Nothing can be more frustrating in Linux than making hostname changes and learning after a reboot that your changes didn’t stick. Here’s just a few things that I did to make the hostname permanent while working in Ubuntu 10.04. This might work in other Debian-based distributions. Let’s assume the name of your system is ‘desktop.’
Edit your hosts file.
sudo vi /etc/hosts</code> |
Add this. You can drop the domain if you don’t plan on using it.
127.0.0.1 desktop desktop.domain.com |
Edit your hostname file.
sudo vi /etc/hostname</code> |
Add your hostname. Domain is optional.
desktop.domain.com |
Finally, change your hostname.
sudo hostname desktop |