chgrp 改变所属用户组
要被改变的组名必须要在/etc/group文件内存在才行;
chgrp [-R] dirname/filename
-R:进行递归的持续更改,连同子目录下的所有文件、目录都更新为新的用户组
chown 改变文件所有者
如果要连目录下的的所有子目录或文件 都同时更改文件所有者的话,直接加上-R参数即可
chown [-R] 账号名称 文件或目录
chown [-R] 账号名称:组名 文件或目录
chown [-R] 账号名称.组名 文件或目录
chmod 改变权限
数字类型改变文件权限
[[email protected] tmp]# ll total 4 drwxr-xr-x. 2 root root 4096 Aug 22 06:11 foo [[email protected] tmp]# chmod 000 foo/ [[email protected] tmp]# ls foo [[email protected] tmp]# ll total 4 d---------. 2 root root 4096 Aug 22 06:11 foo [[email protected] tmp]# chmod 777 foo/ [[email protected] tmp]# ll total 4 drwxrwxrwx. 2 root root 4096 Aug 22 06:11 foo [[email protected] tmp]# chmod 641 foo/ [[email protected] tmp]# ls foo [[email protected] tmp]# ll total 4 drw-r----x. 2 root root 4096 Aug 22 06:11 foo [[email protected]t01 tmp]# chmod 755 foo/ [[email protected] tmp]# ll total 4 drwxr-xr-x. 2 root root 4096 Aug 22 06:11 foo [[email protected] tmp]#
符号类型改变文件权限
[[email protected] tmp]# chmod u=rwx,g=rw,o=rw /tmp/foo/ [[email protected] tmp]# ll total 4 drwxrw-rw-. 2 root root 4096 Aug 22 06:11 foo [[email protected] tmp]# chmod u=rx,g+x,o-rw /tmp/foo/ [[email protected] tmp]# ll total 4 dr-xrwx---. 2 root root 4096 Aug 22 06:11 foo [[email protected] tmp]# chmod ugo=rw /tmp/foo/ [[email protected] tmp]# l -bash: l: command not found [[email protected] tmp]# ll total 4 drw-rw-rw-. 2 root root 4096 Aug 22 06:11 foo [[email protected] tmp]# chmod ug=rw,o-rw /tmp/foo/ [[email protected] tmp]# ll total 4 drw-rw----. 2 root root 4096 Aug 22 06:11 foo [[email protected] tmp]#
时间: 2024-11-03 19:49:18