Linux Hostname

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Linux hostname

With the help of hostname command you can set and view hostname of the system.


  1. hostname  

Linux Hostname1

Look at the above snapshot, our hostname is JavaTpoint.

Setting hostname

Using hostname command you can set it on the system.


  1. sudo hostname <newName>  


sudo hostname 

Linux Hostname2

Look at the above snapshot, we have set as our hostname.

The above hostname is not permanent. Hostname set with command hostname are not permanent. On rebooting the system, hostname will change to the one that is specified in hostname file.

To set hostname permanently you have to save it in hostname file present on the server. After setting you have to reboot the box.

For Ubuntu, /etc/hostname file is used.

For RHEL, /etc/sysconfig/network is used.