How to change the hostname on Linux



If we forget to customize the machine name during the installation of the operating system, we can do it later. The easiest method is using the command line.


This instruction is valid for a computer used at home, which is not part of a network. We use the hostnamectl command.


[pratajo@amd64 ~]$ hostnamectl set-hostname new-name


This name is stored in the /etc/hostname file.


We can simultaneously check the machine name, operating system, kernel version and architecture with this command:


[pratajo@amd64 ~]$ hostnamectl status