一、建立/guanli 目錄,在/guanli下建立zonghe 和 jishu 兩個目錄(一條命令)
[root@localhost ~]# mkdir -p /guanli/zonghe |mkdir -p /guanli/jishu
二、添加組賬號zonghe、caiwu、jishu,GID號分別設置爲200一、200二、2003
[root@localhost ~]# groupadd -g 2001 zonghe
[root@localhost ~]# groupadd -g 2002 caiwu
[root@localhost ~]# groupadd -g 2003 jishu
三、建立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
四、將jerry、kylin、tsengia、obama等用戶添加到zonghe組內
[root@localhost ~]# gpasswd -M jerry,kylin,tsengia,obama zonghe
五、建立handy、cucci用戶,其中cucci賬號的登陸Shell設置爲「/sbin/nologin」
[root@localhost ~]# useradd handy
[root@localhost ~]# useradd -s /sbin/nologin cucci
六、將handy、cucci等用戶添加到jishu組內
[root@localhost ~]# gpasswd -M handy,cucci jishu
七、將上述的全部用戶均要求加入到guanli組內
[root@localhost ~]# groupadd guanli
[root@localhost ~]# gpasswd -M jerry,kylin,tsengia,obama,handy,cucci guanli
八、將zonghe組內的obama用戶刪除
[root@localhost ~]# gpasswd -d obama zonghe
正在將用戶「obama」從「zonghe」組中刪除
九、爲jerry用戶設置密碼爲「123456」(使用普通方法)
爲cucci用戶設置密碼爲「redhat」(使用--stdin方法)
[root@localhost ~]# passwd jerry
更改用戶 jerry 的密碼 。
新的 密碼:
無效的密碼: 密碼少於 8 個字符
從新輸入新的 密碼:
passwd:全部的身份驗證令牌已經成功更新。
[root@localhost ~]# echo "redhat" | passwd --stdin cucci
更改用戶 cucci 的密碼 。
passwd:全部的身份驗證令牌已經成功更新。
十、將jerry用戶鎖定,並查看鎖定狀態
[root@localhost ~]# passwd -l jerry
鎖定用戶 jerry 的密碼 。
passwd: 操做成功
[root@localhost ~]# passwd -S jerry
jerry LK 2019-07-30 0 99999 7 -1 (密碼已被鎖定。)
十一、打開兩個xshell窗口,經過(who 或者 w)命令查看鏈接狀態,並經過fuser殺掉其中一個
十二、查看cucci用戶,屬於那些組,並查看其詳細信息
[root@localhost ~]# groups cucci
cucci : cucci jishu guanli
[root@localhost ~]# finger cucci
Login: cucci Name:
Directory: /home/cucci Shell: /sbin/nologin
Never logged in.
No mail.
No Plan.
1三、手工建立帳號student
[root@localhost ~]# useradd student
1四、設置權限及歸屬:
/guanli目錄屬組設爲guanli
/guanli/zonghe目錄的屬組設爲zonghe
/guanli/jishu目錄的屬組設爲jishu
設置3個目錄都是禁止其餘用戶訪問的權限
[root@localhost ~]# chown .guanli /guanli
[root@localhost ~]# chown .zonghe /guanli/zonghe/
[root@localhost ~]# chown .jishu /guanli/jishu/
[root@localhost ~]# chmod -R a-r /guanli
[root@localhost ~]# ls -l /guanli/
總用量 0
d-wx--x--x. 2 root jishu 6 7月 30 09:40 jishu
d-wx--x--x. 2 root zonghe 6 7月 30 09:40 zonghe
[root@localhost ~]# ll -d /guanli/
d-wx--x--x. 4 root guanli 33 7月 30 09:40 /guanli/
1五、創建公共目錄/ceshi
容許技術組內的全部用戶讀取、寫入、執行文件
禁止其餘用戶讀、寫、執行
[root@localhost ~]# mkdir /ceshi
[root@localhost ~]# chown .jishu /ceshi/
[root@localhost ~]# chmod 770 /ceshi/
[root@localhost ~]# ll -d /ceshi/
drwxrwx---. 2 root jishu 6 7月 30 10:30 /ceshi/
1六、清除jerry用戶密碼
[root@localhost ~]# passwd -d jerry
清除用戶的密碼 jerry。
passwd: 操做成功
1七、鎖定cucci用戶密碼並查看狀態
[root@localhost ~]# passwd -l cucci
鎖定用戶 cucci 的密碼 。
passwd: 操做成功
[root@localhost ~]# passwd -S cucci
cucci LK 2019-07-30 0 99999 7 -1 (密碼已被鎖定。)
1八、修改obama用戶的UID爲8888
[root@localhost ~]# usermod -u 8888 obama
[root@localhost ~]# cat /etc/passwd | grep "obama"
obama:x:8888:1007::/home/obama:/bin/bash
1九、經過passwd命令修改kylin用戶的最長密碼使用期限爲60天
[root@localhost ~]# passwd -x 60 kylin
調整用戶密碼老化數據kylin。
passwd: 操做成功
[root@localhost ~]# cat /etc/shadow | grep "kylin"
kylin:!!:18107:0:60:7::18626:
20、經過id groups finger等命令查看用戶handy信息
[root@localhost ~]# id handy uid=1008(handy) gid=1008(handy) 組=1008(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.