Debian Linux: Change Hostname / Computer Name Permanently
To change the hostname (computer name) on a Debian Linux system permanently, you can follow these steps:
- Open the
/etc/hostnamefile:sudo nano /etc/hostname - Replace the existing hostname with your desired hostname. For example:
mynewhostname - Save and close the file.
- Open the
/etc/hostsfile:sudo nano /etc/hosts - Find the line that contains your current hostname and replace it with your new hostname. For example, if the line was:
127.0.1.1 oldhostnameit should now be:
127.0.1.1 mynewhostname - Save and close the file.
- Restart your system to apply the changes:
sudo reboot
hostnameThe output should be your new hostname.
