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

Top 20 Rsync Examples in Linux

The Rsync (remote sync) command is a Linux/Unix utility used to synchronize and copy files and directories either locally or remotely. Most Linux geeks use Rsync to mirror, backup or migrate data across folders, across disks and networks. One notable feature with the Rsync command is that it uses the "delta transfer algorithm."

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.

The 10 Best Programming Languages for Hacking

One of the significant entities we have in Cyber Security is Ethical Hacking (ETH). It is the process of detecting and finding flaws or vulnerabilities in a system that a hacker would exploit.

What is the difference between Linux and Unix?

When discussing Linux and Unix with average users, it's not uncommon that they will sometimes mistakenly interchange the terms Linux and Unix.  The two are not the same.  Though they share similarities in their overall structures and toolkits, they are decidedly not the same.

VIDEO: Linux Lite 4.8 Features and Desktop Tour

Linux Lite eases Windows 7 users transition to Linux much more comfortable by offering simple software like Team Viewer, VLC, Firefox, TimeShift backup utility, and a full Microsoft Office compatible office suite in LibreOffice.

Manjaro ‘Gellivara’ XFCE Edition (17.0.5) in 10 Screenshots

Want to take a quick virtual tour Manjaro XFCE edition instead of downloading GBs worth of ISO image and then making a Live USB of it? We will make it easy for you. Here are a series of screenshots of the important aspects of Manjaro Linux in XFCE edition. This is a light-weight edition, and aims to be fast and low on system resources. You will be amazed on how it is still visually appealing and user friendly.