Home Elementary OS How to change the computer name in elementary OS

How to change the computer name in elementary OS

by Kiran Kumar
Published: Updated:
change PC 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’.



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.



You may also like


cleteman January 5, 2018 - 2:10 PM

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.

Kiran Kumar January 5, 2018 - 9:13 PM

My bad – missed it. Thanks for highlighting it. I have included it.

cleteman January 6, 2018 - 12:25 PM


Thank you for your insights on all things Linux. They are very informative and helpful. Keep up the good work 🙂

ethan January 27, 2021 - 1:21 AM

Thank you! Saved me from having to do a re-install 🙂

Johnny March 13, 2022 - 8:08 PM

command below worked for me without gedit installation:

pkexec io.elementary.code /etc/hostname

Marc April 4, 2023 - 10:11 AM


after following your instructions the name has been successfully changed, visible in the terminal. Nonetheless, the old name still is potrayed/used in the context of bluetooth connection. Do you know, why? How may it be changed?

Thank you in advance!


Leave a Comment



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us


©2016-2023 FOSS LINUX



“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.