学习目标:
- 实验
- 实验需求
- 实验需求分析
- 实验配置内容 (每一个设备的每一步操作)
- 实验结果验证
学习内容:
- 实验
- 实验需求
- 实验需求分析
- 实验配置内容 (每一个设备的每一步操作)
- 实验结果验证
目录
1.实验
1Sticky Bit
2 SGID (Set GID)
3 SUID (Set UID)
4. chmod
5.ACL
6.chown
2.实验需求
图+操作
3.实验分析
粘制位(Sticky Bit)、`sgid`(Set Group ID)和`setuid`(Set User ID)是Linux系统中用于控制文件和目录权限的特殊权限。
1. 粘制位(Sticky Bit):
- 粘制位只能针对目录设置,用于控制目录中的文件只能被文件所有者删除。
- 如果一个目录开启了粘制位,那么这个目录中的文件只能被文件所有者删除,即使其他用户有写权限。
- 粘制位在权限表示中用`t`表示,例如`rwxrwxrwt`。2. `sgid`(Set Group ID):
- `sgid`用于设置文件或目录的组ID,使得文件或目录的执行者以文件或目录的组身份运行。
- 如果一个文件开启了`sgid`,那么文件执行者将以文件所属的组身份运行,而不是以自己的组身份运行。
- `sgid`在权限表示中用`s`表示,例如`rwxr-sr-x`。3. `setuid`(Set User ID):
- `setuid`用于设置文件的用户ID,使得文件执行者以文件所有者的身份运行。
- 如果一个文件开启了`setuid`,那么文件执行者将以文件所有者的身份运行,而不是以自己的身份运行。
- `setuid`在权限表示中用`s`表示,例如`rwsr-xr-x`。这些特殊权限可以帮助我们更好地控制文件和目录的访问权限,提高系统的安全性。
- 系统范围的配置文件
/etc/profile
和/etc/bashrc
,并设置了umask
为 700。- 使用
source
命令重新加载这些配置文件,使得设置立即生效。
- 创建了一个目录
/mnt/timinglee
,并添加了一个新用户admin
。- 使用
setfacl
命令设置了该目录的 ACL,包括用户、组、默认 ACL 和掩码。- 还使用
watch
命令监控了目录和 ACL 的变化,以确保设置生效。
下面有说明 概念
4.实验配置内容 (每一个设备的每一步操作)
1Sticky Bit
Sticky Bit
watch -n 1 "ls -ld /pub;ls -l /pub"
mkdir /pub
chmod 777 /pub
useradd lee (userdel -r lee)
useradd timinglee (userdel -r timinglee)
su - lee
touch /pub/leefile
exit
su - timinglee
touch /pub/timingleefile
exit
su - root
chmod 1777 /pub
(chmod o+t /pub)
su - lee --------> touch /pub/leefile
rm -fr /pub/leefile
rm -fr /pub/timingleefile
rm: cannot remove 'timingleefile': Operation not permitted
2 SGID(Set GID)
SGID(Set GID)
su - root
mkdir /sc
groupadd shengchan
chgrp shengchan /sc
watch -n 1 "ls -ld /sc;ls -l /sc"
id haha--监控
useradd haha
usermod -G shengchan haha
touch /sc/hahafile
su - haha
exit
chmod 2770 /sc
touch /sc/hahafile2
su - haha
exit
watch -n 1 "ps ax -o user,group,command | grep cat ;ls -l /bin/cat"
su - haha
/bin/cat
exit
chmod g+s /bin/cat【chmod 2755 /bin/cat】
su - haha
/bin/cat
exit
3 SUID(Set UID)
SUID(Set UID)
watch -n 1 "ps ax -o user,group,command | grep cat ;ls -l /bin/cat"
chmod u+s /bin/cat【chmod 4755 /bin/cat】
chmod 6755 /bin/cat--2个s"-sr"【chmod ug+s】
【chmod ug+s /usr/sbin/useradd /usr/sbin/userdel】
4.chmod
chmod
vim /etc/profile
umask 700
vim /etc/bashrc
/umask
umask 700
source /etc/bashrc
source /etc/profile
5.ACL
mkdir /mnt/timinglee
watch -n 1 ls -lR /mnt/
useradd admin
id admin
setfacl -m u:admin:rwx /mnt/timinglee/
watch -n 1 "Is -lR /mnt/;getfacl /mnt/timinglee"
getfacl /mnt/timinglee/
setfacl -b /mnt/timinglee/
setfacl -m u:admin:rwx /mnt/timinglee/
setfacl -m g:root:0 /mnt/timinglee/
setfacl -m m::rwx /mnt/timinglee/
setfacl -m u::rwx /mnt/timinglee/
setfacl -m g::rwx /mnt/timinglee/
setfacl -x g:root /mnt/timinglee/
setfacl -x u:admin /mnt/timinglee/
6.chown
watch -n 1ls -lR /mnt/
chown lee lee1
chown lee nn/
username file
chown root nn/
chown -R root nn
chgrp lee lee1
chgrp lee timinglee
chgrp -R lee timinglee
chown -R root.root timinglee/
chown lee:lee lee2
chown caiwu.caiwu caiwu/
5.实验结果验证
1Sticky Bit
2.SGID(Set GID)
3 SUID(Set UID)
4.chmod
5.ACL
6.chown
学习时间:
学习时间为学习时间
学习时间 | 筋肉人 |
为学习时间 | future |
学习产出:
- 技术笔记 1遍
- 有错误请指出,作者会及时改正