{ 37 comments… read them below or add one }

1 Joe P. November 17, 2007

gave me exactly what I was looking for. Thanks.

Reply

2 balaji March 4, 2011

how to change the user name in linux

Reply

3 rxfelix February 12, 2008

You might want to mention the possible additional tasks required to make a complete username changeover, such as changing the home directory name, the mail spool file name, or the group names. Otherwise an unexperienced sysadmin might use this command but break the user’s mail or other services.

Reply

4 ubuntu April 22, 2008

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

Reply

5 Sys Admin June 7, 2008

As with any potentially dangerous operation, you should back up the user’s data before the migration.

This will allow you to recover from the situation should the problem arise.

Reply

6 johncruise June 8, 2008

very useful. thanks!

Reply

7 kamal January 6, 2009

open Suse
chenge username

usermod -l new old

Reply

8 hassan March 19, 2009

Can we creat a user with the root permissions? if yes please explain how?

Reply

9 hassan March 19, 2009

Can we creat a user with the root permissions? if yes please explain how?
I know root has 0 UID but when i try to assign 0 to any other user it gives me message that id is not unique.

Reply

10 Jo July 3, 2009

This tips is awesome!!!
Thanks

Reply

11 Tamika crockrum July 5, 2009

Great ideal huh

Reply

12 dan July 10, 2009

How to give a user root privileges:
1. open terminal and type “visudo” or “sudo visudo” (you need root privileges)
2. find the line “root ALL=(ALL) ALL ”
3. under that line copy the “root ALL…” line but replace root with your username
example. “dan ALL=(ALL) ALL”
4. make sure you don’t remove any lines in that file
5. If you don’t want to use the visudo command, you could just use a text editor and edit the /etc/sudoers file.

Hope that was helpful
-dan

Reply

13 JuR June 14, 2011

Thank you for that,
but could you help me with saving the file? When I’m on terminal and have written all the needed modifications, how do I save and exit?

Cheers

Reply

14 Aaron July 2, 2011

the editor you are using during that operation is vim

Reply

15 dan July 10, 2009

oh also, instead of adding a line in that file you could uncomment the line that starts with #%admin

so it looks like %admin ALL=(ALL) ALL
then save it
add any users to the admin group to give them admin privileges

same thing can be done for the”%sudo” line (although im not sure about it”

Reply

16 omar July 17, 2009

to change the login for ubuntu 9.04 I used:
# sudo usermod -l

Reply

17 Ruben September 29, 2009

How do yo rename an account in unix sun Solaris 10

Reply

18 paula Ojukwu October 6, 2009

ok mine challenge is different.i want to change from root to a user name.
i have tried all i know how.
please some one help me.

Reply

19 lavanya November 25, 2009

change id

Reply

20 Jacques November 29, 2009

As I recall, usermod only updates UIDs for files in the user’s home directory and the mail spool. You also have to consider files in /tmp or /var that can be persistent between user sessions, or even reboots depending on your OS. I just do this to ensure that all files have been changed,

find / -user 5001 -exec chown -h 10000 {} \;

or maybe this,

find / -user 5001 | xargs chown -h 10000

Use the ‘-h’ switch to chown so that it updates the ownership of symbolic links rather than what the symlink points to.

Reply

21 mrom August 20, 2010

good hint! but i would rather use:

# find / -user 5001 -print0 | xargs -0 chown -h 10000

this handles files with spaces, backslashs or quotation marks correctly.

Reply

22 soundar January 28, 2010

hi
to create user with non-unique UID
useradd -g groupname -o -u UID newusername
ie : useradd -g root -o -u 0 soundar

Reply

23 Anonymous May 7, 2010

Thank you! That works great!!

Reply

24 sayantan February 19, 2010

its leads to a gconf error on rhel 5.

Reply

25 kiran March 26, 2010

# useradd -g root -o -u 0 postgres
UX: useradd: ERROR: Inconsistent password files. See pwconv(1M).

Reply

26 kiran March 26, 2010

# uname -a
SunOS hyd-BNW 5.10 Generic_139555-08 sun4u sparc SUNW,Sun-Fire-V240

Reply

27 Aldo "xoen" Giambelluca May 2, 2010

Maybe you saved my life :P, thank you :).

Reply

28 Dating in Ireland May 3, 2010

Exactly what I was looking for.
Thanks!

Reply

29 jseamus June 5, 2010

In Ubuntu 10.04, when I tried it, it returned this:

$ sudo usermod -l new old
usermod: user old is currently logged in

This happened even when I was changing “old” to “new” from a different user account while “old” was logged out.

Any help please?

Reply

30 Alex October 14, 2011

If you receive the error “usermod: user is currently logged in”, this is probably because you’re trying to change a username while their account is being used by one or more processes.

Getting around this problem is usually pretty straightforward:

- create a new user, e.g. I created an “admin” user, with root privileges
- restart your machine and log in as them (this is the best way to ensure no processes continue to run as the user whose name you want to change)
- retry the command (don’t forget you will probably need to run it with sudo, e.g. “sudo usermod -l “)

Reply

31 recluce June 14, 2010

It seems that you must restart your system in Ubuntu 10.04, login to the different user account and do the changes. Once you were logged in to the account to be changed, it will not work anymore. No idea why.

BTW: if you use WINE, look at the .reg files of WINE and change your /home folder name accordingly – or you will seriously bork Wine!

Reply

32 pev January 4, 2011

Wow just what I was looking for thanks.

Just remember to change the owner’s group (gid) as well (run this after the uid change)

# find / -group 5001 -print0 | xargs -0 chown -h :10000

Reply

33 matias February 24, 2011

“$ sudo usermod -l new old
usermod: user old is currently logged in”
I killed all his tasks. It works.

Reply

34 Tim March 9, 2011

What’s the terminal file in unix ?
Does the terminal files created when a use log in ?

Reply

35 nt September 14, 2011

I want creat a user have id = 0. how can I do it??
when I delete dir home of user I can’t login this user. Why?

Reply

36 gnb November 16, 2011

will this work if my home drive (corresponding to the USR-NAME being changed) is encrypted? I am a bit afraid. Can you reply on this please! Thanks in advance — GNB

Reply

37 quick December 30, 2011

guys, I made a adjustment in sudoers file and deleted the % in the group section. afterwards i cannt access the sudoers file anymore.
error my user do not have the permission to access.
can someone help
ubuntu 10.11

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 3 + 4 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: