Linux之文件权限

基本权限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
 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值