1. Overview of file permissions and ownership 1. Access Rights
2. Ownership
3. View file permissions and ownership 4. chmod sets file permissions The basic syntax format of the chmod command is as follows: Application examples: [root@centos01 ~]# touch 1.txt <!--Create 1.txt file--> [root@centos01 ~]# ll Total dosage 8 -rw-r--r-- 1 root root 0 January 11 22:27 1.txt -rw------. 1 root root 1572 Oct 23 22:37 anaconda-ks.cfg -rw-r--r--. 1 root root 1603 10月23 23:36 initial-setup-ks.cfg [root@centos01 ~]# chmod u+x ./1.txt <!--Add execution permission to the owner--> [root@centos01 ~]# ll Total dosage 8 -rwxr--r-- 1 root root 0 January 11 22:27 1.txt -rw------. 1 root root 1572 Oct 23 22:37 anaconda-ks.cfg -rw-r--r--. 1 root root 1603 10月23 23:36 initial-setup-ks.cfg [root@centos01 ~]# chmod ux,g+x,o+w 1.txt <!--The owner user cancels the execute permission, the group adds the execute permission, and other users add the write permission--> [root@centos01 ~]# ll Total dosage 8 -rw-r-xrw- 1 root root 0 January 11 22:27 1.txt -rw------. 1 root root 1572 Oct 23 22:37 anaconda-ks.cfg -rw-r--r--. 1 root root 1603 10月23 23:36 initial-setup-ks.cfg [root@centos01 ~]# chmod 755 1.txt <!--Add 755 permissions (rwxr-xr-x) --> [root@centos01 ~]# ll Total dosage 8 -rwxr-xr-x 1 root root 0 January 17 02:36 1.txt -rw------. 1 root root 1572 Oct 23 22:37 anaconda-ks.cfg -rw-r--r--. 1 root root 1603 10月23 23:36 initial-setup-ks.cfg 5. chown setting file ownership The basic syntax format of the chown command is as follows: Application examples: [root@centos01 ~]# chown bob 1.txt <!--1.txt sets the owner--> [root@centos01 ~]# ll Total dosage 8 -rwxr-xr-x 1 bob root 0 January 17 02:36 1.txt -rw------. 1 root root 1572 Oct 23 22:37 anaconda-ks.cfg -rw-r--r--. 1 root root 1603 10月23 23:36 initial-setup-ks.cfg [root@centos01 ~]# chown :benet 1.txt <!--1.txt sets the group --> [root@centos01 ~]# ll Total dosage 8 -rwxr-xr-x 1 bob benet 0 Jan 17 02:36 1.txt -rw------. 1 root root 1572 Oct 23 22:37 anaconda-ks.cfg -rw-r--r--. 1 root root 1603 10月23 23:36 initial-setup-ks.cfg [root@centos01 ~]# chown bob:benet 1.txt <!--1.txt sets the owner and group --> [root@centos01 ~]# ll Total dosage 8 -rwxr-xr-x 1 bob benet 0 Jan 17 02:36 1.txt -rw------. 1 root root 1572 Oct 23 22:37 anaconda-ks.cfg -rw-r--r--. 1 root root 1603 10月23 23:36 initial-setup-ks.cfg <!----> 2. Directory permissions and ownership 1. Access Rights 2. Ownership Owner: the user account that owns the directory; Group: The group account that owns the directory; 3. chmod sets directory permissions The basic format of the chmod command to set directory permissions is as follows: Application examples: [root@centos01 ~]# chmod -R 755 benet/ <!--Loop setting the file or directory permissions under the benet directory to 755--> [root@centos01 ~]# ll Total dosage 8 -rw-r-xrw- 1 root root 0 January 11 22:27 1.txt -rw------. 1 root root 1572 Oct 23 22:37 anaconda-ks.cfg drwxr-xr-x 3 root root 18 January 11 22:39 benet -rw-r--r--. 1 root root 1603 10月23 23:36 initial-setup-ks.cfg 4. chown sets the ownership of the directory The basic format of the chown command to set directory ownership is as follows: Application examples: [root@centos01 ~]# chown -R bob:benet benet/ <!--Loop setting the user in the benet directory to bob and the group to benet--> [root@centos01 ~]# ll Total dosage 8 -rw-r-xrw- 1 root root 0 January 11 22:27 1.txt -rw------. 1 root root 1572 Oct 23 22:37 anaconda-ks.cfg drwxr-xr-x 3 bob benet 18 January 11 22:39 benet -rw-r--r--. 1 root root 1603 10月23 23:36 initial-setup-ks.cfg 3. Permission mask umask 1. The role of umask Controls the permissions of newly created files or directories. The default permissions minus the umask permissions are the permissions of newly created files or directories. 2. Set umask umask 022 3. Check umask umask 4. Application examples: [root@centos01 ~]# umask <!--View umask--> 0022 [root@centos01 ~]# umask 000 <!--Set umask to 000--> [root@centos01 ~]# umask <!--Verify whether the setting is successful--> 0000 [root@centos01 ~]# touch 2.txt <!--Create a new file--> [root@centos01 ~]# ll Total dosage 8 -rwxr-xr-x 1 bob benet 0 Jan 17 03:48 1.txt -rw-rw-rw- 1 root root 0 January 17 03:48 2.txt <!-- View permissions --> -rw------. 1 root root 1572 Oct 23 22:37 anaconda-ks.cfg -rw-r--r--. 1 root root 1603 10月23 23:36 initial-setup-ks.cfg [root@centos01 ~]# umask 022 <!--Set umask to 022--> [root@centos01 ~]# umask <!--View umask--> 0022 [root@centos01 ~]# touch 3.txt <!--Create a new file again--> [root@centos01 ~]# ll Total dosage 8 -rwxr-xr-x 1 bob benet 0 Jan 17 03:48 1.txt -rw-rw-rw- 1 root root 0 January 17 03:48 2.txt -rw-r--r-- 1 root root 0 January 17 03:49 3.txt <!-- Check the permissions, obviously different --> -rw------. 1 root root 1572 Oct 23 22:37 anaconda-ks.cfg -rw-r--r--. 1 root root 1603 10月23 23:36 initial-setup-ks.cfg The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Detailed explanation of how components communicate in React
>>: MySQL download and installation details graphic tutorial
mysql batch delete large amounts of data Assume t...
This article example shares the specific code of ...
<br />"There are no ugly women in the w...
The CentOS Project, a 100% compatible rebuild of ...
<br />Previous Web Design Tutorial: Web Desi...
The EXPLAIN statement is introduced in MySQL quer...
Related reading: Solve the problem that the servi...
Install crontab yum install crontabs CentOS 7 com...
Description of the phenomenon: The project uses s...
Nginx's rewrite function supports regular mat...
You may remember that in the past articles we hav...
<html> <head> <meta http-equiv=&quo...
This article uses an example to describe the MySQ...
I have always been interested in wireless interac...
The login interface of WeChat applet is implement...