How to add a new system user in Linux

Source: Internet
Author: User
A simple user in Linux is not a simple useradd command. In fact, if you carefully check the Man document of useradd, you will find that [Syntax] adduser [required parameters] [Select

A simple Linux user is not a simple useradd command. In fact, if you carefully check the Man document of useradd, you will find more.

[Syntax] adduser [required parameters] [selective parameters] user name

[Function description] the adduser command adds users to the system based on the command line parameters. its configuration information is stored in/etc/adduser. in the conf file, if the "-- system" or "-- group" parameter is not specified during the call, the adduser command will add a general user by default, to add a system user, use the "-- symtem" parameter. to add a user group, use the "-- group" parameter.

[Parameter description]

The required parameters are described as follows:

Parameter functions

-R | -- system creates a system user

-- No-creat-home does not create the user's/home directory, even if it does not exist

-Q | -- quiet only displays warning information and error information, not general information

-- Debug for debugging

The optional parameters are described as follows:

Parameter functions

-D | -- home <目录> Specify the directory as the user's home directory

-S | -- shell |-s uses the specified SHELL as the user's shell for logon.

-U | -- uid <用户id> Use the specified user ID as the user ID instead of the default user ID.

-- Firstuid <用户id> The specified first user ID does not need to be crossed.

-- Lastid <用户id> You do not need to cross the specified last user ID

-Group <用户组> When a user is created, the user is assigned to the specified user group.

-- Disabled-password: The password is not set. you can log on

-- Disable-login does not set a password, but the user cannot log on until the password has been set

-- Ingroup <用户组> Add a user to a specified user group instead of creating a user group.

-- Add_extra_groups: adds the user to the additional user group specified by addr. conf.

-- Help |-h help information

-- Version

-- Conf <文件> Replace/etc/. adduser. conf with the specified file

-P | -- password <密码> Unadded user-specified encrypted password

[Parameter usage instructions]

-R | -- system: indicates "-r" or "-- system ".

-- Home <目录> : Add a directory after the "-- home" parameter, not <目录> The two words with angle brackets are actually directory paths.

[Execution example]

[Example 1] add a common user.

Root @ localhost :~ # Useradd kk // add user kk

[Example 2] specify a user group for the added user.

Root @ localhost :~ # Useradd-g root kk // add user kk and specify the user group as the root user group

[Example 3] create a system user.

Root @ localhost :~ # Useradd-r kk // create a system user kk

Example 4: specify the home directory for the newly added user.

Root @ localhost :~ # Useradd-d/home/myf kk // add user kk, whose home directory is/home/myf

When you log on to the host with the user name kk, the default system directory is/home/myf.

[Related commands]

Deluser, groupadd, usermod
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.