基本权限UGO
文件权限设置:可以赋予某个用户或组 能够以何种方式 访问某个文件
文件权限管理之:UGO设置基本权限(r、w、x)
权限对象:
属主: u
属组: g
其他人: o
权限类型:
读:r 4
写:w 2
执行:x 1
例子:
rw- r-- r-- alice hr install.log
属主 属组 其他
对于上面的文件:
alice有什么权限???
alice是所有者,所以拥有rw权限
jack属于hr组,它拥有什么权限???
jack拥有r权限
tom有什么权限???
tom是其他用户,用于r权限。
命令:chown
修改用于属主、属组
修改属主:
-rw-r--r--. 1 root root 14 2月 17 17:52 test
[root@localhost ~]# chown xiaoming test
-rw-r--r--. 1 xiaoming root 14 2月 17 17:52 test
修改属主和属组
[root@localhost ~]# chown xiaoming.xiaoming test
[root@localhost ~]# ll test
-rw-r--r--. 1 xiaoming xiaoming 14 2月 17 17:52 test
修改属组:
[root@localhost ~]# ll test1
-rw-r--r--. 1 root root 16 2月 17 17:58 test1
[root@localhost ~]# chown .xiaoming test1
[root@localhost ~]# ll test1
-rw-r--r--. 1 root xiaoming 16 2月 17 17:58 test1
命令:chgrp:
[root@localhost ~]# ll test3
-rw-r--r--. 1 root root 16 2月 17 18:01 test3
[root@localhost ~]# chgrp xiaoming test3
[root@localhost ~]# ll test3
-rw-r--r--. 1 root xiaoming 16 2月 17 18:01 test3
[root@localhost ~]#
更改权限:chmod:
修改属主权限,添加可执行权限:
[root@localhost ~]# ll test1
-rw-r--r--. 1 root xiaoming 16 2月 17 17:58 test1
[root@localhost ~]# chmod u+x test1
[root@localhost ~]# ll test1
-rwxr--r--. 1 root xiaoming 16 2月 17 17:58 test1
修改属组权限,添加可执行权限:
[root@localhost ~]# ll test1
-rwxr--r--. 1 root xiaoming 16 2月 17 17:58 test1
[root@localhost ~]# chmod g+x test1
[root@localhost ~]# ll test1
-rwxr-xr--. 1 root xiaoming 16 2月 17 17:58 test1
给所有人添加读写执行权限
[root@localhost ~]# ll test1
-rwxr-xr--. 1 root xiaoming 16 2月 17 17:58 test1
[root@localhost ~]# chmod a=rwx test1
[root@localhost ~]# ll test1
-rwxrwxrwx. 1 root xiaoming 16 2月 17 17:58 test1