2

Possible Duplicate:
How do I change my username?

I'm making a small ubuntu network, and in client 10.04 I "logged in" as the user "employee1", and changed my name to "Red Herring" but i cannot change the shortname for this account. Are there terminal commands or something that I need to use to do this? I can't find any GUI ways of doing it.

Thanks,

Devin

Devin
  • 21
  • You need to have a administrator account to do that. Red Herring, is it a Administrator account ? If yes then first create a another admin account, log in through it, then you will probably have the option to change or delete Red Herring. – Curious Apprentice May 04 '12 at 02:40

1 Answers1

2

See man usermod:

   SYNOPSIS
      usermod [options] LOGIN


   -d, --home HOME_DIR
       The user's new login directory.

       If the -m option is given, the contents of the current home
       directory will be moved to the new home directory, which is
       created if it does not already exist.

   -m, --move-home
       Move the content of the user's home directory to the new location.

       This option is only valid in combination with the -d (or --home)
       option.

       usermod will try to adapt the ownership of the files and to copy
       the modes, ACL and extended attributes, but manual changes might
       be needed afterwards.



   -l, --login NEW_LOGIN
       The name of the user will be changed from LOGIN to NEW_LOGIN.
       Nothing else is changed. In particular, the user's home directory
       name should probably be changed manually to reflect the new login
       name.

So you want

sudo usermod -m -d /home/new_login_name old_login_name
sudo usermod -l new_login_name old_login_name

The first command will move your login directory; the second command will edit the relevant files that reference your name (/etc/passwd, /etc/shadow, /etc/groups) of old_login_name to new_login_name. You didn't ask, but you may also want to change your group name as with groupmod in an analogous fashion (sudo groupmod -n new_group_name old_group_name).

dr jimbob
  • 248