Skip to content
TrySitePrice

Debian Linux: Change Hostname / Computer Name Permanently

Best/Tutorial

To change the hostname (computer name) on a Debian Linux system permanently, you can follow these steps:

  1. Open the /etc/hostname file:

    sudo nano /etc/hostname

  2. Replace the existing hostname with your desired hostname. For example:

    mynewhostname

  3. Save and close the file.
  4. Open the /etc/hosts file:

    sudo nano /etc/hosts

  5. 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

  6. Save and close the file.
  7. Restart your system to apply the changes:

    sudo reboot

rnAfter 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.