


Summary of centos users, group permissions, adding and deleting users
1. The Linux operating system is a multi-user and multi-tasking operating system, including user accounts and group accounts.
Subdivided user accounts (ordinary user accounts, super user accounts). In addition to user accounts, there are also group accounts. The so-called group account is a user account. There are two types of centos groups, private groups and standard groups. When a new user is created, if the group to which he belongs is not specified, centos will create a private group that is the same as the user. In this private group, only Including the users themselves. Standard groups can accommodate multiple users. If you want to use standard groups, you should specify the group he belongs to when creating a new user. On the other hand, the same user can belong to multiple groups, such as the leader of a certain unit. Group and technical group, lik is the technical director of the unit, so he belongs to the leadership group and technical group. When a user belongs to multiple groups, the group to which he or she belongs after logging in is the primary group, and other groups are additional groups.
2. The account system files in the Linux environment are mainly composed of four files: /etc/passwd, /etc/shadow, /etc/group, and /etc/gshadow
I won’t go into details about the basic meaning, but let’s focus on root. uid is 0, from 1-499 are the system's standard accounts, ordinary users start from uid 500.
3. Use commands to manage accounts
useradd option Username //Add new user
usermod option Username //Modify existing users
userdel -r Username //Deleting a user means deleting the home directory together.
groupadd option group name // Add a new group
groupmod option group name // Modify an existing group
groupdel group name // Delete an existing specific group.
Example
useradd zhh888 //Add a user zh888
groupadd blog //Create a new blog group
useradd -G blog zh //Indicates creating a new user zh and joining the blog additional group.
useradd -d /var/ftp/pub -M ftpadmin //Create a new user ftpadmin, specify the directory is /var/ftp/pub, do not create your own directory (-M)
usermod -G blog zh888 //Indicates that zh888 Add it to the additional group blog.
userdel ftpadmin //Delete the ftpadmin user
userdel -r zhh888 //Delete zh888 and delete the directory in /home together.
groupdel blog //Indicates deleting the blog group.
4. Password management and expiry
After creating a user, you need to add a password to the user. The command passwd of the set password
passwd option user name
passwd -l username account name // prohibit user account password
passwd -S username //Indicates to check the user account password status
passwd -u username //Indicates to restore the user account
passwd -d username //Indicates to delete the user account password
5.chage command is to protect the password expiration date, which can prevent others from guessing the password The time
chage option user name
parameters are -m days, -M days,-d days, -I days,-E date, -W days,-l
Example: #chage -m 2 -M 30 -W zhh //It means that the user cannot change the password within two days, and the maximum password survival period is 30 days, and the password is notified within 5 days of expiration
6. User and group status query command
whoami //Used to display the current user name.
groups username//Indicates that the groups to which the specified user belongs are displayed. If no user is specified, it is the group to which the current user belongs.
id //Indicates displaying the uid gid of the current user and the list of groups to which the user belongs.
su - User // means switching to other users, if su means switching to your current user.
newgrp group name //Indicates converting the user's current group to the specified additional group. The user must belong to this group to proceed.
7. Change the owner and group members
Sometimes you need to change the owner of the file and the group it belongs to. Only the owner of the file has the right to change other owners and groups. Users can transfer their own files to everyone. To change the file owner, use the chown command
chown [-R]
chown zh888 files//Change the owner of the file files to the zh888 user.
chown zh888.zh888 files//Change the owner and group of files to zh888.
chown -R zh888.zh888 files//Change the owner and group of all files or directories in all directories and subdirectories of files to zh888.
8. Set the directory and directory generation mask of the file
Users can use the umask command Sets the default build mask for files. The default build mask tells the system what permissions should not be given to create a file or directory. If the user places the umask command in the environment file .bash_profile, he can control the access permissions of all newly created files and directories.
umask [a1a2a3]
a1 represents the permission that does not allow the owner, a2 represents the permission that does not allow people in the same group, and a3 represents the permission that does not allow other people.
umask 022//Indicates that the setting does not allow users in the same group and other users to have write permissions.
umask //Shows the current default build mask.
9. Setting of special permissions
SUID SGID and sticky-bit
In addition to general permissions, there are also special permissions. Some special permissions have special permissions. If the user does not need special permissions, generally do not open special permissions to avoid security issues. . For specific usage, you can search on Baidu and Google.
I hope the knowledge I compiled can help netizens better understand issues such as centos user & group permissions & adding and deleting users.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

DeepSeek is a powerful intelligent search and analysis tool that provides two access methods: web version and official website. The web version is convenient and efficient, and can be used without installation; the official website provides comprehensive product information, download resources and support services. Whether individuals or corporate users, they can easily obtain and analyze massive data through DeepSeek to improve work efficiency, assist decision-making and promote innovation.

There are many ways to install DeepSeek, including: compile from source (for experienced developers) using precompiled packages (for Windows users) using Docker containers (for most convenient, no need to worry about compatibility) No matter which method you choose, Please read the official documents carefully and prepare them fully to avoid unnecessary trouble.

Ouyi OKX, the world's leading digital asset exchange, has now launched an official installation package to provide a safe and convenient trading experience. The OKX installation package of Ouyi does not need to be accessed through a browser. It can directly install independent applications on the device, creating a stable and efficient trading platform for users. The installation process is simple and easy to understand. Users only need to download the latest version of the installation package and follow the prompts to complete the installation step by step.

BITGet is a cryptocurrency exchange that provides a variety of trading services including spot trading, contract trading and derivatives. Founded in 2018, the exchange is headquartered in Singapore and is committed to providing users with a safe and reliable trading platform. BITGet offers a variety of trading pairs, including BTC/USDT, ETH/USDT and XRP/USDT. Additionally, the exchange has a reputation for security and liquidity and offers a variety of features such as premium order types, leveraged trading and 24/7 customer support.

Gate.io is a popular cryptocurrency exchange that users can use by downloading its installation package and installing it on their devices. The steps to obtain the installation package are as follows: Visit the official website of Gate.io, click "Download", select the corresponding operating system (Windows, Mac or Linux), and download the installation package to your computer. It is recommended to temporarily disable antivirus software or firewall during installation to ensure smooth installation. After completion, the user needs to create a Gate.io account to start using it.

Ouyi, also known as OKX, is a world-leading cryptocurrency trading platform. The article provides a download portal for Ouyi's official installation package, which facilitates users to install Ouyi client on different devices. This installation package supports Windows, Mac, Android and iOS systems. Users can choose the corresponding version to download according to their device type. After the installation is completed, users can register or log in to the Ouyi account, start trading cryptocurrencies and enjoy other services provided by the platform.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...
