linux 文件权限的管理
2009-10-10 10:14
489 查看
chgrp : 改变文件所属组
chown : 改变文件拥有者
chmod : 改变文件的权限
chgrp 这个命令就是 change group 的缩写,chgrp - R groupName FileName , 要改变的组名称必须要要在 /etc/group 内才行,否则报错:
[root@andy ~]# ll
total 64
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rw-r--r-- 1 root root 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
[root@andy ~]# chgrp andy file
chgrp: invalid group `andy' //报错信息,找不到Andy组
[root@andy ~]#
[root@andy ~]# chgrp test file
[root@andy ~]# ll
total 64
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rw-r--r-- 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
[root@andy ~]#
chown , 就是 change owner 的缩写, UserName 必须在 /etc/passwd 中才行.
chown [ -R ] UserName FileName
chown [ -R ] UsetName:GroupName FileName
[root@andy ~]# ll
total 68
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rw-r--r-- 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
drwxr-xr-x 3 root test 4096 Oct 10 09:26 sj
[root@andy ~]# chown andy01 sj
[root@andy ~]# ll
total 68
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rw-r--r-- 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
drwxr-xr-x 3 andy01 test 4096 Oct 10 09:26 sj
[root@andy ~]#
[root@andy ~]# ll
total 68
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rw-r--r-- 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
drwxr-xr-x 3 andy01 test 4096 Oct 10 09:26 sj
[root@andy ~]# chown -R root:root sj
[root@andy ~]# ll
total 68
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rw-r--r-- 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
drwxr-xr-x 3 root root 4096 Oct 10 09:26 sj
chmod : 数字类型改变文件权限
r : 4
w : 2
x : 1
owner = rwx = 4+2+1 = 7
group = rw- = 4+2 +0 = 6
others = r- - = 4+0+0 = 4
chmod [ -R ] 764 FileName
[root@andy ~]# ll
total 68
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rw-r--r-- 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
drwxr-xr-x 3 root root 4096 Oct 10 09:26 sj
[root@andy ~]# chmod 764 file
[root@andy ~]# ll
total 68
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rwxrw-r-- 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
drwxr-xr-x 3 root root 4096 Oct 10 09:26 sj
[root@andy ~]#
符号类型改变文件权限
chmod [ u , g , o , a ] [ + , - , = ] FileName
[root@andy ~]# chmod u=rwx,go=rx file
[root@andy ~]# ll
total 68
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rwxr-xr-x 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
drwxr-xr-x 3 root root 4096 Oct 10 09:26 sj
[root@andy ~]#
chown : 改变文件拥有者
chmod : 改变文件的权限
chgrp 这个命令就是 change group 的缩写,chgrp - R groupName FileName , 要改变的组名称必须要要在 /etc/group 内才行,否则报错:
[root@andy ~]# ll
total 64
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rw-r--r-- 1 root root 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
[root@andy ~]# chgrp andy file
chgrp: invalid group `andy' //报错信息,找不到Andy组
[root@andy ~]#
[root@andy ~]# chgrp test file
[root@andy ~]# ll
total 64
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rw-r--r-- 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
[root@andy ~]#
chown , 就是 change owner 的缩写, UserName 必须在 /etc/passwd 中才行.
chown [ -R ] UserName FileName
chown [ -R ] UsetName:GroupName FileName
[root@andy ~]# ll
total 68
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rw-r--r-- 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
drwxr-xr-x 3 root test 4096 Oct 10 09:26 sj
[root@andy ~]# chown andy01 sj
[root@andy ~]# ll
total 68
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rw-r--r-- 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
drwxr-xr-x 3 andy01 test 4096 Oct 10 09:26 sj
[root@andy ~]#
[root@andy ~]# ll
total 68
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rw-r--r-- 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
drwxr-xr-x 3 andy01 test 4096 Oct 10 09:26 sj
[root@andy ~]# chown -R root:root sj
[root@andy ~]# ll
total 68
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rw-r--r-- 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
drwxr-xr-x 3 root root 4096 Oct 10 09:26 sj
chmod : 数字类型改变文件权限
r : 4
w : 2
x : 1
owner = rwx = 4+2+1 = 7
group = rw- = 4+2 +0 = 6
others = r- - = 4+0+0 = 4
chmod [ -R ] 764 FileName
[root@andy ~]# ll
total 68
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rw-r--r-- 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
drwxr-xr-x 3 root root 4096 Oct 10 09:26 sj
[root@andy ~]# chmod 764 file
[root@andy ~]# ll
total 68
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rwxrw-r-- 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
drwxr-xr-x 3 root root 4096 Oct 10 09:26 sj
[root@andy ~]#
符号类型改变文件权限
chmod [ u , g , o , a ] [ + , - , = ] FileName
[root@andy ~]# chmod u=rwx,go=rx file
[root@andy ~]# ll
total 68
-rw------- 1 root root 2451 Oct 10 00:50 anaconda-ks.cfg
-rwxr-xr-x 1 root test 0 Oct 10 01:18 file
-rw-r--r-- 1 root root 34539 Oct 10 00:50 install.log
-rw-r--r-- 1 root root 8002 Oct 10 00:50 install.log.syslog
drwxr-xr-x 3 root root 4096 Oct 10 09:26 sj
[root@andy ~]#
相关文章推荐
- 实验楼linux学习笔记(二):用户及文件权限管理
- 鸟哥的Linux私房菜之Linux 的文件权限与目录管理(一)
- 40_Linux下的文件权限管理
- 【Linux】文件的权限管理
- Linux之文件权限管理
- linux修改文件权限和用户组管理小结 经常会用到的命令
- linux修改文件权限和用户组管理小结
- Linux学习--文件权限与目录管理
- Linux中文件系统的权限管理(普通权限,特殊权限,文件的扩展属性,FACL)
- Linux权限管理之文件默认权限
- Linux常用命令--目录管理、文件管理、权限管理
- Linux权限管理ACL权限,文件特殊权限,chattr权限,sudo权限
- Linux 文件解压缩及权限管理
- Linux用户及文件权限管理
- Linux之用户及文件权限管理
- Linux基础管理——文件权限管理(访问控制)
- 项目二 任务六管理Linux系统的文件权限
- 任务六 管理Linux系统的文件权限
- 项目二 任务六 管理Linux系统的文件权限