usermod - modify a user account
usermod [options] LOGIN
Options you will use
-aG GROUPS- APPEND to the supplementary groups. This is almost always what you want.
-G GROUPS- Without -a: REPLACE the supplementary groups with exactly this list.
usermod -G docker learnerremoves learner from sudo. -g GROUP- change the primary group
-s SHELL- change the login shell
-L / -U- lock / unlock the password (prefixes ! in /etc/shadow)
-e, --expiredate EXPIRE_DATE- The date the account is disabled (YYYY-MM-DD); -e 1 disables it now.
Examples
$ sudo usermod -aG ops appuseradd to ops, keep everything else
Gotchas
- Group changes apply to NEW logins. A shell that is already running keeps the groups it started with: log out and in, or
newgrp GROUP.
Taught in
Try usermod in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.