Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I am given an old Ubuntu working system and the previous user had everything on his name so started turning it to my name as typing his name everywhere was bugging me. I tried:

$ usermod -l hussain darhamid

This turned the darhamid@darhamid:$ into hussain@darhamid:$

But I want hussain@darhamid:$ also changed to hussain@hussain. What should I do?

I am using ubuntu 12.04

share|improve this question

marked as duplicate by minerz029, Avinash Raj, Aditya, BuZZ-dEE, Warren Hill Jan 24 '14 at 9:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Possible duplicate: How do I change the computer name? – minerz029 Jan 23 '14 at 9:46
up vote 42 down vote accepted

You have to change the computers hostname as well.

Edit the hostname file and replace the name

gksudo gedit /etc/hostname

also change the name in hosts

gksudo gedit /etc/hosts

Leave the other stuff there untouched.

For the username, it would be cleaner if you deleted the old user and created your new one.

share|improve this answer
Agreed: it's best to make a new user, however it should be pointed out that the new user must be an admin user and must have sudo rights, otherwise the system can never be updated or have new software installed. Perhaps it would be wise to leave the old admin user there as a recovery option. – fabricator4 Oct 26 '12 at 12:28
Thank you that worked fine. – Hussain Nagri Oct 26 '12 at 12:31
You're right, if you don't know how to do this, better leave it as it is ;D – phoibos Oct 26 '12 at 12:35
after reboot, at network connections, while editing wireless hotspot, the old name remained.. my guess is we should grep the whole system for the old name to see if it was left untouched somewhere else :(. Here I have these /etc files /etc/cups/printers.conf.O, /etc/cups/printers.conf and /etc/NetworkManager/system-connections/Hotspot that still contained the old name :(, my guess is not other places for it to be "hiding" :> – Aquarius Power Apr 26 '13 at 1:32
For the hotspot file you can use the network connections configuration, thats surely safe. The printers configuration, at properties, will handle the cups files. – Aquarius Power Apr 26 '13 at 1:42

You'll have to edit /etc/hostname and /etc/hosts, and replace the old hostname with the new.

PS: On the second thought, I'd probably just reinstall to get a clean system.

share|improve this answer
  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.


share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.