He, Peng

A Roboticist.

The secret of getting ahead is getting started.

How to change the Username and Hostname on Ubuntu

Change the username

At the start screen press Ctrl+Alt+F1.
Log in using your username and password.
Set a password for the "root" account.

sudo passwd root  

Log out.


Log in using the "root" account and the password you have previously set.
Change the username and the home folder to the new name that you want.

usermod -l <newname> -d /home/<newname> -m <oldname>  

Change the group name to the new name that you want. I'm not so sure about which group should I change to

groupmod -n <newgroup> <oldgroup>  

Lock the "root" account.

passwd -l root  

If you were using ecryptfs (encrypted home directory). Mount your encrypted directory using ecryptfs-recover-private and edit <mountpoint>/.ecryptfs/Private.mnt to reflect your new home directory.
Log out.


Press Ctrl+Alt+F7.

Change the hostname, which is the computer name

Type the following command to edit /etc/hostname using nano or vi text editor:

sudo nano /etc/hostname  

Delete the old name and setup new name.
Next Edit the /etc/hosts file:

sudo nano /etc/hosts  

Replace any occurrence of the existing computer name with your new one.
Reboot the system to changes take effect:

sudo reboot  

Change the password


Super easy, isn't it?

Earlier Posts

My To Do List

Personally, I want to form my blog as a shorthand posting place for all the deep learner. As we step…

In logRead More
comments powered by Disqus