Home  >  Article  >  Operation and Maintenance  >  Detailed explanation of useradd command

Detailed explanation of useradd command

angryTom
angryTomOriginal
2020-02-26 17:49:2312538browse

Detailed explanation of useradd command

Detailed explanation of useradd command

1. Function

The useradd command is used to establish a user account and create the user's starting directory , the usage permission is root user.

Recommended: Linux video tutorial

2. Format

useradd [-d home] [-s shell] [-c comment] [-m [-k template]] [-f inactive] [-e expire ] [-p passwd] [-r] name

3. Main parameters

-c: add The remark text is saved in the remark column of passwd.

-d: Specify the starting directory when the user logs in.

-D: Change the default value.

-e: Specify the validity period of the account. The default means it is permanently valid.

-f: Specify the number of days after the password expires to close the account.

-g: Specify the starting group to which the user belongs.

-G: Specify additional groups to which the user belongs.

-m: Automatically create the user's login directory.

-M: Do not automatically create the user's login directory.

-n: Cancel the creation of a group named by the user name.

-r: Create a system account.

-s: Specify the shell used by the user after logging in.

-u: Specify the user ID number.

4. Description

useradd can be used to create a user account. It is the same as the adduser command. After the account is created, use passwd to set the password for the account. The account created using the useradd command is actually saved in the /etc/passwd text file.

5. Application example

Create a new user account and set the ID:

#useradd david -u 544

It should be noted that when setting the ID value, try to be greater than 500 to avoid conflicts . Because some special users will be created after Linux is installed, values ​​between 0 and 499 are generally reserved for system accounts such as bin and mail.

#useradd oracle -g oinstall -G dba

Create a new oracle user, which initially belongs to the oinstall group, and also makes him belong to the dba group.

#useradd tomcat  -d /var/servlet/service -s /sbin/nologin

Cannot use shell, and its user directory is to /var/servlet/service

PHP Chinese website, a large number of programming learning courses are welcome to learn.

The above is the detailed content of Detailed explanation of useradd command. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn