Linux文件属性、权限设置
如:
[root@test root]# chgrp users tmp
[root@test root]# ls –l
drwx------??? 2 root???? root???????? 4096 Oct 19 11:43 drakx/
drwx------??? 2 root???? users??????? 4096 Oct 19 21:24 tmp/
[root@test root]# chgrp testing tmp
chgrp: invalid group name `testing'?? <==出错信息!
如:
[root@test root]# chown test tmp
[root@test root]# ls -l
total 28
drwx------??? 2 root???? root???????? 4096 Oct 19 11:43 drakx/
drwx------??? 2 test???? users??????? 4096 Oct 19 21:24 tmp/
[root@test root]# chown –R root:root tmp?
[root@test root]# ls –l
drwx------??? 2 root???? root???????? 4096 Oct 19 11:43 drakx/
drwx------??? 2 root???? root???????? 4096 Oct 19 21:24 tmp/
方式一 数字类型改变
三个基本属性:r、w、x的数字类型代表:r:4、w:2 、x:1
语法:
chmod [-R] xyz?文件或目录
xyz 为三組 rwx 属性数值的相加
同一组的数字是相加!如属性为 [ -rwxrwx--- ] ,则:
owner? = rwx? = 4+2+1 = 7
group? = rwx? = 4+2+1 = 7
others = ---? = 0+0+0 = 0
[root@test root]# ls –al .bashrc
-rw-r--r--??? 1 root???? root????????? 226 Feb 16? 2002 .bashrc
[root@test root]# chmod 777 .bashrc
[root@test root]# ls –al .bashrc
-rwxrwxrwx??? 1 root???? root????????? 226 Feb 16? 2002 .bashrc
[root@test root]# chmod u=rwx,og=rx .bashrc
[root@test root]# ls –al .bashrc
-rwxr-xr-x??? 1 root???? root????????? 226 Feb 16? 2002 .bashrc
[root@test root]# ls –al .bashrc
-rwxr-xr-x??? 1 root???? root????????? 226 Feb 16? 2002 .bashrc
[root@test root]# chmod a+w .bashrc
[root@test root]# ls –al .bashrc
-rwxrwxrwx??? 1 root???? root????????? 226 Feb 16? 2002 .bashrc
[root@test root]# chmod a-x .bashrc
[root@test root]# ls –al .bashrc
-rw-rw-rw-??? 1 root???? root????????? 226 Feb 16? 2002 .bashrc