Take the tour ×

I installed Ubuntu on a computer that is now used by somebody else. I renamed the account with her name, but it only changes the fullname, not the user name, which is still displayed in the top right (in the fast-user-switch-applet). Is there a command to rename an Unix user account?

I've thought of creating a new user account with the new name, and then copying everything in the "old" home to the home of the new account. Would it be enough? But then I think the files would have the old account's permissions' owner? So should I do chown -R newuser ~?

Is there a simpler/recommended way to do this?

share|improve this question
add comment

2 Answers

up vote 31 down vote accepted


usermod --move-home --login <new-login-name> --home <new-home-dir> <old-login-name>

The --move-home option moves the old home directory's contents to the new one given by the --home option which is created if it doesn't already exist.

If you want the primary user group to match the new-login-name, add --gid <new-login-name> to the command above, but the group must be pre-existing.

See the man page for more info:

man usermod
share|improve this answer
Thanks! I didn't know about this command. :) However, that's the only account on this computer and the man says this: « You must make certain that the named user is not executing any processes when this command is being executed if the users numerical user ID, the users name, or the users home directory is being changed. usermod checks this on Linux, but only check if the user is logged in according to utmp on other architectures. » Would you suggest using a live cd to do this or creating a temp account that I will delete once it's done? –  Yann Dìnendal Aug 18 '10 at 10:30
Since you're using Ubuntu and can't login as root, I would create another account called, say, admin that you use for just this type of task. A temporary account will work just as well but you might as well keep it since you could be doing similar things in the future. –  gvkv Aug 18 '10 at 15:23
I will do that, thanks. :) –  Yann Dìnendal Aug 18 '10 at 17:41
add comment

While it's possible to rename a user, and usermod will do some of the job, this is quite likely to cause trouble. Here's a list of places where the user name may appear; I do not claim that this list is exhaustive.

  • The user entry in /etc/passwd and related files (e.g. /etc/shadow, /etc/master.passwd).
  • Group entries in /etc/group (and /etc/gshadow).
  • Possibly entries in /etc/sudoers.
  • The system mailbox, typically /var/mail/$USER or /var/spool/mail/$USER.
  • The crontab, typically /var/spool/cron/crontabs/$USER
  • In at jobs (/var/spool/cron/atjobs/*)

The home directory is likely to appear in even more places. Many applications write absolute paths in various dot files. If you decide to rename the home directory as well (while there's no requirement that user alice's home directory be /home/alice, having it be /home/bob would be confusing), you'll need to take care of those. A global replacement will work for most applications, but I make no promises. If possible, keep the old home directory name as a symbolic link to the renamed directory.

share|improve this answer
add comment

Your Answer


