linux基础命令-chgrp/chown/chomd

chgrp 改变所属用户组

要被改变的组名必须要在/etc/group文件内存在才行;

chgrp [-R]   dirname/filename

-R:进行递归的持续更改,连同子目录下的所有文件、目录都更新为新的用户组

chown 改变文件所有者

如果要连目录下的的所有子目录或文件 都同时更改文件所有者的话,直接加上-R参数即可

chown  [-R]  账号名称                   文件或目录

chown [-R]   账号名称组名          文件或目录

chown [-R]  账号名称.组名           文件或目录

chmod  改变权限

数字类型改变文件权限

[root@host01 tmp]# ll
total 4
drwxr-xr-x. 2 root root 4096 Aug 22 06:11 foo
[root@host01 tmp]# chmod 000  foo/
[root@host01 tmp]# ls
foo
[root@host01 tmp]# ll
total 4
d---------. 2 root root 4096 Aug 22 06:11 foo
[root@host01 tmp]# chmod 777 foo/
[root@host01 tmp]# ll
total 4
drwxrwxrwx. 2 root root 4096 Aug 22 06:11 foo
[root@host01 tmp]# chmod 641 foo/
[root@host01 tmp]# ls
foo
[root@host01 tmp]# ll
total 4
drw-r----x. 2 root root 4096 Aug 22 06:11 foo
[root@host01 tmp]# chmod 755 foo/
[root@host01 tmp]# ll
total 4
drwxr-xr-x. 2 root root 4096 Aug 22 06:11 foo
[root@host01 tmp]# 

符号类型改变文件权限

[root@host01 tmp]# chmod  u=rwx,g=rw,o=rw  /tmp/foo/
[root@host01 tmp]# ll
total 4
drwxrw-rw-. 2 root root 4096 Aug 22 06:11 foo
[root@host01 tmp]# chmod  u=rx,g+x,o-rw  /tmp/foo/
[root@host01 tmp]# ll
total 4
dr-xrwx---. 2 root root 4096 Aug 22 06:11 foo
[root@host01 tmp]# chmod  ugo=rw  /tmp/foo/
[root@host01 tmp]# l
-bash: l: command not found
[root@host01 tmp]# ll
total 4
drw-rw-rw-. 2 root root 4096 Aug 22 06:11 foo
[root@host01 tmp]# chmod  ug=rw,o-rw  /tmp/foo/
[root@host01 tmp]# ll
total 4
drw-rw----. 2 root root 4096 Aug 22 06:11 foo
[root@host01 tmp]# 

 

            

posted @ 2017-08-21 22:26  JUSTZHI  阅读(375)  评论(0编辑  收藏  举报