In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article summarizes common commands for linux user and group management. Share with you for your reference, the details are as follows:
1. The user belongs to the user group.
2. User and user group profile
1) user Group Profil
/ etc/group
First column: group name of the user group
Second column: group password (the real password is stored in gshadow)
The third column: user group ID, unique identity of user group
The superuser group with group ID of 0
Group ID is 1-499 is the system user group
Group ID greater than 500is a user-defined group
Fourth column: group members
2) user group password profile
/ etc/gshadow
First column: user group name
Second column: password
The third column: group administrator
Fourth column: group members
3) user profile
/ etc/passwd
First column: user name
Second column: user password, with only one x placeholder, password stored in shadow
The third column: user ID, unique ID
The user whose ID is 0 is the superuser.
Users whose ID is 1-499 are system users.
A user whose ID is greater than 500is a custom user
Fourth column: group ID of the group to which it belongs
Column 5: remarks
The sixth column: the user's home directory (home). When the user logs in to the system, he or she logs in at home.
The seventh column: shell type
4) user password profile
/ etc/shadow
First column: user name
The second column: password (! Indicates that there is no password and login is not allowed.
3. User group management
Groupadd group name add user group
-g: specify the group ID when adding a group
Groupmod group name modifies user group information
-n: modify the group name
-g: modify the group ID
Groupdel group name delete group
* if there are users under a group, the group cannot be deleted.
4. User management
Useradd [parameter] username add user
-g group name specifies the group to which it belongs
-d directory specifies the user home directory
* when adding a user, if you do not specify a group, the system creates a group with the same name as the user.
Usermod [parameter] user name
-c comment modify remarks information
-l user name modify user name
-d directory modify user home directory
-g group name modify user group
Userdel [parameter] user name
-r Delete user home directory
5. Password management
Passwd [option] user name
-S to view the password status of the user
-l lock the user's password (no login is allowed)
-u unlock the user's password
-d delete user password
6. Forbid account login
There are two situations:
Forbid a certain account to log in
/ etc/shadow
Modify shadow directly and add two before the user's password! The user is not allowed to log in.
It is recommended to use: passwd-l user name this method to prevent users from logging in.
All accounts are prohibited from logging in
/ etc/nologin
Create a nologin file under / etc/, and no user can log in.
7. Add and delete group members
* usermod-g is the primary group of the modified user
Gpasswd [options] group name
-a user name: add group members
-d user name: delete group member
The default identity of a user after logging in is his primary group identity.
You can use newgrp to switch the identity of the group to which it belongs, as long as it also belongs to that group.
The group to which the current user identity is switched is the group to which the created file belongs.
I hope what is described in this article will be helpful to everyone's Linux management.
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.