The hostname is a unique identifier for a Linux machine within a network. It is typically set during system installation and stored in the /etc/hostname file.
You can view the current hostname by using the hostname command, examining the contents of the /etc/hostname file, or observing it in the command prompt when you log into the system.
There are several ways to change the system's hostname, such as editing the /etc/hostname file directly or using the hostname command. However, the recommended approach is to use the hostnamectl tool. This tool is specifically designed for managing hostnames and ensures that the changes persist after a system reboot. By using hostnamectl, you can avoid misconfigurations and make sure your changes are applied correctly.
user@host:~$ hostname host
user@host:~$ sudo hostnamectl set-hostname newhost
user@host:~$ hostname newhost
user@host:~$ cat /etc/hostname newhost
user@host:~$ bash user@newhost:~$
Comment anonymously. Login not required.