How to change the computer name in elementary OS

Here's how to change your elementary OS computer name after the set up is complete. We shall use a text editor to change the PC name in the hostname file.

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

Kiran Kumar
Hi there! I'm Kiran Kumar, founder of FOSSLinux.com. I'm an avid Linux lover and enjoy hands-on with new promising distros. Currently, I'm using Ubuntu as a daily driver and run several other distros such as Fedora, Solus, Manjaro, Debian, and some new ones on my test PC and virtual machines. I have a day job as an Engineer, and this website is one of my favorite past time activities, especially during Winter ;). When I'm not writing for FOSSLinux, I'm seen biking and hiking on scenic trails. I hope you enjoy using this website as much as I do writing for it. Feedback from readers is something that inspires me to do more and spread Linux love!. If you find a time, drop me an email or feedback from the 'Contact' page. Or simply leave a comment below if you found this article useful. Have a good day!

3 COMMENTS

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

Leave a Reply to cleteman Cancel reply

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,519FansLike
366FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

How to install Java on Pop!_OS

Having Java on your Linux system is necessary for running a lot of essential software. We have put together a comprehensive guide on how to install Java on Pop!_OS. We shall show you how to install the Java Runtime Environment (JRE) as well as the Java Developer Kit (JDK) using the apt command.

How to setup FTP Server on CentOS

You are allowed to use any one of the FTP servers as you like. However, in this tutorial, we will be installing and using vsftpd, short for Very Secure FTP Daemon. It is a fast, stable, and secure FTP server that will help you transfer files to and from a remote system in a jiffy.

CentOS Vs. Ubuntu Server : Everything You Need to Know

Choosing the perfect Linux distribution to set up your server can be confusing since Linux provides a limitless number of options. The main reason behind these many distributions is because Linux is an opensource platform. Anybody with the required skills can contribute to the development or build and release their distribution. Currently, there are more than 600 Linux Desktop and Server distributions in the market.

Top 10 Reasons to use Xfce as your Desktop Environment

There are many choices for desktop environments for Linux based operating systems. Mainly, you can install any DE of your choice on most of the Linux based distributions, even if they are not offered as a package officially. In our recent articles, we discussed the best of KDE and Cinnamon. In this article, we wish to present to you the top reasons why you should consider Xfce as your desktop environment.

The 10 Best Linux Network Monitoring Tools

Having total control over your network is essential to prevent programs from overusing your network resources and slowing down the overall performance. This is why you should install a network monitoring tool on your system, giving you a visual overview of everything that's happening on your network. Networking Tools are like swiss-knife for the system administrators for troubleshooting system issues.

How to install CouchPotato on Ubuntu

Downloading movies and copying them over to your home server can get frustrating, especially if you are doing it daily! What if you have an option to download videos automatically, quickly, and above all with excellent quality. CouchPotato allows you to download movies easily once they are available and released automatically.

MUST READ

Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

5 Best Notepad++ Alternatives for Linux

Notepad++ has been the de facto standard for source code editors for nearly 16 years, almost since its creation in 2003.  For Windows users, that is.  For years, Linux users had no source code editor that compared to Notepad++ with all its bells and whistles, such as code folding, scripting, markup languages, syntax highlighting, auto-completion for programming (limited).

5 Best Music Players for Linux

For sure, there will be Linux users out there who cannot live without music. If you're one of those people, you would know how important it is to have a good music player installed on your computer system. In this article, we present to you the five Best Music Players for Linux, which will hopefully be able to satisfy each of our readers' needs.

3 Best Ways to Uninstall Software on Ubuntu

Uninstallation of programs can be done by graphical way using the Ubuntu Software Center, and the Synaptic Package manager. Command-line way of doing it is also possible using apt-get and aptitude commands. We shall discuss each one of them in detail.

7 Best Ways to Kill Unresponsive Programs in Linux

For dealing with a frozen app or desktop, you can't use the CTRL+ALT+DEL in Linux system. Instead, there are powerful alternatives that come in handy in frustrating situations. We pick the best methods available for you.