Home > Article > Operation and Maintenance > How to configure file and directory access permissions in Unix/Linux?
Unix and Linux operating systems assign one of three access types (read, write, and execute) to each of three groups (owner, group, and other users) to set access to files and directories. access permission. The following article will show you how to configure file and directory access permissions in Unix/Linux. I hope it will be helpful to you.
How to check file and directory access permissions?
We can use the ls command with the -l option to list the details of the file attributes, for example
ls -l filename
The above command will return something like -rwe-rw -r information indicates that the permissions of the file are: read, write and execute permissions for the owner, read and write permissions for the group, and read-only permissions for all other users.
Each type of access has an associated value listed below:
Read = 4
Write = 2
Execute = 1
How to configure file and directory access permissions?
You can use the chmod command to assign access permissions to files and directories.
When we add the access permission values of each group above together, we will get a value between 0 and 7, which can be used to assign or modify permissions using the chmod (change mode) command.
You can specify the access permissions of related files by entering the following command, for example: the information similar to -rwe-rw-r returned in the above example
chmod 764 filename
The number 764 comes from:
rwe = 4(r) 2(w) 1(e) = 7
rw = 4(r) 2(w) = 6
r = 4(r) = 4
Note: UNIX/Linux command and object names are case-sensitive, "chmod" must be used instead of CHMod or any other combination of upper and lower case letters.
Example using chmod command:
Everyone has access, need to run the following command:
chmod 777 filename
Set full for owner and group permissions Access permissions, but other users are set to read and execute only:
chmod 775 filename
Full access to the owner, but restrict group and other user permissions to read and execute only files in the directory:
chmod 755 dirname
Full access to the owner, no access or permissions to anyone else:
chmod 700 filename
No access to groups or other users in the directory and the owner restricts read and execute permissions to Prevent accidental deletion or modification of files in a directory:
chmod 500 dirname
Allow the owner and group read and write access to the file, allow others in the group to edit or delete the file and the owner, but not access to other users:
chmod 660 filename
Recommended video tutorials: "Linux Tutorial"
The above is the entire content of this article, I hope it will be helpful to everyone's learning. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !
The above is the detailed content of How to configure file and directory access permissions in Unix/Linux?. For more information, please follow other related articles on the PHP Chinese website!