To change the hostname of a Debian system permanently, you can follow these steps:
/etc/hostname
file using a text editor such as nano:sudo nano /etc/hostname
new-hostname
Save the file and exit the text editor.
Open the /etc/hosts
file:
sudo nano /etc/hosts
Find the line that contains the current hostname, and replace it with the new hostname. For example, if the current hostname is "old-hostname", you should replace it with "new-hostname".
Save the file and exit the text editor.
Run the hostname
command to set the hostname immediately:
sudo hostname new-hostname
sudo reboot
After rebooting, your system's hostname will be changed to the new hostname. You can verify the hostname by running the hostname
command.