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 to introduce Linux chmod directory permissions

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

Share

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

In this issue, the editor will bring you about how to introduce the permissions of the Linux chmod directory. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

In the Linux file system model, each file has a set of nine permission bits to control who can read, write and execute the contents of the file. We all know about ordinary documents. Let's talk about the catalogue here.

For a directory, the role of the execution bit is to control whether it can be entered or passed through the directory, not to control whether its contents can be listed. The role of the combination of read bits and execution bits is to control whether the contents of the directory are listed. The combination of write bits and execution bits allows files to be created, deleted, and renamed in the directory.

Here is an example to illustrate the problem: the main command is chmod

An ordinary user creates a folder linuxidc. The default permission is 775.

Linuxidc@Ubuntu:~/linuxidc.com$ mkdir linuxidclinuxidc@ubuntu:~/linuxidc.com$ lslinuxidclinuxidc@ubuntu:~/linuxidc.com$ ls-ltotal 4drwxr-xr-x 2 linuxidclinuxidc 4096 Feb 16 20:18 linuxidclinuxidc@ubuntu:~/linuxidc.com$ ls-l linuxidc/total 0

Change directory permissions to 700, and files can be created in the directory.

Linuxidc@ubuntu:~/linuxidc.com$ chmod 700linuxidc/linuxidc@ubuntu:~/linuxidc.com$ uptime > linuxidc/uptimelinuxidc@ubuntu:~/linuxidc.com$ ls-ltotal 4drwx-2 linuxidclinuxidc 4096 Feb 16 20:22 linuxidclinuxidc@ubuntu:~/linuxidc.com$ ls-l linuxidc/total 4koto Rukhok Ruki-1 linuxidclinuxidc 61 Feb 16 20:22 uptimelinuxidc@ubuntu:~/linuxidc.com$ cat linuxidc/uptime 20:22:23 up 13:22, 1 user, load average: 0.00,0.08,0.20

Change the permissions of the directory to 400. details cannot be listed in the directory, cannot be CAT, and files cannot be created.

Linuxidc@ubuntu:~/linuxidc.com$ chmod 400 linuxidc/linuxidc@ubuntu:~/linuxidc.com$ ls-l linuxidc/ls: cannot access' linuxidc/uptime': Permission deniedtotal 0muri?? Uptimelinuxidc@ubuntu:~/linuxidc.com$ ls-ltotal 4dr2 linuxidclinuxidc 4096 Feb 16 20:22 linuxidclinuxidc@ubuntu:~/linuxidc.com$ cat linuxidc/uptimecat: linuxidc/uptime: Permission deniedlinuxidc@ubuntu:~/linuxidc.com$ touch linuxidc/linuxmitouch: cannot touch 'linuxidc/linuxmi': Permission denied

Change the permission of the directory to 100. the directory cannot be listed, the directory can be entered, the file cannot be created, but the file within the Cat (of course, the permission of the file should have, and know its name, can not be associated)

Linuxidc@ubuntu:~/linuxidc.com$ chmod 100 linuxidc/linuxidc@ubuntu:~/linuxidc.com$ ls-ltotal 4dMurray x-2 linuxidclinuxidc 4096 Feb 16 20:22 linuxidclinuxidc@ubuntu:~/linuxidc.com$ ls-l linuxidc/ls: cannot open directory 'linuxidc/': Permission deniedlinuxidc@ubuntu:~/linuxidc.com$ ls-l linuxidc/uptime-rw-r--r-- 1 linuxidclinuxidc 61 Feb 16 20:22 linuxidc/uptimelinuxidc@ubuntu:~/linuxidc.com$ cd linuxidc/linuxidc@ubuntu: ~ / linuxidc.com/linuxidc$ ls-lls: cannot open directory'.': Permission deniedlinuxidc@ubuntu:~/linuxidc.com/linuxidc$ cat uptime 20:22:23 up 13:22 1 user, load average: 0.00,0.08,0.20 linuxidc touch linuxmitouch: cannot touch 'linuxmi': Permission denied

Change the permissions of the directory to 200. cannot be listed in the directory, cannot be CAT, and cannot create files.

Linuxidc@ubuntu:~/linuxidc.com$ chmod 200 linuxidc/linuxidc@ubuntu:~/linuxidc.com$ ls-ltotal 4dMurw-2 linuxidclinuxidc 4096 Feb 16 20:22 linuxidclinuxidc@ubuntu:~/linuxidc.com$ ls-l linuxidc/ls: cannot open directory 'linuxidc/': Permission deniedlinuxidc@ubuntu:~/linuxidc.com$ cat linuxidc/uptimecat: linuxidc/uptime: Permission deniedlinuxidc@ubuntu:~/linuxidc.com$ touch linuxidc/linuxidctouch: cannot touch' linuxidc/linuxidc': Permission denied

Change the permissions of the directory to 500. it can be listed in the directory, can be CAT, and cannot create files.

Linuxidc@ubuntu:~/linuxidc.com$ chmod 500 linuxidc/linuxidc@ubuntu:~/linuxidc.com$ ls-ltotal 4drmurx-2 linuxidclinuxidc 4096 Feb 16 20:22 linuxidclinuxidc@ubuntu:~/linuxidc.com$ ls-l linuxidc/total 4Murray Rukhom linuxidclinuxidc-1 linuxidclinuxidc 61 Feb 16 20:22 uptimelinuxidc@ubuntu:~/linuxidc.com$ cat linuxidc/uptime 20:22:23 up 13:22, 1 user, load average: 0.00,0.08 0.20 linuxidcUBUTUTU _ linuxidc/linuxidc.com': Permission denied _ UBG _ linuxidc. Com $touch linuxidc/linuxidc.comtouch: cannot touch 'linuxidc/linuxidc.com': Permission denied

Change the permission of the directory to 300. it can not be listed in the directory, but CAT (of course, the permission of the file should be there, and you can't associate it with its name), you can create a file.

Linuxidc@ubuntu:~/linuxidc.com$ chmod 300 linuxidc/linuxidc@ubuntu:~/linuxidc.com$ ls-ltotal 4dMurwx-2 linuxidclinuxidc 4096 Feb 16 20:22 linuxidclinuxidc@ubuntu:~/linuxidc.com$ ls-l linuxidc/ls: cannot open directory 'linuxidc/': Permission deniedlinuxidc@ubuntu:~/linuxidc.com$ cat linuxidc/uptime 20:22:23 up 13:22, 1 user, load average: 0.00,0.08,0.20 linuxidc. Com $touch linuxidc/linuxlinuxidc@ubuntu:~/linuxidc.com$

Remarks: 700=rwx, 400cm, 100m x, 200m w, 500=rx, 300=wx

The above is the editor for you to share how to introduce Linux chmod directory permissions, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

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