Add / delete file permissions under Linux (ubuntu)
[permission section]
In the ubuntu system, different users and different user groups have different permissions to operate files. Through the console, we can quickly operate the permissions of files.
There are two ways to change permissions for modifying permissions. Let's take a look at the composition of file system permissions:
File permissions View:
1. View file permissions command: ls-lh [option: file name]
2. View folder permissions command ls-ld [option: folder name]
Example:-rw-r--r--
Explanation:-(for type) × × (owner) × × (group of users) × × (other users)
Option 1:
Let's use the chmod command to modify the permissions of the file
Sudo chmod 644 × × (only the file owner has read and write permissions) sudo chmod 644 × × (file owners have read and write permissions, group users only have read permissions) sudo chmod 700 × × (only file owners have read and write and execute permissions) sudo chmod 666 × × (all users have read and write permissions) sudo chmod 777 × × (all users have read and write rights and execute permissions)
Explanation:
1. Where × ×: refers to the file name (when modifying folder permissions, some need to add-ld after chmod)
2. The three digits correspond to the permission settings of each user type, with a value of 00007, that is, binary [000] ~ [111].
3. Other permissions [000] do not have any permissions [100] read-only permissions [110] read-write permissions [111] read-write execution permissions
Option 2:
Also use the chmod command to modify permissions, as follows:
Command format:
Sudo chmod [Operand + permission increase or decrease + operation authority] × ×
Example:
Sudo chmod uperw × × × # add the "writeable" permission of the file owner sudo chmod Ulyw × × × # remove the "writeable" permission of the file owner sudo chmod grubr × × × # add the "readable" permission of the user group sudo chmod Olam × × × # remove the "writeable" permission of other users sudo chmod + x × × × # add the "executable" permission of all users
Explanation:
Operation object: U for file owner, g for group users, o for other users, a for all users
Permission increase or decrease: + means to increase permissions,-means to cancel permissions, and = means to set unique permissions
Operation permissions: r for readable, w for writable, x for executable
The above Linux (ubuntu) to add / delete file permissions is the editor to share with you all the content, I hope to give you a reference, but also hope that you support more.