Hello everyone, I am Cola, a dedicated original, willing to share the program ape. This series of tutorials will continue to be updated, you can search “IT Cola” on wechat to read the first time. Ebooks has a huge selection of free books that I’ve selected for you

In the last blog, we introduced ACL permissions for permission management. By setting ACL permissions, we can assign specific permissions for a file to a user. In this blog we will introduce two of the most popular commands for permission management: chattr and sudo.

1. Set the file system attribute to chattr

Chattr [+-=][option] Name of a file or directory

+ : Adds permission

– : Deletes the permission

= : Indicates a permission

options Note: After chattr restricts permissions, the root user cannot be exempted. This command protects the file from misoperation.

2. View the system property of the file: lsattr

Lsattr Indicates the name of the option file

-a Displays all files and directories

②, -d list only the attributes of the directory, not the subfiles

3, Sudo permission

Sudo can only operate on system commands.

2. Assign the commands originally executed by the superuser to ordinary users.

Simply speaking, for example, many commands can only be executed by the super user, such as restart, shutdown and so on. Sometimes the super user cannot be used, so what should we do?

Step 1: Configure the power user to give ordinary users permission to execute these commands

Step 2: Add sudo to execute these commands.

We can use vim /etc/sudoers command or visudo command 2. Authorized users can restart the server

User name ALL=/sbin/shutdown -h now

The sudo command is available

sudo -l

4. Ordinary users execute commands assigned by sudo

4, summarize

The chattr command can set the system properties of files and restrict superusers. This command can better protect files and directories from being destroyed. Another command, sudo, is that the super administrator grants ordinary users the right to execute system commands, and then executes them through sudo. Sometimes we do not have the permission of super users, and then we want to use some system commands, so sudo can help us.

This series of tutorials will continue to be updated, you can search “IT Cola” on wechat to read the first time. Reply ebook has a selection of books that I have selected for you