Ubuntu Linux Change Hostname (computer name)

To change the hostname (computer name) on Ubuntu Linux, follow these steps:

  1. Temporarily change the hostname:

You can temporarily change the hostname by using the following command:

sudo hostname <new-hostname>

Replace <new-hostname> with the desired hostname. This change will only persist until the next reboot.

  1. Permanently change the hostname:

To change the hostname permanently, you need to modify the following two files:

  • /etc/hosts: this file maps IP addresses to hostnames and domain names.
sudo nano /etc/hosts

Replace the old hostname with the new hostname in the 127.0.1.1 line.

  • /etc/hostname: this file contains the hostname of the system.
sudo nano /etc/hostname

Replace the old hostname with the new hostname in this file.

  1. Restart the system:
sudo reboot

After restarting the system, the new hostname should be in effect. You can verify the hostname by using the hostname command.

Leave a Comment