User management in Linux

Source: Internet
Author: User
1. add a new user account 1. use useradd to add a user account # useraddTOM1 # useradd-d/home/guest # useradd-s/sbin/nologtailm22, running useradd is equivalent to doing something (1) editing p in the/etc/directory...

1. add a new user account
1. use useradd to add a user account
# Useradd TOM1
 
# Useradd-d/home/guest
# Useradd-s/sbin/nologin TOM2
 
2. running useradd is equivalent to doing something

(1) edit the passwd, shadow, group, and gshadow files in the/etc/directory.
(2) create and locate the user's home directory
(3) set the permissions of the home directory and the owner and owner group of the file
**************************************** *****************************
 
2. user's private group
1. when a user account is created, a group with the same name as the user account is also created. in linux, there are two groups, private group and additional group.
2. differences between a private group and an additional group:
When a file is created, the owner group of the file is the private group corresponding to the user.
**************************************** *****************************
3. modify and delete user accounts
1. you can modify the user information in either of the following ways:
(1) directly edit the/etc/passwd file
(2) use the usermod command:

# Usermod-c "test user" redhat1 // modify the description bit

# Usermod-d/home/guests/redhat2 redhat1 // modify the home directory
# Usermod-g redhat2 redhat1 // modify the private group of redhat1
# Usermod-G redhat1 redhat1 // when redhat1 does not have an additional group, add redhat1 as the additional group. If yes, change it to redhat1.
# Usermod-a-G redhat3 redhat1 // a indicates appending. add redhat1 to redhat3 without changing the previous group.
# Usermod-s/sbin/nologin redhat1 // change the user's logon shell to/sbin/nologin
2. if you want to delete a user, you can manually delete the file.
/Etc/passwd,/etc/shadow,/etc/group,/etc/gshadow and/var/spool/mail
3. you can also use userdel-r redhat1 // to delete it together with the home directory.
**************************************** **************************************** **
IV. Password aging policy
1. by default, passwords in linux do not expire.
2. the force password process is a security enhancement policy.
3. modify the settings of the default policy to edit the/etc/login. defs file.
========================================================== ========================================================== =
[Root @ localhost etc] # cat/etc/login. defs | grep ^ [^ #] | nl
----------------------------------------------------------------------------------
1 MAIL_DIR/var/spool/mail
// Defines the location of your email in the system
2 PASS_MAX_DAYS 99999
// Defines the maximum password expiration time of 99999.
3 PASS_MIN_DAYS 0
// Defines the minimum password expiration time
4 PASS_MIN_LEN 5
// Defines the minimum password length
5 PASS_WARN_AGE 7
// The password expiration warning days are 7 days
6 UID_MIN 500
// When creating a user, the default minimum UID starts from 500.
7 UID_MAX 60000
// Defines that the default maximum UID is 60000 when a user is created.
8 GID_MIN 500
// Defines that when a group is created, the minimum GID starts from 500.
9 GID_MAX 60000
// Defines the maximum GID for creating a group as 60000
10 CREATE_HOME yes
// Define whether to create a user together with the user's home directory
11 UMASK 077
// Define the user's UMASK value as 077
12 USERGROUPS_ENAB yes
// Define the group to which a user is deleted if there are no other users in the user group
13 MD5_CRYPT_ENAB yes
// Define whether the password is encrypted in MD5 mode
========================================================== ========================================================== =

4. you can use the chage command to modify the password policy.
 
# Chage-l test2 // view the password policy of the test2 user
 
Password inactive: indicates the Password grace period.
# Chage test2 // modify the password policy of the test2 user
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&
 
What is the difference between Account expiration and password expiration:
Password Expiration does not mean the account has expired. the password system will prompt you to change the new password. you can continue to use the new password.
The account has expired and cannot be used directly.

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.