Ubuntu: How to Change the Computer Name
You might run into a situation that requires you to change your computer name, either because you need it to meet a naming scheme or you’re just bored with it and want something better. By following these steps, you’ll give your computer a new identity in no time.
1. Open a terminal window.
2. Input the following command and hit Enter:
gksudo gedit /etc/hostname
3. When prompted, enter the administrator password and click the OK button.
4. The hostname file will open, displaying the current computer name. Replace the current computer name with the desired new name.
5. Click Save.
6. Close all open windows and restart your system.
After your system has restarted, it will have the new computer name.







ubu-fan said on January 25, 2009
hey thnx for the tutorial, worked like a charm ;)
kumareshane1986 said on May 5, 2009
its working pretty cool…
Rahul said on June 5, 2009
Thanks
Lurker said on June 17, 2009
I would change the /etc/hosts first if you don’t the machine can not create a window. Otherwise works great on Ubuntu 9.04
Greg said on December 5, 2009
You may (will) want to edit your /etc/hosts file too. So that your system isn’t confused by the change: (sudo gedit /etc/hosts) look at the second line typically.
Anonymous said on December 8, 2009
So simple? I can”t believe it. I always wanted my computer to bare a good name but, like in any other operating system, I’ve been using Administrator or other general words.
____________
Mathew Farney – Web Hosting
Name said on January 17, 2010
As mentioned before, you’ll need to change your /etc/hosts file as well. If you change the /etc/hostname first, Ubuntu probably won’t let you open the /etc/hosts file with the gedit command. You can get around this with:
sudo vi /etc/hosts
Lars said on February 11, 2010
Very helpful, thank you. What is the character limit?
ralph said on April 23, 2010
thanks
Nick Djinn said on May 16, 2010
Thanks!
Yashwant108 said on July 17, 2010
Thanks
Anonymous said on July 21, 2010
That’s very interesting, I will bone up on the subject and then express myself regarding the problem
Anonymous said on July 30, 2010
There are simple commands on Linux:)) Never thought I would see that soon enough. Thanks for the piece of advice. Very useful for non-Linux users that have to deal with Linux.
________________________________________
computer checkup
Tiburon19 said on August 12, 2010
this is awesome. best decision was to go linux. Thanks for the advice.
Salman said on September 2, 2010
thnks it work 4 me thnks again———————————————————
nyomz said on September 4, 2010
thanks. it’s so helpful..
Rodrigo Primo said on September 18, 2010
Please update the post and mention that you need to edit /etc/hosts as well as others mentioned before. Thanks.
olof nord said on September 30, 2010
thank you!
Aniruddh said on December 9, 2010
Thanks
Anonymous said on February 21, 2011
Is there an official way to do this instead of using a hack on the command line? Obviously this solution is not complete, as it does not change the hosts file. There should be an official GUI way to change the hostname that changes all relevant files at the same time.
Dahc said on March 3, 2011
so whats the complete process? Do I change (sudo gedit /etc/hosts) this first or what? Sorry I’m new to Linux. I have to put this in the Terminal command line right. My IT guy did all of my Ubuntu stuff for me and he”s gone now and so am I. I need some training on Linux in general, any suggestions as to where to get it?
Anon said on March 16, 2011
Thanks!!
Greg said on March 24, 2011
Well, this is the “official” way, Junior…at least for Debian and derivatives such as the *buntus, etc. There might be a GUI thingy out there somewhere to do it, but it’s just simple enough as it is:
Change the hosts file first and then change the hostname file. Then restart your networking and you’re all set.
1) From a command line: sudo gedit /etc/hosts – will give you something like:
127.0.0.1 localhost.localdomain
127.0.1.1 “computername”.”domain_name” “computername”
..change the “computername” parts to whatever you want and “domain_name” part if you have to/want to to make it complete….Then save it.
2) Run (also from command line): sudo gedit /etc/hostname
put your new hostname in where the old one was…and save this file, too.
3) Restart your computer or restart networking from the command line.
If you’re running RedHat or another flavor of Linux the process is pretty similar, just the filenames and details are different.
gahh said on March 24, 2011
You’re forgetting something.
Yet another reason why I switched from Ubuntu to Windows 7. Stuff Just Works.
remove Blueflare Antivirus said on May 24, 2011
Change the computer name is easy.
windows xp recovery virus said on May 25, 2011
You saved my alot of time thank you so much for sharing your experience.
Gil said on December 30, 2011
Very simple and easy.
Thanks.
kalpesh said on January 8, 2012
thnx buddy