- To create/add new users into the system, Linux has a useradd command.
- useradd provides many options for creating users, we can create local, system or superusers using it.
- It comes from “shadow-utils-4.1.4.2” package, we have covered almost all the options here.
Examples:
1. To add a new user
$ adduser mike |
2. To add new user with default directory
$ adduser -d /mike mike |
3. To add new user with some comment
$ adduser -c “Admin Group” mike |
4. To add new user with expiry date
$ adduser -e 12/12/2015 mike |
5. To add new user with primary group
$ adduser -g support mike |
6. To add user with supplementary group
$ adduser -G admin mike |
7. To add user without home directoy
$ adduser -M mike |
8. Add user without creating default group with same name
$ adduser -N mike |
9. To add user with given password
$ adduser -p “12asd124123Ads43” mike |
10. To create a system account
$ adduser -r mike |
11. To add user with default login shell
$ adduser -s /bin/bash mike |
12. To add user with creating group of same name
$ adduser -U mike |
Related Commands: chfn, chsh, passwd, crypt, groupadd, groupdel, groupmod, login.defs, newusers, userdel, usermod.
One thought on “how to use adduser command with its examples”
Thanks for sharing multiple options for creating user,
Here are few more :
The user will be created with the UID specified with -u option as:
# useradd -u 3210 bill
# grep bill /etc/passwd
bill:x:3210:3210::/home/bill:/bin/bash
Also learn :
Disabling the account with -e option on a certain date.
# useradd -e 2013-06-23 bill
https://linoxide.com/linux-command/linux-user-add-command/