Changing User Attributes
The usermod command is used to change attributes of an existing user account.
Changing the Primary Group (-g)
This changes the user's primary group ID.
bash $ sudo usermod -g developers alice
Adding to Secondary Groups (-aG)
To add a user to secondary groups without removing them from their existing ones, you must use the -a (append) and -G (Groups) options together.
bash
Add user 'bob' to 'sysadmin' and 'web_ops' groups:
$ sudo usermod -aG sysadmin,web_ops bob
Changing the Username (-l)
This changes the login name of the user.
bash
Change jdoe's username to johnnyd
$ sudo usermod -l johnnyd jdoe
Note: Changing the username does not automatically rename the home directory. Use -d and -m to move and rename the home directory separately if needed.