How to set or change hostname of a Linux system with example

A hostname is name assigned to any computer which is on a network and this name is used to identify this system in cluster of devices on any network or over the internet.

Websites are identified by their hostname defined over DNS servers (translates hostnames to IP address), else you will have to use IP address instead of their names.

Manage hostname in Linux 

Display hostname

The first command before changing anything is check your hostname



you can also view hostname with cat command

cat /etc/hostname


Change hostname

Host name can be changed by either editing host file /etc/host or by command by using the hostname command.


hostname <new_hostname>


hostname test_system

Once changed confirm changes have been applied by viewing host name.