linux 该变文件拥有者chown,改变文件所属群组chgrp,改变文件权限chmod

来源:互联网 发布:网络强国包括哪些要素 编辑:程序博客网 时间:2024/05/06 23:28
 

1. 改变文件所属群组 chgrp 

chgrp [-R] dirname/filename

参数-R: 进行递归(recursive) 的变更。常常用在某一目录内所有的档案。

Examples:  chgrp staff /u      注:Change the group of /u to "staff".  chgrp -hR staff /u  注:Change the group of /u and subfiles to "staff".

 

2. 改变文件拥有者 chown

chown [-R] 帐号名称 档案或目录

chown [-R] 帐号名称:群组名称 档案或目录

选项与参数:

-R :进行递归(recursive) 的变更。

EXAMPLES       chown root /u注:Change the owner of /u to "root".       chown root:staff /u注:Likewise, but also change its group to "staff".       chown -hR root /u注:Change the owner of /u and subfiles to "root".

3. 改变文件权限 chmod

chmod [-R] xyz 档案或目录

选项和参数:

 xyz:为rwx 属性数值的相加

-R:为循环(recurive) 递归的变更

档案的权限为:-rwxrwxrwx ,这就个权限是三个三个一组的!其中,我们可以使用数字来代表各种权限,各权限的分数对照如下:

r:4 w:2 x:1

 Example:

[root@www ~]# ls -al .bashrc-rw-r--r--  1 root root 395 Jul  4 11:45 .bashrc[root@localhost]# chmod 777 .bashrc[root@localhost]# ls -al .bashrc-rwxrwxrwx  1 root root 395 Jul  4 11:45 .bashrc