Skip to the content.

Change Hostname Of A System

Typically, hostname of a system is stored in /etc/hostname, and we can change that by writing a new hostname in /etc/hostname file.


  1. Edit /etc/hostname with any text editor such as nano or vim, and replace the exisitng hostname -
$ sudo nano /etc/hostname
  1. Save and reboot -
$ sudo reboot

To display current hostname, we can use hostname command.

Source: CyberCiti