Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use the useradd command of linux to create a user

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail about the use of linux's useradd command to create users. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

The useradd command is used to create a new user or change the user's information.

Useradd can be used to set up user accounts. After the account is set up, use passwd to set the password of the account. The account created using the useradd directive is actually saved in the / etc/passwd text file.

Syntax format: useradd [parameter] [user name]

Common parameters:

-D change the default value of the new user-c add remarks-d the home directory used by the new user each time they log in-e user termination date, the format of the date is the permanent suspension of rights of YYYY-MM-DD-f users after a few days of expiration. When the value is 0, the user is immediately suspended, while the value is-1, this function is disabled. The default value is-1, which specifies the user's corresponding user group-G defines this user as a member of multiple different groups-m user directory does not exist, then automatically creates-M does not establish a user home directory, takes precedence over / etc/login.defs file setting-n cancels the establishment of a group with the user name-r establishes the system account-u specifies the user id

Reference example

Add a new user linuxcool:

[root@linuxcool ~] # useradd linuxcool

Do not create a home directory, and do not log in:

[root@linuxcool] # useradd-M-s / sbin/nologin linuxcool

Add a new user linuxcool, specify UID as 888,specify that the home user group is a member of root,cool, and its shell type is / bin/sh:

[root@linuxcool] # useradd-u 888-s / bin/sh-G root,cool linuxcool

Add a new user linuxcool, set the home directory to / tmp/linuxcool, and the user expiration date is 2019-05-01. Suspension of rights for two days after expiration:

[root@linuxcool] # useradd-e "2019-05-01"-f 2-d / tmp/linuxcool linuxcool on the use of linux useradd command to create users to share here, I hope the above content can be helpful to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report