码迷,mamicode.com
首页 > 其他好文 > 详细

权限和归属

时间:2018-11-07 11:35:54      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:文本文件   chmod   txt   读写   div   roo   目录文件   server   color   

查看权限: 

    ls -l  file_path      查看文本文件权限

    ls -ld dir_path     查看目录文件权限

[root@server0 ~]# mkdir -p /test/test01
[root@server0 ~]# ls -ld /test/test01
drwxr-xr-x. 2 root root 6 11月  6 20:39 /test/test01
[root@server0 ~]# touch /test/test01.txt
[root@server0 ~]# ls -l /test/test01.txt
-rw-r--r--. 1 root root 0 11月  6 20:40 /test/test01.txt
[root@server0 ~]# 

 

修改权限:

  chmod o+x file_path          给其他用户添加执行权限

  chmod o-x file_path        除去其他用户的执行权限

  chmod u+x,g-w,o-w  file_path        给所有者添加执行权限,所属组除去写权限,其他用户除去写权限 

  chmod u=rwx,g=rx,o=rx                 所有者读写执行权限,所属组和其他用户都执行权限

    chmod ugo=rwx         所有人读写执行权限 

  chmod 777           所有人读写执行权限

[root@server0 ~]# ls -ld /test/
drwxr-xr-x. 3 root root 36 11月  6 20:40 /test/
[root@server0 ~]# chmod o+w /test/
[root@server0 ~]# ls -ld /test/
drwxr-xrwx. 3 root root 36 11月  6 20:40 /test/
[root@server0 ~]# chmod u-w,g-x,o-w /test/
[root@server0 ~]# ls -ld /test/
dr-xr--r-x. 3 root root 36 11月  6 20:40 /test/
[root@server0 ~]# chmod u=rwx,g=rw,o=r /test/
[root@server0 ~]# ls -ld /test/
drwxrw-r--. 3 root root 36 11月  6 20:40 /test/
[root@server0 ~]# chmod ugo=--- /test/
[root@server0 ~]# ls -ld /test/
d---------. 3 root root 36 11月  6 20:40 /test/
[root@server0 ~]# chmod 777 /test/
[root@server0 ~]# ls -ld /test/
drwxrwxrwx. 3 root root 36 11月  6 20:40 /test/
[root@server0 ~]# 

修改组

  chown 所有者:所属组  文件

  修改文件的所有者,所属组

[root@S opt]# mkdir /opt/test
[root@S opt]# ls -ld /opt/test/
drwxr-xr-x. 2 root root 6 11月  7 09:08 /opt/test/
[root@S opt]# chown harry:harry /opt/test/
[root@S opt]# ls -ld /opt/test/
drwxr-xr-x. 2 harry harry 6 11月  7 09:08 /opt/test/
[root@S opt]# 

 

权限和归属

标签:文本文件   chmod   txt   读写   div   roo   目录文件   server   color   

原文地址:https://www.cnblogs.com/ray-mmss/p/9915495.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!