Linux 系统管理 05—权限及归属管理

1、创建/guanli 目录,在/guanli下创建zonghe 和 jishu 两个目录(一条命令)

[root@localhost ~]# mkdir -p /guanli/zonghe |mkdir -p /guanli/jishu

[root@localhost ~]# ls /guanli
jishu zonghe

2、添加组帐号zonghe、caiwu、jishu,GID号分别设置为2001、2002、2003

[root@localhost ~]# groupadd -g 2001 zonghe
[root@localhost ~]# groupadd -g 2002 caiwu

[root@localhost ~]# groupadd -g 2003 jishu

[root@localhost ~]# tail -5 /etc/group
tcpdump:x:72:
zxs:x:1000:
zonghe:x:2001:
caiwu:x:2002:
jishu:x:2003:

3、创建jerry、kylin、tsengia、obama用户,其中的kylin用户帐号在2020年12月30日后失效

[root@localhost ~]# useradd jerry

[root@localhost ~]# useradd -e 2020-12-30 kylin

[root@localhost ~]# useradd tsengia
[root@localhost ~]# useradd obama

[root@localhost ~]# tail -4 /etc/shadow
jerry:!!:18107:0:99999:7:::
tsengia:!!:18107:0:99999:7:::
obama:!!:18107:0:99999:7:::
kylin:!!:18107:0:99999:7::18626:

4、将jerry、kylin、tsengia、obama等用户添加到zonghe组内

[root@localhost ~]# gpasswd -M jerry,kylin,tsengia,obama zonghe

[root@localhost ~]# tail -10 /etc/group
stapdev:x:158:
tcpdump:x:72:
zxs:x:1000:
zonghe:x:2001:jerry,kylin,tsengia,obama
caiwu:x:2002:
jishu:x:2003:
jerry:x:1001:
tsengia:x:1003:
obama:x:1004:
kylin:x:1005:

5、创建handy、cucci用户,其中cucci帐号的登录Shell设置为“/sbin/nologin”

[root@localhost ~]# useradd handy
[root@localhost ~]# useradd -s /sbin/nologin cucci

6、将handy、cucci等用户添加到jishu组内

[root@localhost ~]# gpasswd -M handy,cucci jishu
[root@localhost ~]# tail -10 /etc/group
zxs:x:1000:
zonghe:x:2001:jerry,kylin,tsengia,obama
caiwu:x:2002:
jishu:x:2003:handy,cucci
jerry:x:1001:
tsengia:x:1003:
obama:x:1004:
kylin:x:1005:
handy:x:1006:
cucci:x:1007:

7、将上述的所有用户均要求加入到guanli组内

[root@localhost ~]# groupadd guanli
[root@localhost ~]# gpasswd -M jerry,kylin,tsengia,obama,handy,cucci guanli

8、将zonghe组内的obama用户删除

[root@localhost ~]# gpasswd -d obama zonghe
正在将用户“obama”从“zonghe”组中删除

9、为jerry用户设置密码为“123456”(使用普通方法)

为cucci用户设置密码为“redhat”(使用--stdin方法)

10、将jerry用户锁定,并查看锁定状态

11、打开两个xshell窗口,通过(who 或者 w)命令查看连接状态,并通过fuser杀掉其中一个

12、查看cucci用户,属于那些组,并查看其详细信息

13、手工创建账号student

14、设置权限及归属:
/guanli目录属组设为guanli
/guanli/zonghe目录的属组设为zonghe
/guanli/jishu目录的属组设为jishu
设置3个目录都是禁止其他用户访问的权限

15、建立公共目录/ceshi
允许技术组内的所有用户读取、写入、执行文件
禁止其他用户读、写、执行

16、清除jerry用户密码

17、锁定cucci用户密码并查看状态

18、修改obama用户的UID为8888

19、通过passwd命令修改kylin用户的最长密码使用期限为60天

20、通过id groups finger等命令查看用户handy信息

猜你喜欢

转载自www.cnblogs.com/wangjia120/p/11271169.html
今日推荐