To change the hostname (computer name) on a Debian Linux system permanently, you can follow these steps:
- Open the
/etc/hostname
file:sudo nano /etc/hostname
- Replace the existing hostname with your desired hostname. For example:
mynewhostname
- Save and close the file.
- Open the
/etc/hosts
file: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 oldhostname
it should now be:
127.0.1.1 mynewhostname
- Save and close the file.
- Restart your system to apply the changes:
sudo reboot
After the system restarts, you can verify that the hostname has been changed by running the following command:
hostname
The output should be your new hostname.