work 1

1、创建/guanli 目录,在/guanli下创建zonghe 和 jishu 两个目录(一条命令)
 
mkdir -p /guanli/zonghe && mkdir -p /guanli/jishu
 
2、添加组帐号zonghe、caiwu、jishu,GID号分别设置为2001、2002、2003
 
groupadd -g 2001 zonghe && groupadd -g 2002 caiwu && groupadd -g 2003 jishu
 
3、创建jerry、kylin、tsengia、obama用户,其中的kylin用户帐号在2020年12月30日后失效
 
 useradd jerry && useradd -e 2020.12.30 kylin && useradd obama
 
4、将jerry、kylin、tsengia、obama等用户添加到zonghe组内
 
gpasswd -a jerry zonghe  gpasswd -a kylin  zonghe gpasswd -a tsengia  zonghe gpasswd -a obama  zonghe
 
5、创建handy、cucci用户,其中cucci帐号的登录Shell设置为“/sbin/nologin”
 
useradd handy && useradd -s /sbin/nlogin cucci
 
6、将handy、cucci等用户添加到jishu组内
 
gpasswd -a handy jishu && gpasswd -a cucci jishu
 
7、将上述的所有用户均要求加入到guanli组内
 
gpasswd -a handy guanli && gpasswd -a cucci guanli && gpasswd  -a jerry guanli && gpasswd -a kylin guanli && gpasswd -a tsengia guanli && gpasswd -a obama guanli
 
8、将zonghe组内的obama用户删除

userdel obama
 
9、为jerry用户设置密码为“123456”(使用普通方法)
   为cucci用户设置密码为“redhat”(使用--stdin方法) 

echo "123456" | passwd --stdin jerry
echo "redhat" | passwd --stdin cucci
 
10、将jerry用户锁定,并查看锁定状态
 
 passwd -l jerry
锁定用户 jerry 的密码 。
 
11、打开两个xshell窗口,通过(who 或者 w)命令查看连接状态,并通过fuser杀掉其中一个
 
[root@localhost ~]# w
 10:25:56 up 49 min,  4 users,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     :0       :0               09:37   ?xdm?  53.26s  0.17s gdm-session-worker [pam/gdm-password]
root     pts/0    :0               09:37   48:16   0.06s  0.06s /bin/bash
root     pts/1    192.168.100.166  09:38    4.00s  0.29s  0.04s w
root     pts/2    192.168.100.166  10:22    3:37   0.04s  0.04s -bash
[root@localhost ~]# fuser -k /dev/pts/2
/dev/pts/2:           3444
 
12、查看cucci用户,属于那些组,并查看其详细信息
 
groups cucci  finger cucci
13、手工创建账号student
 [root@localhost ~]# echo "student:x:1007:1007::/home/student:/bin/bnsh">> /etc/passwd && echo "student::18107:0:99999:7:::" >> /etc/shadow echo "student:x:1007:student" >> /etc/group && cp /etc/skel/.bash* /home/student
[root@localhost ~]# tail -1 /etc/passwd && tail -1 /etc/shadow && tail -1 /etc/group
student:x:1007:1007::/home/student:/bin/bnsh
cucci:$6$QrHcO4kz$0q2SeJ7MnH/XHRj1yJz3I5gDYs9LzvOFA2/P.S3iTaQDG.naAa7C/2BddDJ0e.O.fkU9jfvNbwsRglOLUeFuY/:18107:0:99999:7:::
student::18107:0:99999:7::: echo student:x:1007:student

14、设置权限及归属:
 
   /guanli目录属组设为guanli
   /guanli/zonghe目录的属组设为zonghe
   /guanli/jishu目录的属组设为jishu
   设置3个目录都是禁止其他用户访问的权限
[root@localhost ~]# chown :guanli /guanli && chmod  o=000 /guanli 
[root@localhost ~]# chown :zonghe /guanli/zonghe && chmod -R o= 000 /guanli/zonghe
[root@localhost ~]# chown :jishu /guanli/jishu && chmod -R 0=000 /guanli/jishu
 
15、建立公共目录/ceshi
   允许技术组内的所有用户读取、写入、执行文件
   禁止其他用户读、写、执行

[root@localhost ~]# mkdir /ceshi
[root@localhost ~]# setfacl -m g:jishu:rwx /ceshi
 
16、清除jerry用户密码
 
[root@localhost ~]# passwd -d jerry
清除用户的密码 jerry。
 
17、锁定cucci用户密码并查看状态
 
root@localhost ~]# passwd -l cucci
锁定用户 cucci 的密码 。
root@localhost ~]# passwd -S cucci
cucci LK 2019-07-30 0 99999 7 -1 (密码已被锁定。
18、修改obama用户的UID为8888
 
usermod -u 8888 obama
 
19、通过passwd命令修改kylin用户的最长密码使用期限为60天
 
[root@localhost ~]# passwd -x 60 kylin
 
20、通过id groups finger等命令查看用户handy信息
 
[root@localhost ~]# id handy
uid=1007(handy) gid=1007(handy) 组=1007(handy),2003(jishu),2006(guanli)
[root@localhost ~]# groups handy
handy : handy jishu guanli
[root@localhost ~]# finger handy
Login: handy             Name:
Directory: /home/handy               Shell: /bin/bash
Never logged in.
No mail.
No Plan.

猜你喜欢

转载自www.cnblogs.com/zhangjiaqi19990423/p/11271403.html