Debian Linux: Change Hostname / Computer Name Permanently

Debian Linux: Change Hostname / Computer Name Permanently

To change the hostname of a Debian system permanently, you can follow these steps:

  1. Open the /etc/hostname file using a text editor such as nano:
refer t‮uttual:o‬ri.com
sudo nano /etc/hostname
  1. Replace the current hostname with the desired hostname. For example, if you want to change the hostname to "new-hostname", the file should contain only the following line:
new-hostname
  1. Save the file and exit the text editor.

  2. Open the /etc/hosts file:

sudo nano /etc/hosts
  1. 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".

  2. Save the file and exit the text editor.

  3. Run the hostname command to set the hostname immediately:

sudo hostname new-hostname
  1. Reboot the system for the changes to take effect permanently:
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.

Created Time:2017-10-28 14:02:25  Author:lautturi