[HowTo] Change a hostname after Linux installation
I usually set hostname during Linux installation, but many people don’t. Then without a knowledge it could take some time to change it correctly.
Doing so:
hostname newhostnamewill only change hostname temporary, after system reboot it will change back to what it was specified during installation.
So the right (my) way of changing hostname:
- Some linux systems keep hostname record in /etc/sysconfig/network
HOSTNAME=localhost.localdomain
- Debian systems /etc/hostname
localhost.localdomain
- Additionally hostname is kept in /etc/sysctl.conf
kernel.domainname = localdomain (usually uncommented)
kernel.hostname = localhost
And at the end, don’t forget to add hostname to /etc/hosts file like this:
127.0.0.1 newhostname.localdomain newhostname
or
127.0.0.1 newhostname
Otherwise services like Apache, Squid and many others won’t run correctly or won’t run at all if they can’t resolve the hostname either by hosts file or DNS server.
No Comments, Comment or Ping
Reply to “[HowTo] Change a hostname after Linux installation”