online prescription solutions
online discount medstore
pills online
buy lorazepam without prescription
xanax for sale
buy xanax without prescription
buy ambien without prescription
ambien for sale
buy modafinil without prescription
buy phentermine without prescription
modafinil for sale
phentermine for sale
lorazepam for sale
buy lexotan without prescription
bromazepam for sale
xenical for sale
buy stilnox without prescription
valium for sale
buy prosom without prescription
buy mefenorex without prescription
buy sildenafil citrate without prescription
buy adipex-p without prescription
librium for sale
buy restoril without prescription
buy halazepam without prescription
cephalexin for sale
buy zoloft without prescription
buy renova without prescription
renova for sale
terbinafine for sale
dalmane for sale
buy lormetazepam without prescription
nobrium for sale
buy klonopin without prescription
priligy dapoxetine for sale
buy prednisone without prescription
buy aleram without prescription
buy flomax without prescription
imovane for sale
adipex-p for sale
buy niravam without prescription
seroquel for sale
carisoprodol for sale
buy deltasone without prescription
buy diazepam without prescription
zopiclone for sale
buy imitrex without prescription
testosterone anadoil for sale
buy provigil without prescription
sonata for sale
nimetazepam for sale
buy temazepam without prescription
buy xenical without prescription
buy famvir without prescription
buy seroquel without prescription
rivotril for sale
acyclovir for sale
loprazolam for sale
buy nimetazepam without prescription
buy prozac without prescription
mogadon for sale
viagra for sale
buy valium without prescription
lamisil for sale
camazepam for sale
zithromax for sale
buy clobazam without prescription
buy diflucan without prescription
modalert for sale
diflucan for sale
buy alertec without prescription
buy zyban without prescription
buy serax without prescription
buy medazepam without prescription
buy imovane without prescription
mefenorex for sale
lormetazepam for sale
prednisone for sale
ativan for sale
buy alprazolam without prescription
buy camazepam without prescription
buy nobrium without prescription
mazindol for sale
buy mazindol without prescription
buy mogadon without prescription
buy terbinafine without prescription
diazepam for sale
buy topamax without prescription
cialis for sale
buy tafil-xanor without prescription
buy librium without prescription
buy zithromax without prescription
retin-a for sale
buy lunesta without prescription
serax for sale
restoril for sale
stilnox for sale
lamotrigine for sale

Linux: How do you rename a user account in linux?

In Linux, there is no command which will rename a user account. If you make a mistake creating a user account, user changes their name or if user does not like his user name, there is no real easy way of going and making the change. Only thing I know you can do is to go through some files and rename user manually. Let us say that we have a user who is named joe and we want to rename him to john.

Note: you must be logged in as root to do following.

vi /etc/passwd
find joe and change it to john, save/exit

vi /etc/group
find joe and change it to john, save/exit

vi /etc/shadow
find joe and change it to john. This file is read only and you have to force overwrite it. In vi it is :w! once saved, quit.

cd /home
mv joe john

And that should do the trick.

[Edited] Right after I posted this post, I was contacted and was told to look at utility called usermod. Read more about it man usermod. Got to love the quick responses.

DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. Use at your own risk.

14 Responses to “ Linux: How do you rename a user account in linux? ”

  1. she
    May 9th, 2008 | 5:09 am

    hmm the linux tools should take care of that IMO

  2. May 9th, 2008 | 5:35 am

    Yeah as I updated the post, there is a utility: usermod

  3. May 9th, 2008 | 6:25 am

    The comment from ’she’ is correct. The usermod command will let you do just about everything. If you find that you must edit the passwd or group files, you should never use vi to edit them. Instead, you should use vipw and vigr for that. After editing, they will prompt you to edit the shadow files as well. They do a few others things, like making sure the temporary file used is more secure from prying eyes and general naughtiness.

    Another thing to note, if the user created files or directories outside of their home directory before the username changed, you’ll need to find those files and change the ownership. A few that spring to mind are mail in the /var/mail directory, crontab files and at jobs.

  4. May 9th, 2008 | 6:29 am

    I left out an important clause from my last paragraph. You need to find and change ownership of files if you change the UID or GID numbers for a user.

  5. May 9th, 2008 | 9:17 pm

    Thanks for the great information Stoner.

  6. May 10th, 2008 | 6:06 am

    I’d still only recommend this for a new user, not one who is established. Last time I did this, I had a number of problems with things which had hardcoded the equivalent of /home/joe/… into their configuration. (Mozilla in particular. I had to start afresh there, and it was painful. But maybe they’ve fixed that in the intervening 5 years.)

  7. Johan L. Cerezo
    October 22nd, 2008 | 8:39 pm

    Additional info, If your linux box is a mail server, you must also change the name of the file found in /var/spool/mail. Example from above joe to john. So you can still retrieve your old mail found in your inbox using thunderbird, outlook(client) and alike.

  8. Eu
    August 20th, 2009 | 2:00 pm

    Sorry but this article is misleading, first says theres no way to change the username in linux and then crosses that, then gives a manual procedure which is absolutely not pratical because all of it can be done with a single linux command… i suspect that simply replacing all the text in this article with: “usermod -l old_name new_name” would do us all a great favor!

  9. kopper
    November 12th, 2009 | 11:06 pm

    would this be enough

    killall -u old
    id old
    usermod -l new old
    groupmod -n new old
    usermod -d /home/new -m new
    usermod -c “New Real Name” new
    id new

  10. noiamsamiam
    January 21st, 2010 | 11:05 am

    Your instructions were a big help for me to rename my user and move my home folder on 9.10

    Using kopper’s instructions my approach was this for Ubuntu 9.10

    1. Login to your user account
    2. Go to Menu System > Administration > Users and Groups
    3. Unlock by clicking on keys “Unlock to make changes”
    4. Enter your user account password when prompted
    5. User settings now unlocked > Select Add User
    6. In Basic Settings tab define you new username for your admin account and real name (This is the friendly name you are shown in the Ubuntu 9.10 login screen
    7. Select the profile drop down box and select administrator
    8. Create your new password (something decent since this account has more privileges than the standard desktop account)
    9. Logout of your current account
    10. At Ubuntu login screen login to the newly created admin account
    11. Open a terminal window from Menu Applications > Accessories > Terminal
    12. type command sudo -i to get root access
    13. execute command killall -u oldaccountusername
    14. execute command id oldaccount username
    15. execute command usermod -l newaccountusername oldaccountusername
    16. execute command groupmod -n newaccountusername oldaccountusername
    17. execute command usermod -d /home/newaccountusername -m newaccountusername
    18. execute usermod -c “New User Account Friendly Name for Logon Screen” newaccountusername
    19. execute id new
    20. execute ls /home/ and you should see a new home folder matching the new username that you changed from the old username and if you ls /home/newaccountusername you should see the all the files and folders that were in the home folder for your oldaccountusername
    21. close the terminal window
    22. logout of the adminuser account on Ubuntu
    23. Ubuntu login screen should now show only the admin account and your changed useraccountname.
    24. Login in to this user account using your old password from the same account before it was renamed.
    25. You should now be logged in to your account under the new username and have access to all the same files, settings and applications as the account before it was renamed.

    I’m sure there is a quicker approach to achieve this but this is what worked for me.

    Thanks again to kopper who contributed the nuts and bolts of getting this working

  11. alaakhalaf
    June 13th, 2010 | 6:07 pm

    Hallo all
    I think firs you should install package ‘libuser’ using this command
    sudo apt-get install libuser
    and then execute this command
    sudo lusermod -l newname oldname

  12. May 11th, 2011 | 9:48 am
  13. Ruchir
    March 13th, 2012 | 3:45 am

    Thanks buddy… it’s working ….

  14. June 6th, 2013 | 5:40 am

    [...] You can use usermode, and/or edit manually the relevant files, mainly /etc/passwd, /etc/group and /etc/shadow. Don’t forget to move around the home folder, too. See also: Crazytoon – How do you rename a user account in linux? [...]

Leave a reply

To prove that you're not a bot, enter this code
Anti-Spam Image