≡ Menu

Ubuntu: Rename an Account [ User ID ]

How do I rename a user name from ‘tom’ to ‘jerry’ under Ubuntu Linux?

You need to use the usermod command. It can modify the system account files (such as /etc/passwd) to reflect the changes that are specified on the command line. The syntax is as follows:
usermod -l {new-login-name} {current-old-login-name}
In this example, rename login id from tom to jerry. Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following command
$ sudo usermod -l jerry tom
To verify new changes, enter:
$ id jerry

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:



{ 3 comments… add one }
  • Kirk December 15, 2010, 5:21 pm

    Correct me if I am wrong though, but this does not change the user’s home directory to match the new ID, right?

    • nixCraft December 15, 2010, 6:38 pm

      Try the -m and -d /home/jerry option; the contents of the current home directory will be moved to the new home directory, which is created if it does not already exist:

      usermod -m -d /home/jerry -l jerry tom
      ### gone ###
      ls /home/tom 
      ### as it moved to ###
      ls /home/jerry
      

      You may have to take care of secondary group memberhsip too.

      • Kirk December 15, 2010, 8:37 pm

        Exactly. Be worth updating your original FAQ, no so that the user transformation is complete.

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">


   Tagged with: , , , , , , ,