linux入门第4篇-文件和目录权限

来源:互联网 发布:淘宝开店货源免费代理 编辑:程序博客网 时间:2024/06/04 00:58

1.查看文件和目录属性

[root@hostline /]# ls -l /test总用量 0-rw-r--r--. 1 root root 0 5月  25 12:41 a.txtdrwxr-xr-x. 2 root root 6 5月  25 12:31 documentdrwxr-xr-x. 2 root root 6 5月  25 12:48 picture
             说明:a.txt中‘-’表示普通文件;rw-r-r就是三组权限位 r表示可读,w表示可写,x表示可执行,那么属主就能执行读写和执行权限;第三个和第四个root,root分别表示属主和属组,在这里root是属主,root是组;紧跟着0表示连接数目,说明a.txt后面没文件,而document里面有六个文件;最后表示文件修改日期和文件名

2.查看目录的属性

[root@hostline /]# ls -ld /testdrwxr-xr-x. 4 root root 47 5月  25 12:41 /test
3.修改文件权限 chown和chgrp

           chown用于修改文件权限

[root@hostline test]# sudo chown hello:root a.txt [root@hostline test]# lsa.txt  document  picture[root@hostline test]# ls -l a.txt-rw-r--r--. 1 hello root 0 5月  25 12:41 a.txt
             a.txt以前的属主和属组都是root,现在改为属主hello,属组root

3.改变文件权限

[root@hostline test]# chmod u+x a.txt
             这条命令是增加属主对文件的执行权限
[root@hostline test]# chmod a-x a.txt
            这条命令是删除所有人对days的执行权限

原创粉丝点击