unix目录权限的含义
- 本文链接地址:http://zhubaining.com/blog/2010/09/20/archives/unix%e7%9b%ae%e5%bd%95%e6%9d%83%e9%99%90%e7%9a%84%e5%90%ab%e4%b9%89
- 作者:zhubaining
unix基础知识,温故知新。
| WHO | WHAT THE PERMISSIONS ALLOW | |
|---|---|---|
| USER | Read (r) | The account owner can list the files in the directory. |
| Write (w) | The account owner can create or delete files in the directory. | |
| Execute (x) | access files in that directory by name (such as Web page files). | |
| GROUP | Read (r) | Everyone in the designated group can list the files in the directory. |
| Write (w) | Everyone in the group can create or delete files in the directory. | |
| Execute (x) | Everyone in the group can change (cd) into the directory and access files in that directory by name (such as Web page files). | |
| OTHER | Read (r) | Anyone can list the files in the directory. |
| Write (w) | Anyone can create or delete files in the directory. | |
| Execute (x) | Anyone can change (cd) into the directory and access files in that directory by name (such as Web page files). | |
去掉r权限,则无法列目录,但是可以cd或者通过名称访问文件:
[someone@eb tmp]$ ll -l
total 8
drwxrwx-wx 2 root root 4096 Sep 20 14:31 someone
drwxrwxrwt 3 someone someone 4096 Mar 10 2009 uscreens
[someone@eb tmp]$ ll someone
ls: someone: Permission denied
[someone@eb tmp]$ cd someone
[someone@eb someone]$ ls
ls: .: Permission denied
[someone@eb someone]$ cat a.txt
[someone@eb someone]$ cd ..
[someone@eb tmp]$ cat someone/a.txt
[someone@eb tmp]$
去掉x权限,我们发现无法cd:
[root@eb tmp]# ll
total 8
drwxr–r-x 2 root root 4096 Sep 20 14:31 someone
drwxrwxrwt 3 someone someone 4096 Mar 10 2009 uscreens
[root@eb tmp]# chmod o-x someone
[root@eb tmp]# ll
total 8
drwxr–r– 2 root root 4096 Sep 20 14:31 someone
drwxrwxrwt 3 someone someone 4096 Mar 10 2009 uscreens
[root@eb tmp]# su someone
[someone@eb tmp]$ cd someone
bash: cd: someone: Permission denied
ll没有问题,但是cat里面的问题就出错了:
[someone@eb tmp]$ ll someone
total 0
?——— ? ? ? ? ? a.txt
[someone@eb tmp]$ cat someone/a.txt
cat: someone/a.txt: Permission denied
Recent Comments