Linex Chapter III Chapter IV

1. Create / guanli directory, create two directories zonghe and jishu (a command) in / guanli
[Root @ localhost ~] # mkdir -p / guanli / zonghe | mkdir -p / guanli / jishu
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
3. Create jerry, kylin, tsengia, obama user, which kylin user account expire after 30 December 2020
[root@localhost ~]# useradd jerry
[root@localhost ~]# useradd -e 2020-12-30 kylin
[root@localhost ~]# useradd tsengia
[root@localhost ~]# useradd obama
4, adding jerry, kylin, tsengia, obama other users into groups zonghe
[root@localhost ~]# gpasswd -M jerry,kylin,tsengia,obama zonghe
5, create a handy, cucci users, cucci account login Shell is set to "/ sbin / nologin"
[root@localhost ~]# useradd handy
[root@localhost ~]# useradd  -s /sbin/nologin cucci
6, adding handy, cucci other users into groups jishu
[root@localhost ~]# gpasswd -M handy,cucci jishu
7, all users are required to be added to the aforementioned group within guanli
[root@localhost ~]# groupadd guanli
[root@localhost ~]# gpasswd -M jerry,kylin,tsengia,obama,handy,cucci guanli
8, obama users in zonghe group deleted
[root @ localhost ~] # gpasswd -d obama zonghe
is the user "obama" delete from "zonghe" group
9, set a password for the user jerry is "123456" (using conventional methods)
   to set a password to "RedHat" (using the method --stdin) to users cucci 
[root @ localhost ~] # passwd jerry
change a user's password jerry.
The 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
change a user's password cucci.
passwd: all authentication tokens have been successfully updated.
10, the jerry user to lock and view the locked state
[root @ localhost ~] # passwd -l jerry
locked jerry user's password.
passwd: Operation Success
[the root @ localhost ~] # the passwd -S Jerry
Jerry 2019-07-30 LK -1 0 99999. 7 (password is locked.)
11, two xshell open windows, by (who or w) command to check the connection status, and wherein through a fuser kill
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
Login: cucci             Name:
Directory: /home/cucci               Shell: /sbin/nologin
Never logged in.
No mail.
No Plan.
13, manually create an account student
[root@localhost ~]# useradd student
14, set permissions and ownership:
   / guanli directory is a group set guanli
   is a group / guanli / zonghe directory to Zonghe
   / guanli / directory is a group jishu set jishu
   set up three directories are prohibited other user access rights
[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/

15, to establish a public directory / ceshi
   allow all users in the technical group read, write, execute the file
   prohibit other users to read, write, execute
[the root @ localhost ~] # mkdir / ceshi
[the root @ localhost ~] # chown .jishu / ceshi /
[the root @ localhost ~] # the chmod 770 / ceshi /
[the root @ localhost ~] -d # LL / ceshi /
drwxrwx- -. 2 root jishu 6 7 Yue 30 10:30 / ceshi /

16, clear the user password jerry
[root @ localhost ~] # passwd -d jerry
clear a user's password jerry.
passwd: Successful operation

17, locking the user's password and view the status cucci
[root @ localhost ~] # passwd -l cucci
locked cucci user's password.
passwd: Operation Success
[the root @ localhost ~] # CUCCI the passwd -S
CUCCI LK 2019-07-30 99999 0 -1. 7 (password is locked.)

18, the user's UID is modified obama 8888
[root@localhost ~]# usermod -u 8888 obama
[root@localhost ~]# cat /etc/passwd | grep "obama"
obama:x:8888:1007::/home/obama:/bin/bash
19, kylin modify the user's password by using the passwd command a maximum period of 60 days
[root @ localhost ~] # passwd -x 60 kylin
of the user password aging data kylin.
passwd: successful operation
[root @ localhost ~] # CAT / etc / Shadow | grep "Kylin"
Kylin: !!: 18107: 0: 60: 7 :: 18626:
20, see the user handy information id groups finger commands
[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.

Guess you like

Origin www.cnblogs.com/shao123-/p/11278755.html