2019.7.31 第四章节权限与项目管理 作业!作业!作业!

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


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


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

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

[root@localhost ~]# useradd jeryy
[root@localhost ~]# useradd -e 2020-12-30 kylix
[root@localhost ~]# useradd tsengia
[root@localhost ~]# useradd obama

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


[root@localhost ~]# gpasswd -M jeryy,kylix,tsengia,obama zonghe //因为里面是空的所有用-M,如果里面有用户,只能用-a
[root@localhost ~]#


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 -a handy jishu
正在将用户“handy”加入到“jishu”组中
[root@localhost ~]# gpasswd -a cucci jishu
正在将用户“cucci”加入到“jishu”组中


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

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

8、将zonghe组内的obama用户删除
[root@localhost ~]# vi /etc/group //查看所有用户的归属组和用户

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

9、为jerry用户设置密码为“123456”(使用普通方法)
[root@localhost ~]# passwd jeryy
更改用户 jeryy 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@localhost ~]#

为cucci用户设置密码为“redhat”(使用--stdin方法)
[root@localhost ~]# echo "redhat"|passwd --stdin cucci
更改用户 cucci 的密码 。
passwd:所有的身份验证令牌已经成功更新。

10、将jerry用户锁定,并查看锁定状态
[root@localhost ~]# passwd -l jeryy
锁定用户 jeryy 的密码 。

passwd: 操作成功
[root@localhost ~]# passwd -S jeryy
jeryy LK 2019-07-31 0 99999 7 -1 (密码已被锁定。)

11、打开两个xshell窗口,通过(who 或者 w)命令查看连接状态,并通过fuser杀掉其中一个
[root@localhost ~]# fuser -k /dev/pts/5
/dev/pts/5: 50421


12、查看cucci用户,属于那些组,并查看其详细信息
[root@localhost ~]# groups cucci
cucci : cucci jishu guanli

//先创建yum仓库

[root@localhost ~]# yum -y install lynx


13、手工创建账号student
[root@localhost ~]# vi /etc/passwd //进去手动创建

[root@localhost ~]# tail /etc/passwd //然后在查看

14、设置权限及归属:
/guanli目录属组设为guanli
[root@localhost ~]# chown :guanli /guanli //设置

[root@localhost ~]# ls -ld /guanli //查看
drwxr-xr-x. 4 root guanli 33 7月 31 10:27 /guanli

/guanli/zonghe目录的属组设为zonghe

[root@localhost ~]# chown :zonghe /guanli/zonghe/ //设置
[root@localhost ~]# ls -ld /guanli/zonghe/
drwxr-xr-x. 2 root zonghe 6 7月 31 10:27 /guanli/zonghe/ //查看

/guanli/jishu目录的属组设为jishu

[root@localhost ~]# chown :jishu /guanli/jishu/
[root@localhost ~]# ls -ld /guanli/jishu/
drwxr-xr-x. 2 root jishu 6 7月 31 10:27 /guanli/jishu/

设置3个目录都是禁止其他用户访问的权限

15、建立公共目录/ceshi
允许技术组内的所有用户读取、写入、执行文件
禁止其他用户读、写、执行
[root@likun ~]# setfacl -m g:jishu:rwx /ceshi

[root@likun ~]# chmod 770 /ceshi


16、清除jerry用户密码

[root@localhost ~]# passwd -d jeryy
清除用户的密码 jeryy。
passwd: 操作成功

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

[root@localhost ~]# passwd -l cucci
锁定用户 cucci 的密码 。
passwd: 操作成功
[root@localhost ~]# passwd -S cucci

cucci LK 2019-07-31 0 99999 7 -1 (密码已被锁定。)

18、修改obama用户的UID为8888

useradd //初始创建时可以修改,创建好了用usermod
[root@localhost ~]# usermod -u 8888 obama

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

[root@localhost ~]# passwd -x 60 kylix
调整用户密码老化数据kylix。
passwd: 操作成功

20、通过id groups finger等命令查看用户handy信息
[root@localhost ~]# id handy
uid=1005(handy) gid=1005(handy) 组=1005(handy),2003(jishu),2004(guanli)

[root@localhost ~]# groups handy
handy : handy jishu guanli

[root@localhost ~]# finger handy

猜你喜欢

转载自www.cnblogs.com/otherwise/p/11280302.html