Command format:
useradd [option] User name (option not writable)
Command function:
Create a new user
Common options:
- u Specifies the user ID, but requires that the UID is not used by another user when specified
- d Specify user account host Directory
- e Specify user account expiration time, date format: YYYY-MM-DD
- g Specifies the user's base group (you can use the GID number to represent the group name)
- g Additional groups for the specified user (you can use the GID number to represent the group name)
- M does not establish a user host directory
- s login shell for the specified user
Common examples:
Example one: Creating a user Zhangsan
Command: useradd Zhangsan
Note: If you do not add an option, by default, a host directory named after a user name is created in the directory, and a user's initial configuration file is created in that directory, a basic group named after the user name and joined to the group, the system will be/etc/passwd and/etc/ Shadow add the user account record at the end of the two files and log in to the shell for/bin/bash
Example two: Create an account named Lisi, and specify a base group of wheel, the host directory is/lisi
Command: useradd-d /lisi-g wheel Lisi
Note: When specifying a group, the group must exist in the system
Example three: Create a user named Wangwu, request to disable login system, do not create the host directory, and the account expires on December 31, 2016
Command: useradd-m-S /sbin/nologin- e 2016-12-31 Wangwu
This article is from the "Shiyu" blog, make sure to keep this source http://928004321.blog.51cto.com/10707688/1731421
Linux command--useradd