Linux目录权限下操作总结

  • Post author:
  • Post category:linux



  1. 进入目录需要哪些权限?
[iboy@localhost code]$ ll
total 12
drwxrwxr-x. 2 iboy iboy 4096 Jun 19 21:19 class-2
drwxrwxr-x. 5 iboy iboy 4096 Jul  4 21:34 class-3
drwxrwxr-x. 2 iboy iboy 4096 Jul 11 20:34 class-4
[iboy@localhost code]$ cd class-2
[iboy@localhost class-2]$ cd ..
[iboy@localhost code]$ chmod 075 class-2
[iboy@localhost code]$ ll
total 12
d---rwxr-x. 2 iboy iboy 4096 Jun 19 21:19 class-2
drwxrwxr-x. 5 iboy iboy 4096 Jul  4 21:34 class-3
drwxrwxr-x. 2 iboy iboy 4096 Jul 11 20:34 class-4
[iboy@localhost code]$ cd class-2
bash: cd: class-2: Permission denied
[iboy@localhost code]$ chmod 175 class-2
[iboy@localhost code]$ ll
total 12
d--xrwxr-x. 2 iboy iboy 4096 Jun 19 21:19 class-2
drwxrwxr-x. 5 iboy iboy 4096 Jul  4 21:34 class-3
drwxrwxr-x. 2 iboy iboy 4096 Jul 11 20:34 class-4
[iboy@localhost code]$ cd class-2
[iboy@localhost class-2]$ cd ..
[iboy@localhost code]$ chmod 275
chmod: missing operand after `275'
Try `chmod --help' for more information.
[iboy@localhost code]$ chmod 275 class-2
[iboy@localhost code]$ ll
total 12
d-w-rwxr-x. 2 iboy iboy 4096 Jun 19 21:19 class-2
drwxrwxr-x. 5 iboy iboy 4096 Jul  4 21:34 class-3
drwxrwxr-x. 2 iboy iboy 4096 Jul 11 20:34 class-4
[iboy@localhost code]$ cd class-2
bash: cd: class-2: Permission denied
[iboy@localhost code]$ chmod 475 class-2
[iboy@localhost code]$ ll
total 12
dr--rwxr-x. 2 iboy iboy 4096 Jun 19 21:19 class-2
drwxrwxr-x. 5 iboy iboy 4096 Jul  4 21:34 class-3
drwxrwxr-x. 2 iboy iboy 4096 Jul 11 20:34 class-4
[iboy@localhost code]$ cd class-2
bash: cd: class-2: Permission denied

一开始目录class-2的权限可读可写可执行,然后将该目录权限改为没有任何权限和可读,可写权限下,均不能进入目录。只有当目录权限为可执行时才能进入目录。


2.对文件改动需要哪些权限?
[iboy@localhost code]$ ll
total 12
d--xrwxr-x. 2 iboy iboy 4096 Aug  6 11:10 class-2
drwxrwxr-x. 5 iboy iboy 4096 Jul  4 21:34 class-3
drwxrwxr-x. 2 iboy iboy 4096 Jul 11 20:34 class-4
[iboy@localhost code]$ cd class-2
[iboy@localhost class-2]$ ls
ls: cannot open directory .: Permission denied
[iboy@localhost class-2]$ touch test
touch: cannot touch `test': Permission denied
[iboy@localhost class-2]$ rm file
rm: cannot remove `file': Permission denied
[iboy@localhost class-2]$ mv file test
mv: cannot move `file' to `test': Permission denied

当该目录class-2只有可执行权限时,只能进入该目录,但不能执行任何对文件的操作。

[iboy@localhost code]$ chmod 375 class-2
[iboy@localhost code]$ ll
total 12
d-wxrwxr-x. 2 iboy iboy 4096 Aug  6 11:10 class-2
drwxrwxr-x. 5 iboy iboy 4096 Jul  4 21:34 class-3
drwxrwxr-x. 2 iboy iboy 4096 Jul 11 20:34 class-4
[iboy@localhost code]$ cd class-2
[iboy@localhost class-2]$ ls
ls: cannot open directory .: Permission denied
[iboy@localhost class-2]$ touch test
[iboy@localhost class-2]$ rm test
[iboy@localhost class-2]$ mv file test

当目录权限为可写和可执行权限时可以在该目录下进行文件的修改,创建和删除,但不能查看该目录下的文件。

[iboy@localhost code]$ chmod 775 class-2
[iboy@localhost code]$ ll
total 12
drwxrwxr-x. 2 iboy iboy 4096 Aug  6 11:23 class-2
drwxrwxr-x. 5 iboy iboy 4096 Jul  4 21:34 class-3
drwxrwxr-x. 2 iboy iboy 4096 Jul 11 20:34 class-4
[iboy@localhost code]$ cd class-2
[iboy@localhost class-2]$ ls
file  file.zip  name

当目录

转载于:https://my.oschina.net/u/3867614/blog/1923088