7-27学习总结日记

一.基本权限ugo

1.权限的对象:

权限对象:

属主: u

属组: g

其他人: o

所有人:a(u+g+o)

2.权限类型

读 r=4

写 w=2

执行 x=1

3.查看权限记录

ls -l /root/1.txt

-rw-r–r--. 1 root root 179 5月 25 14:27 /root/1.txt

-文件类型

rw-主人的权限,属主

r–属组的权限,

r–其他人的权限

.权限的扩展

1文件链接(第七章文件链接)

root文件的属主

root文件的属组

179大小

5月 25 14:27文件最后的修改时间

/root/1.txt 文件的名和路径

4.设置权限

对一个写好程序的文件增加执行权,首先查看一下文件的权限

[root@localhost tmp]# ll file.txt

-rw-r–r-- 1 root root 83 7月 27 19:04 file.txt

对一个文件增加执行的权限

[root@localhost tmp]# chmod u+x file.txt

[root@localhost tmp]# ll file.txt

-rwxr–r-- 1 root root 83 7月 27 19:04 file.txt

进行测试

[root@localhost tmp]# ./file.txt

hello 2020

请输入姓名da

哈哈 da shuaidail

5.去除权限

[root@localhost tmp]# ll file.txt

-rwxr–r-- 1 root root 83 7月 27 19:04 file.txt

[root@localhost tmp]# chmod u-x file.txt

[root@localhost tmp]# ll file.txt

-rw-r–r-- 1 root root 83 7月 27 19:04 file.txt

接下来我们查看运行的结果:

[root@localhost tmp]# ./file.txt

-bash: ./file.txt: 权限不够

二.更改属主和属组

  1. chown: 设置一个文件属于谁,属主

语法: chown 用户名.组名 文件

[root@localhost tmp]# ll file.txt

-rw-r–r-- 1 root root 83 7月 27 19:04 file.txt

[root@localhost tmp]# chown user11.jishuzu file.txt

[root@localhost tmp]# ll file.txt

-rwxr–r-- 1 user11 jishuzu 83 7月 27 19:04 file.txt

当在chown后面加上-R时,是针对目录中的所有文件。

2.chgrp命令

语法:chgrp 组名 文件 -R是递归的意思

[root@localhost ~]# chgrp it file1 //改文件属组

[root@localhost ~]# chgrp -R it dir1 //改文件属组

三.基本权限acl

1.acl和ugo的区别

ACL文件权限管理:设置不同用户,不同的基本权限(r、w、x)。对象数量

不同。

UGO设置基本权限: 只能一个用户,一个组和其他人

下面是整个操作过程:

[root@localhost ~]# touch /home/file.txt //建立新的文件夹

[root@localhost ~]# cd /home //移到路径为home的文件夹当中

[root@localhost home]# ls // 查看当前位置当中有什么

chenzhihao user00 user22 xiaochen

file.txt user11 user33

[root@localhost home]# vim file.txt //对file.txt进行写入内容

[root@localhost home]# ll file.txt //查看文件的基本权限

-rw-r–r-- 1 root root 43 7月 27 19:33 file.txt

[root@localhost home]# getfacl file.txt

# file: file.txt // 文件名

# owner: root //属主:root

# group: root // 属组:root

user::rw- //用户

group::r-- //组

other::r-- //其他人

[root@localhost home]# setfacl -m u:user11:rw file.txt //给用户

读写的权限

[root@localhost home]# tail -5 /etc/group

user11❌1002:

user22❌1003:

user33❌1004:

user00❌1005:

jishuzu❌1006:

[root@localhost home]# su - user11 切换用户

上一次登录:一 7月 27 10:13:57 CST 2020pts/0 上

[user11@localhost ~]$ cat /home/file.txt 查看文件

sdsjdfskfjdcnldfjsklsdl

dasda

dasd

asd

[user11@localhost ~]$ vi /home/file.txt 编辑文件

[user11@localhost ~]$ cat /home/file.txt 查看文件

sdsjdfskfjdcnldfjsklsdl

dasda

dasd

asd

12345

[user11@localhost ~]$ exit 退出当前用户

登出

[root@localhost home]# setfacl -m u:user00:- file.txt 去除权限

[root@localhost home]# su - user00 切换用户

上一次登录:一 7月 27 16:32:01 CST 2020pts/1 上

[user00@localhost ~]$ cat /home/file.txt

cat: /home/file.txt: 权限不够

[root@localhost ~]# setfacl -m g:hr:r /home/test.txt//给予组读的

权限

[root@localhost ~]# setfacl -x g:hr /home/test.txt//删除组hr的acl

权限

[root@localhost ~]# setfacl -b /home/test.txt//删除所有acl权限

2.特殊权限

设置suid,使普通用户通过suid临时提权,查看超管root用户的文件

[root@localhost home]# chmod u+s /usr/bin/cat

[root@localhost home]# ll /usr/bin/cat

-rwsr-xr-x. 1 root root 54080 8月 20 2019 /usr/bin/cat

[root@localhost home]# su - user00

上一次登录:一 7月 27 19:41:28 CST 2020pts/0 上

[user00@localhost ~]$ ll /root/1.txt

ls: 无法访问/root/1.txt: 权限不够

[user00@localhost ~]$ ll /root/file.txt

ls: 无法访问/root/file.txt: 权限不够

[user00@localhost ~]$ cat /root/file.txt

cat: /root/file.txt: 没有那个文件或目录

[user00@localhost ~]$ exit

登出

[root@localhost home]# cd ~

[root@localhost ~]# ll

总用量 4

-rw-r–r-- 1 root root 0 7月 27 08:46 1.txt

-rw-------. 1 root root 1418 7月 25 13:53 anaconda-ks.cfg

drwxr-xr-x 2 root root 6 7月 27 08:49 dir1

[root@localhost ~]# su - user11

上一次登录:一 7月 27 19:38:39 CST 2020pts/0 上

[user11@localhost ~]$ cat /root/1.txt

[user11@localhost ~]$ exit

登出

[root@localhost ~]# chmod u-s /usr/bin/cat

[root@localhost ~]# ll /usr/bin/cat

-rwxr-xr-x. 1 root root 54080 8月 20 2019 /usr/bin/cat

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值