In-depth understanding of Linux user rights management: detailed explanation of common commands

In Linux systems, user rights management is an important part of system security. With appropriate permission settings, the system can be effectively protected from unauthorized access and operations. This article will introduce some commonly used Linux user rights management commands to help you better understand and use these commands.

1. User and group management commands

1.1 useradd - Addition holder
sudo useradd username

New users can be added via the useradd command. By default, this command only creates the user without setting a password for it.

1.2 passwd - Set user password
sudo passwd username

Use the passwd command to set a password for the specified user to ensure the complexity of the password to improve system security.

1.3 usermod - Repair attribute
sudo usermod -aG groupname username

You can modify the attributes of existing users through theusermod command, such as adding the user to a user group.

1.4 groupadd - Addition system
sudo groupadd groupname

New user groups can be created via the groupadd command.

1.5 id - View user information
id username

idThe command is used to display the basic information of the specified user, including user ID (UID) and user group (GID) to which it belongs.

2. File and directory permission management commands

2.1 chmod - Modified text condition limit
chmod permissions filename

chmodThe command is used to change the permissions of a file or directory. Permissions can be specified by numbers or symbols, such as chmod 755 filename.

2.2 chown - Modified text owner
chown newowner:newgroup filename

You can change the owner and group of a file or directory through thechown command.

2.3 chgrp - Revised text affiliation group
chgrp newgroup filename

chgrpThe command is used to modify the group to which a file or directory belongs.

3. View permission information command

3.1 ls - List files and directories
ls -l

lsThe command's-l option displays detailed file and directory information, including permissions, owners, groups, etc.

3.2 stat - Show file details
stat filename

statThe command is used to display detailed information about a file, including permissions, owner, size, etc.

4. sudo command

4.1 sudo - Execute commands with superuser privileges
sudo command

sudoCommands allow ordinary users to execute specific commands as superusers to improve system security.

5.

5.1 su - Switch for switching
su username

suThe command is used to switch users, which can be to switch to the super user or other ordinary users.

By mastering these common commands for Linux user rights management, you can manage users and rights more flexibly to ensure system security and stability. Please use caution when using these commands to avoid unnecessary problems.

Guess you like

Origin blog.csdn.net/u011095039/article/details/134810400