How To change user name and UID

Hi,
I was asked to change the ID of the mysql user and gourp on one of my servers.
this is a very simple to do.

first type
# id mysql
uid=101(mysql) gid=103(mysql) groups=103(mysql) 
to change the user id type:
# usermod -u 25 mysql
to change the group id run the next command under root user:
# vigr
search the mysql group mysql:x:103: the change it to 25 mysql:x:25:
(save with /wq like regular vi)
OR
# groupmod -g 25 mysql
now run again:
# id mysql
uid=25(mysql) gid=25(mysql) groups=25(mysql)

to change user name run:
# usermod -l old_name new_name
to change home directory run:
# usermod -d /home/user_name user_name
to change group name run:
# groupmod -n old_name new_name

1 comment:

  1. Thank you crzyOrc
    very useful.

    ReplyDelete