
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. You didn’t bother it much until you start seeing it in the Terminal’s command prompt! Don’t worry, it is easy to change the computer name. We shall edit the host name in the system file using gedit command.
STEP 1: Go to ‘Applications’ and launch ‘Terminal’.
STEP 2: Type the following command line and hit enter.
sudo gedit /etc/hostname

As you see, we are using gedit to edit the hostname file.
STEP 3: You will 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 illustration. You can enter whatever the new name you want.
STEP 4: Click ‘Save’.

STEP 6: Finally, update the new name in the hosts file too in similar way with the following command. (Thanks to cleteman)
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.

Leave a Reply
3 Comments on "How to change the computer name in elementary OS"
One more step:
Update the /etc/hosts file with the new hostname.
Other wise you will get an “unable to resolve host” msg when using su or sudo cmd.
My bad – missed it. Thanks for highlighting it. I have included it.
Kiran,
Thank you for your insights on all things Linux. They are very informative and helpful. Keep up the good work 🙂