1. Create / guanli directory, create two directories zonghe and jishu (a command) in / guanli
[root@localhost ~]# mkdir /guanli
[root@localhost ~]# cd /guanli
[Root @ localhost guanli] # mkdir zonghe jishu
[root@localhost guanli]# ls
jishu zonghe
2, add a group account zonghe, caiwu, jishu, GID numbers are set to 2001, 2002
[root@localhost ~]# groupadd -g 2001 zonghe
[root@localhost ~]# groupadd -g 2002 caiwu
[root@localhost ~]# groupadd -g 2003 jishu
[root@localhost ~]# tail -3 /etc/group
zonghe: x: 2001:
caiwu:x:2002:
jishu: x: 2003:
3. Create jerry, kylin, tsengia, obama user, which kylin user account expire after 30 December 2020
[root@localhost ~]# useradd jerry
[root@localhost ~]# useradd kylin -e 2020-12-30
[root@localhost ~]# useradd tsengia
[root@localhost ~]# useradd obanma
4, adding jerry, kylin, tsengia, obama other users into groups zonghe
[root@localhost ~]# gpasswd -a jerry zonghe
Is the user "jerry" added to "zonghe" group
[root@localhost ~]# gpasswd -a tsengia zonghe
The user is "tsengia" added to "zonghe" group
[root@localhost ~]# gpasswd -a kylin zonghe
The user is "kylin" added to "zonghe" group
[root@localhost ~]# gpasswd -a obama zonghe
The user is "obama" added to "zonghe" group
5, create a handy, cucci users, cucci account login Shell is set to "/ sbin / nologin"
[root@localhost ~]# useradd handy
[root@localhost ~]# useradd cucci -s /sbin/nologin
6, adding handy, cucci other users into groups jishu
[root@localhost ~]# gpasswd -a handy jishu
The user is "handy" added to "jishu" group
[root@localhost ~]# gpasswd -a cucci jishu
The user is "cucci" added to "jishu" group
7, all users are required to be added to the aforementioned group within guanli
[root@localhost ~]# groupadd guanli
[root@localhost ~]# gpasswd -a jerry guanli
Is the user "jerry" added to "guanli" group
[root@localhost ~]# gpasswd -a kylin guanli
The user is "kylin" added to "guanli" group
[root@localhost ~]# gpasswd -a tsengia guanli
The user is "tsengia" added to "guanli" group
[root@localhost ~]# gpasswd -a obama guanli
The user is "obama" added to "guanli" group
[root@localhost ~]# gpasswd -a handy guanli
The user is "handy" added to "guanli" group
[root@localhost ~]# gpasswd -a cucci guanli
The user is "cucci" added to "guanli" group
8, obama users in zonghe group deleted
[root@localhost ~]# gpasswd -d obama zonghe
The user is "obama" delete from "zonghe" group
9, set a password for the user jerry is "123456" (using conventional methods)
Cucci set a password for the user "redhat" (use --stdin method)
[root@localhost ~]# passwd jerry
Jerry change the user's password.
New Password:
Invalid Password: password less than eight characters
Re-enter the new password:
passwd: all authentication tokens have been successfully updated.
[root@localhost ~]# echo "redhat" |passwd --stdin cucci
Cucci change the user's password.
passwd: all authentication tokens have been successfully updated.
10, the jerry user to lock and view the locked state
[root@localhost ~]# passwd -l jerry
Jerry lock the user's password.
passwd: Successful operation
[root@localhost ~]# passwd -S jerry
jerry LK 2019-07-30 0 99999 7 -1 (password is locked.)
11, two xshell open windows, by (who or w) command to check the connection status, and wherein through a fuser kill
[root@localhost ~]# w
[root@localhost ~]# fuser -k /dev/pts/0
12, see cucci users belong to those groups, and to view its details
[root@localhost ~]# groups cucci
cucci: cucci jishu guanli
[root@localhost ~]# finger cucci
13, manually create an account student
[root@localhost ~]# vi /etc/passwd
[root@localhost ~]# tail -1 /etc/passwd
student:x:1008:1008::/home/student:/bin/bash
[root@localhost ~]# vi /etc/shadow
[root@localhost ~]# tail -1 /etc/shadow
student::18107:0:99999:7:::
[root@localhost ~]# vi /etc/group
[root@localhost ~]# tail -1 /etc/group
student:x:1008:
[root@localhost skel]# mkdir /home/student
[root@localhost skel]# ls -a |cp .b* /home/student/
[root@localhost skel]# cd /home/student/
14, set permissions and ownership:
/ Guanli directory is a group set guanli
Is a group / guanli / zonghe directory to zonghe
Is a group / guanli / jishu directory to jishu
Set up three directories are prohibited other user access rights
[Root @ localhost ~] # chown: guanli / guanli
[root@localhost ~]# chmod -R o-rwx /guanli
[Root @ localhost ~] # chown: zonghe / guanli- / zonghe
[root@localhost ~]# chmod -R o-rwx /guanli/zonghe
[Root @ localhost ~] # chown: jishu / guanli / jishu
[root@localhost ~]# chmod -R o-rwx /guanli/jishu
15, to establish a public directory / ceshi
Technology allows all users within the group of read, write, execute the file
Prohibit other users to read, write, execute
[root@localhost ~]# chmod g=rwx,o-rwx /ceshi
[Root @ localhost ~] # chown: jishu / ceshi
16, clear the user password jerry
[root@localhost ~]# passwd -d jerry
Clear user password jerry.
passwd: Successful operation
17, locking the user's password and view the status cucci
[root@localhost ~]# passwd -l cucci
Cucci lock the user's password.
passwd: Successful operation
[root@localhost ~]# passwd -S cucci
cucci LK 2019-07-30 0 99999 7 -1 (password is locked.)
18, the user's UID is modified obama 8888
[root@localhost ~]# usermod -u 8888 obama
19, kylin modify the user's password by using the passwd command a maximum period of 60 days
[root@localhost ~]# passwd -x 60 kylin
Adjust the user password aging data kylin.
passwd: Successful operation
[root@localhost ~]# grep kylin /etc/shadow
kylin:!!:18107:0:60:7::18626:
20, see the user handy information id groups finger commands
[root@localhost ~]# id handy
uid = 1005 (handy) gid = 1005 (handy) groups = 1005 (handy), 2003 (jishu), 2004 (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.