Linux adduser Command
The Linux adduser command is used to create new user accounts or update default user information.
adduser and useradd are the same command (via a symbolic link).
Permission required: system administrator.
adduser adds a user. Correspondingly, there is also a command to delete a user userdel, with the syntax userdel [login ID].
Syntax
adduser [-c comment] [-d home_dir] [-e expire_date] [-f inactive_time] [-g initial_group] [-G group[,...]] [-m [-k skeleton_dir] | -M] [-p passwd] [-s shell] [-u uid [ -o]] [-n] [-r] loginid
or
adduser -D [-g default_group] [-b default_home] [-f default_inactive] [-e default_expire_date] [-s default_shell]
Parameter Description:
- -c comment: the comment field for the new user in the password file (usually /etc/passwd)
- -d home_dir: set the user's home directory to home_dir; the default is the default home followed by the user account loginid
- -e expire_date: set the account's expiration date (format YYYY-MM-DD); the default is never expiring
- -f inactive_time Example:
Example
Add a regular user
# adduser kk //添加用户kk
Assign an appropriate user group to the added user
# adduser -g root kk //添加用户kk,并指定用户所在的组为root用户组
Create a system user
# adduser -r kk //创建一个系统用户kk
Specify the /home directory for the newly added user
# adduser -d /home/myf kk //新添加用户kk,其home目录为/home/myf
//When user kk logs into the host, the default directory the system enters is /home/myf
Linux Command Reference