Every Linux machines comes with a host name, which is normally configured during system installation. It is stored in /etc/hostname and normally displayed at the terminal as \h in the PS1 environment variable.
Current host name of the system can be viewed via hostname command or by viewing the content of the /etc/hostname file.
System host name in Linux could be changed via hostname command but it is not persistent as it will return to the original host name after the system reboots.
[email protected]:~$ hostname host [email protected]:~$ sudo hostname newhost [email protected]:~$ hostname newhost [email protected]:~$ cat /etc/hostname host
The proper way to change system host name in Linux and make it persist or permanent is by using hostnamectl tool at the terminal.
[email protected]:~$ hostname host
[email protected]:~$ sudo hostnamectl set-hostname newhost
[email protected]:~$ hostname newhost
[email protected]:~$ cat /etc/hostname newhost
[email protected]:~$ bash [email protected]:~$
Comment anonymously. Login not required.