In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the usage of the Linux basic command useradd". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the usage of the Linux basic command useradd".
Useradd
To create a new system user, the useradd directive can only be run as an administrator, and the created users are in the "/ etc/passwd" file. When the-D parameter is not added, the useradd instruction uses the command line to specify the settings for the new account and uses the default values on the system. The new user account will generate some system files, user directory creation, copy starting files, etc., all of which can be specified by command line options. This version is available for RedHat Linux and allows each new user to create a separate group without adding the-n option.
The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.
1. Grammar
Useradd [- D] [options] [parameters]
Useradd [- c comment] [- d home_dir] [- e expire_date] [- f inactive_time] [- g initial_group] [- G group [,...]] [- m [- k skeleton_dir] |-M] [- s shell] [- u uid [- o]] [- n] [- r] login
Useradd-D [- g default_group] [- b default_home] [- f default_inactive] [- e default_expire_date] [- s default_shell]
2. List of options
Option
Description
-- help
Show help documentation
-- version
Show command version
Use the-D option
-b dir
Specify the user's base directory. The default is home.
-e date
Date of validity of user account
-f days
Specify how many days to close the account after the password expires
-g group
Specifies the group of the account, which must exist
-s shell
Specify the shell used by the account
Do not use the-D option
-c comment
Remarks information
-d home
The directory used for each login of the account
-e date
Account termination date, MM/DD/YY
-f days
How long after the account expires?
-g group
Specifies the group of the account, which must exist
-G group
Specify the additional group for the user
-m
If the consumer directory does not exist, it is automatically created
-n
Cancel the group automatically created on the account with the same name
-p password
Set the password for the account
-r
Create a system account
S
Specify the shell used after the account is logged in
-u uid
Specify user ID
3. Files
/ etc/passwd, user account information.
/ etc/shadow, the user account information is encrypted.
/ etc/group, group information.
/ etc/default/useradd, define the information.
/ etc/login.defs, the system generalized setting.
/ etc/skel, which contains the directory of the definition file.
4. Examples
1) create a user
[root@localhost david] # useradd-p 123456 user01 / / create user, password 123456
[root@localhost david] # tail-n 2 / etc/passwd / / check whether it is created successfully
Webalizer:x:67:67:Webalizer:/var/www/usage:/sbin/nologin
User01:x:503:503::/home/user01:/bin/bash
[root@localhost david] # ls / home/ create a home directory under home
David test01 user01 weijie
2) set the user's home directory, uid, and comments
[root@localhost david] # useradd-d / home/other-u 600-c "test user" user02 / / create a user
[root@localhost david] # tail-n 2 / etc/passwd / / View user information
User01:x:503:503::/home/user01:/bin/bash
User02:x:600:600:test user:/home/other:/bin/bash
[root@localhost david] # ls / home/ Home directory other
David other test01 user01 weijie
Thank you for your reading, the above is the content of "the usage of the Linux basic command useradd". After the study of this article, I believe you have a deeper understanding of the usage of the Linux basic command useradd, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.