How to change the computer name in elementary OS

So you have installed elementary OS in a hurry only to realize you made a typo or gave a weird name or left the default name having the PC maker and model for the computer name? Just my guess! You didn’t bother it much until you start seeing it in the Terminal’s command prompt.

In this mini-tutorial, we show you how quick it to change the computer name on your elementary OS PC. To achieve what we want, we shall edit the hostname in the system file using “gedit” command, and also configure the hosts file too so that you don’t get “unable to resolve host” error message when using the “su” or “sudo” command.

Changing the PC name

STEP 1: Click on ‘Applications’ and launch ‘Terminal’.

STEP 2: Type the following command line and hit enter.

sudo gedit /etc/hostname

Terminal gedit command
Terminal gedit command

As you can notice, we are using gedit to edit the hostname file. Just for the unware, gedit is the default text editor of the GNOME desktop environment and part of the DE’s core Applications. All Ubuntu and derivatives should have it installed by default. For some reason, if your elementary OS shows gedit is not installed, fire the following command in the terminal to install it.

sudo apt-get install gedit

STEP 3: You should see a new window with the current computer name in it. In my test PC, the name is ‘FOSSLinux’. I will change it to ‘PC_NAME_CHANGE’ just for the sake of this tutorial. You can enter whatever the new name you want.

STEP 4: When done, click ‘Save’.

gedit_hostname
gedit_hostname

STEP 6: Finally, update the new name in the hosts file too in a similar way with the following command. (Thanks to cleteman in the comments below.)

sudo -i gedit /etc/hosts

STEP 7: Close everything and restart the computer.

STEP 8: Launch ‘Terminal’ to see your new computer name in the command prompt.

Computer_Name_Changed
Computer_Name_Changed

Leave a comment

Your email address will not be published. Required fields are marked *