60.14 Hostname Change

20201104

Changing the system hostname is not always trivial. Over time it permeates to various files in /etc/. The starting point to changing the hostname is with the hostname command. For example to change the hostname to zafira:

sudo hostname zafira

To ensure the changed hostname will survive a reboot edit /etc/hostname to make the same change. This is where the name is obtained at boot time.

sudo editor /etc/hostname

Then search through /etc/ for occurrences of the old name, porsche, and edit as required:

sudo grep -r -n porsche /etc

The hostname might be found in /etc/hosts, /etc/mailname, /etc/motd, /etc/postfix/main.cf, etc/ssh/ssh_host_dsa_key.pub, /etc/ssh/ssh_host_rsa_key.pub, /etc/ssh/ssh_host_ecdsa_key.pub, and various other apache, ppp, ssh, and exim files, depending on the setup. These can usually be edited by hand to replace the hostname.

While these changes can generally be made without any problem, there are rare occasions where the next reboot might complain. It’s useful to be careful, but not concerned!



Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0