(一)权限管理 chgrp、chown、chmod
一:linux档案属性
1 [root@localhost ~]# ls -all 2 总用量 104 3 dr-xr-x---. 2 root root 4096 8月 10 21:36 . 4 dr-xr-xr-x. 24 root root 4096 8月 10 21:38 .. 5 -rw-------. 1 root root 2454 8月 10 21:36 anaconda-ks.cfg 6 -rw-r--r--. 1 root root 18 5月 20 2009 .bash_logout 7 -rw-r--r--. 1 root root 176 5月 20 2009 .bash_profile 8 -rw-r--r--. 1 root root 176 9月 23 2004 .bashrc 9 -rw-r--r--. 1 root root 100 9月 23 2004 .cshrc 10 -rw-r--r--. 1 root root 52211 8月 10 21:36 install.log 11 -rw-r--r--. 1 root root 14312 8月 10 21:34 install.log.syslog 12 -rw-r--r--. 1 root root 129 12月 4 2004 .tcshrc

档案属性:-rwxrwxrwx(共有10个属性)
第一个属性代表这个档案是【目录、档案或链接文件等】
- d:代表目录
- -:代表档案
- b:代表为装置文件里面的可供储存的接口设备
- c:代表为装置文件里面的串行端口设备,例如:键盘、鼠标
接下来的属性,三个为一组,且均为【rwx】的三个参数的组合,r代表读(读),w代表写(write),x代表可执行(excute)
- 第一组为【拥有者的权限】
- 第二组为【同群组的权限】
- 第三组为【其他非本群组的权限】
范例:【-rwxr-xr--】
- 该文件为档案
- 该文件拥有者具有读、写、可执行的权限
- 该文件同群组人具有读、可执行的权限
- 该文件非同群组人具有读的权限
改变所属群组:chgrp
格式:chgrp dirname filename
1 [root@localhost ~]# ls -l 2 总用量 76 3 -rw-------. 1 root root 2454 8月 10 21:36 anaconda-ks.cfg 4 -rw-r--r--. 1 root root 52211 8月 10 21:36 install.log 5 -rw-r--r--. 1 root root 14312 8月 10 21:34 install.log.syslog 6 [root@localhost ~]# chgrp users install.log 7 [root@localhost ~]# ls -l 8 总用量 76 9 -rw-------. 1 root root 2454 8月 10 21:36 anaconda-ks.cfg 10 -rw-r--r--. 1 root users 52211 8月 10 21:36 install.log 11 -rw-r--r--. 1 root root 14312 8月 10 21:34 install.log.syslog
改变档案拥有者:chown
格式:chown 账号名称/群组名称 档案/目录
1 [root@localhost ~]# chown bin install.log 2 [root@localhost ~]# ls -l 3 总用量 76 4 -rw-------. 1 root root 2454 8月 10 21:36 anaconda-ks.cfg 5 -rw-r--r--. 1 bin users 52211 8月 10 21:36 install.log 6 -rw-r--r--. 1 root root 14312 8月 10 21:34 install.log.syslog 7 [root@localhost ~]# chown root install.log 8 [root@localhost ~]# ls -l 9 总用量 76 10 -rw-------. 1 root root 2454 8月 10 21:36 anaconda-ks.cfg 11 -rw-r--r--. 1 root users 52211 8月 10 21:36 install.log 12 -rw-r--r--. 1 root root 14312 8月 10 21:34 install.log.syslog
改变档案权限:chmod
方法一:数字类型改变档案权限
格式:chmod xyz(数字类型的权限属性) 档案/目录
数字代表其属性 r:4 w:2 x:1
-rwxrwxrwx 该属性的数字为770
owner:4+2+1=7
group:4+2+1=7
others:4+2+1=7
1 [root@localhost ~]# chmod 763 install.log 2 [root@localhost ~]# ls -l 3 总用量 76 4 -rw-------. 1 root root 2454 8月 10 21:36 anaconda-ks.cfg 5 -rwxrw--wx. 1 root users 52211 8月 10 21:36 install.log 6 -rw-r--r--. 1 root root 14312 8月 10 21:34 install.log.syslog
方法二:符号类型改变档案权限
-rwxr-xr-x
user(u):具有可读、可写、可执行的权限
group与others(g/o):具有可读、可执行的权限
1 [root@localhost ~]# chmod u=rwx,go=rx install.log 2 [root@localhost ~]# ls -l 3 总用量 76 4 -rw-------. 1 root root 2454 8月 10 21:36 anaconda-ks.cfg 5 -rwxr-xr-x. 1 root users 52211 8月 10 21:36 install.log 6 -rw-r--r--. 1 root root 14312 8月 10 21:34 install.log.syslog
在原有属性上加上w(可写)属性
1 [root@localhost ~]# chmod a+w install.log 2 [root@localhost ~]# ls -l 3 总用量 76 4 -rw-------. 1 root root 2454 8月 10 21:36 anaconda-ks.cfg 5 -rwx-wxrwx. 1 root users 52211 8月 10 21:36 install.log 6 -rw-r--r--. 1 root root 14312 8月 10 21:34 install.log.syslog
在原有属性上减去x(可执行)属性
1 [root@localhost ~]# chmod a-x install.log 2 [root@localhost ~]# ls -l 3 总用量 76 4 -rw-------. 1 root root 2454 8月 10 21:36 anaconda-ks.cfg 5 -rw--w-rw-. 1 root users 52211 8月 10 21:36 install.log 6 -rw-r--r--. 1 root root 14312 8月 10 21:34 install.log.syslog


浙公网安备 33010602011771号