To add new users you can use the adduser command. With no options, adduser steps you through the information you need to enter to add a user account. Here’s an example of using adduser to add a user interactively:
# adduser ### Start an interactive session to add a user Username: geek Full name: geek labuser Uid (Leave empty for default): Login group [geek]: Login group is geek. Invite geek into other groups? []: Login class [default]: Shell (sh csh tcsh bash ksh nologin) [sh]: bash Home directory [/home/geek]: Use password-based authentication? [yes]: Use an empty password? (yes/no) [no]: Use a random password? (yes/no) [no]: Enter password: ********* Enter password again: ********* Lock out the account after creation? [no]:
The user name must be from one to 16 characters. Most people use lowercase letters and digits, with the first character being a letter. Default user IDs (Uid) start at 1001. The default group is a new group with the same name as the user name.
Login class is something that not all UNIX-like systems have. The default class is best for regular users (more on login classes a bit later). Password-based authentication (yes) is the normal authentication. Select a good password (more on passwords later as well).
adduser Command Examples in Linux
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
The adduser command has many command-line options. The command can be used to set policies and dates for the new user’s password, assign a login shell, assign group membership, and other aspects of a user’s account. See man page for adduser command for more info.