Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Linux manages the permissions of files and directories with commands

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

How does Linux manage the permissions of files and directories with commands? In view of this problem, today the editor summarizes this article on the permissions of linux files and directories, which can be used as a reference for interested friends. I hope it will be helpful to you.

An overview of the permissions and attribution of files 1. Access rights

Read r: allows you to view file contents and display directory lists

Write w: allows file contents to be modified, new files or subdirectories to be created, moved, or deleted in the directory

Executable x: allow to run programs, change directories 2, ownership (ownership)

Owner: the user account that owns the file or directory

Group: the group account that owns the file or directory; 3. The permission and ownership of viewing the file.

4. Chmod sets file permissions

The basic syntax format of the chmod command is as follows:

Application examples:

[root@centos01 ~] # touch 1.txt [root@centos01 ~] # ll total usage 8 root root 1 January 11 22:27 1.txtMuy RWL. 1 root root 1572 October 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 October 23 23:36 initial-setup-ks.cfg [root@centos01] # chmod upright x. / 1.txt [root@centos01] # ll total dosage 8 Kui root root 1 root root 0 January 11 22:27 1.txt Mustang RWMY. 1 root root 1572 October 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 October 23 23:36 initial-setup-ks.cfg [root@centos01 ~] # chmod Umurx journal gongqijie 1.txt [root@centos01] # ll total usage 8korwashi root root XRW-1 root root January 11 22:27 1.txtMuywashi. 1 root root 1572 October 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 October 23 23:36 initial-setup-ks.cfg [root@centos01] # chmod 755 1.txt [root@centos01] # ll total dosage 8-rwxr-xr-x 1 root root January 17 02:36 1.txtMurray. 1 root root 1572 October 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 October 23 23:36 ownership of initial-setup-ks.cfg5 and chown setting files

The basic syntax format of the chown command is as follows:

Application examples:

[root@centos01] # chown bob 1.txt [root@centos01] # ll Total amount 8-rwxr-xr-x 1 bob root January 17 02:36 1.txtMurray RW. 1 root root 1572 October 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 October 23 23:36 initial-setup-ks.cfg [root@centos01] # chown: benet 1.txt [root@centos01] # ll total dosage 8-rwxr-xr-x 1 bob benet January 17 02:36 1.txtMurray. 1 root root 1572 October 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 October 23 23:36 initial-setup-ks.cfg [root@centos01] # chown bob:benet 1.txt [root@centos01] # ll total dosage 8-rwxr-xr-x 1 bob benet January 17 02:36 1.txtMurray. 1 root root 1572 October 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 October 23 23:36 initial-setup-ks.cfg II, permissions and attribution of directories 1, access rights

2. Ownership (ownership)

Owner: the user account that owns this directory

Group: the group account that owns the directory; 3. Chmod sets directory permissions

The basic format for setting directory permissions by the chmod command is as follows:

Application examples:

[root@centos01] # chmod-R 755 benet/ [root@centos01] # ll total amount 8MhrwMuthxrw1 root root January 11 22:27 1.txtMuyrwyr. 1 root root 1572 October 23 22:37 anaconda-ks.cfgdrwxr-xr-x 3 root root 18 January 11 22:39 benet-rw-r--r--. 1 root root 1603 October 23 23:36 initial-setup-ks.cfg4, chown setting directory attribution

The chown command sets the basic format for directory attribution as follows:

Application examples:

[root@centos01] # chown-R bob:benet benet/ [root@centos01] # ll total consumption 8murrwMuhrwxrw1 root root January 11 22:27 1.txtMurray RWL. 1 root root 1572 October 23 22:37 anaconda-ks.cfgdrwxr-xr-x 3 bob benet 18 January 11 22:39 benet-rw-r--r--. 1 root root 1603 October 23 23:36 initial-setup-ks.cfg III, the role of permission mask umask1, umask

Control the permissions of the newly created file or directory. The default permission to remove the permission of umask is the permission of the newly created file or directory.

2. Set up umaskumask 0223, view umaskumask4, and application examples: [root@centos01 ~] # umask 0022 [root@centos01 ~] # umask 0223 [root@centos01 ~] # umask 0000 [root@centos01 ~] # touch 2.txt [root@centos01] # ll Total usage 8-rwxr-xr-x 1 bob benet 17 03:48 1.txtmurf rwmurf-1 root root January 17 03:48 2.txt-rw-. 1 root root 1572 October 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 October 23 23:36 initial-setup-ks.cfg [root@centos01 ~] # umask 022 [root@centos01 ~] # umask 0022 [root@centos01 ~] # touch 3.txt [root@centos01 ~] # ll Total usage 8-rwxr-xr-x 1 bob benet January 17 03:48 1.txtmurf rwsway RW-1 root root January 17 03:48 2.txtmurf rwlur- -r root root-1 root root January 17 03:49 3.txt-rw-. 1 root root 1572 October 23 22:37 anaconda-ks.cfg-rw-r--r--. 1 root root 1603 October 23 23:36 initial-setup-ks.cfg

After reading this article, have you learned how to manage the permissions of files and directories? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel. Thank you for reading.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report