Published February 23, 2018 by

How to Change Hostname in Ubuntu

This is a simple and short article for show How to Change Hostname (Computer Name) in Ubuntu/Debian based distribution Linux OS.

1. Display current hostname

# hostname

2. Change Hostname

# hostname new_host_name

This command temporary set a hostname for your system until next reboot.


3. To change the hostname permanently, run below command to edit the host files /etc/hostname.

# sudo vim /etc/hostname

In /etc/hostname file give new hostname what you want and save them.


4. Finally, restart your system to apply the changes.

# reboot