Chapter04 practice

1. Create / guanli directory, create two directories zonghe and jishu (a command) in / guanli
[root @ localhost ~] # mkdir -pv / guanli / zonghe && mkdir -pv / guanli / jishu
mkdir: directory has been created. " / guanli "
mkdir: directory has been created" / guanli / Zonghe "
mkdir: directory has been created" / guanli / jishu "

2, add a group account zonghe, caiwu, jishu, GID numbers are set to 2001,2002,2003
[root @ localhost ~] # groupadd -g 2001 groupadd -g 2002 caiwu Zonghe && && groupadd -g 2003. Journal
[root @ localhost ~] -3 tail # / etc / Group
Zonghe: the X-: 2001:
caiwu: the X-: 2002:
. Journal: the X-: 2003:

3. Create jerry, kylin, tsengia, obama user, which kylin user account failure in December 2020 after 30
[root @ localhost ~] # useradd Jerry
[root @ localhost ~] # useradd -e 2020-12-30 kylin
[the root @ localhost ~] # the useradd tsengia
[the root @ localhost ~] # the useradd Obama

4, adding jerry, kylin, tsengia, obama Zonghe into other user groups
[the root @ localhost ~] # the gpasswd -M jerry, kylin, tsengia, obama Zonghe
[the root @ localhost ~] # tail -10 / etc / Group
Test3 : the X-: 1003:
Zonghe: the X-: 2001: Jerry, Kylin, tsengia, obama
caiwu: the X-: 2002:
. Journal: the X-: 2003:
Jerry: the X-: 1011:
Kylin: the X-: 1012:
tsengia: the X-: 1013:
obama: x: 1014:

5, creating Handy, cucci user, wherein cucci Shell login account is set to "/ sbin / nologin"
[the root @ localhost ~] # the useradd Handy && the useradd -s / sbin / nologin cucci
[the root @ localhost ~] # tail -2 / etc / the passwd
Handy: X: 1015: 1015 :: / Home / Handy: / bin / the bash
CUCCI: X: 1016: 1016 :: / Home / CUCCI: / sbin / nologin

6, adding handy, cucci into other user groups. Journal
[the root @ localhost ~] # the gpasswd -M handy, cucci. Journal
[the root @ localhost ~] # tail -2 / etc / Group
Handy: X: 1015:
CUCCI: X : 1016:
7, will require all users, the group added to the guanli
[the root @ localhost ~] # Jerry the gpasswd -M, Kylin, tsengia, Obama, Handy, CUCCI guanli
[the root @ localhost ~] # tail -1 / etc / group
guanli: the X-: 2004: Jerry, Kylin, tsengia, obama, Handy, CUCCI
8, the obama users in zonghe group delete
[root @ localhost ~] # gpasswd -d obama zonghe
is the user "obama" from " Zonghe "delete group
[the root @ localhost ~] # tail -10 / etc / group
Zonghe: X: 2001: jerry, Kylin, tsengia
. 9, jerry set a password for the user is" 123456 "(using conventional methods)
to the user cucci the password is "redhat" (use --stdin method)
[root @ localhost ~] # passwd jerry
change a user's password jerry.
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
[the root @ localhost ~] # WHO
the root: 2019-07-30 12:27 0 (: 0)
the root PTS / 2019-07-30. 1 12:28 (192.168.100.148)
the root PTS / 2 2019-07-30 12:28 (192.168.100.148)
[the root @ localhost ~] # the fuser -k / dev / PTS /. 1
/ dev / pts / 1: 2363

12, view cucci users belonging to those groups, and view its details
[the root @ localhost ~] # Groups cucci
cucci: cucci Guanli [
[the root @ localhost ~] # finger cucci
the Login: cucci the Name:
Directory: / Home / cucci Shell: / sbin / nologin
. Never logged in
. No mail
. No Plan
13, manually create accounts Student
[root @ localhost ~] # vi / etc / passwd
1 root: the X-: 0: 0: root: / root: / bin / bash
2 bin: X:. 1:. 1: bin: / bin: / sbin / nologin
. 3 daemon: X: 2: 2: daemon: / sbin: / sbin / nologin
. 4 ADM: X:. 3:. 4: ADM: / var / ADM: / sbin / nologin
. 5 LP: X:. 4:. 7: LP: / var / spool / LPD: / sbin / nologin
...
50 Handy: X: 1009: 1009 :: / Home / Handy: / bin / the bash
CUCCI 51 is: X: 1010: 1010 :: / Home / CUCCI: / sbin / nologin
52 is Student: X: 1000: 1000 :: / Home / Student: / bin / the bash
"/etc/passwd" 52L, 2581C written

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
[ ~ @ localhost the root] # chown: Guanli [/ Guanli [
[the root @ localhost ~] # chown: Zonghe / Guanli [/ Zonghe
[the root @ localhost ~] # chown:. Journal / Guanli [/. Journal
[the root @ localhost ~] # or the chmod -R & lt / Guanli [
[the root @ localhost ~] -l # LS / Guanli [/
total amount of 0
drwxr-X - X 2. 6 the root. Journal 16:48. Journal July 30
drwxr-X - X 2. 6 Zonghe July 30, the root 16: Zonghe 48
[the root @ localhost ~] # LS -dl / Guanli [/
drwxr-X - X. 4 Guanli [33 is the root. 7 dated 30 16:48 / 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
[root @ localhost ~] # -mg the setfacl:. Journal: rwx / ceshi /
[root @ ~ localhost] # getfa
the getfacl getfattr
[the root @ localhost ~] # the getfacl / ceshi /
the getfacl: Removing leading '/' Absolute path names from
# File: ceshi /
# owner: the root
# Group: the root
User :: rwx
Group RX ::
Group:. Journal: rwx
mask :: rwx
OTHER RX ::
[the root @ localhost ~] # O-rwx the chmod / ceshi /
[the root @ localhost ~] # LS -dl / ceshi /
drwxrwx --- the root the root. 6. 7 + 2 19:25 May 30 / ceshi /
16, clear jerry user password
[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: Successful operation
[the root @ localhost ~] # CUCCI the passwd -S
CUCCI LK 2019-07-30 99999 0 -1. 7 (password is locked.)
18, to modify the user's UID obama 8888
[the root @ localhost ~] # CAT / etc / Shadow
Obama: X: 8888: 1014. :: / Home / Obama: / bin / the bash
. 19, modified by the user kylin passwd command maximum password age of 60 days
[root @ localhost ~] # grep kylin / etc / Shadow
Kylin: !!: 18107: 0: 60: 18626 ::. 7:

20, view the user handy information id groups finger commands
[the root @ localhost ~] # ID handy && Groups handy && finger handy
UID = 1015 (handy) GID = 1015 (handy) group = 1015 (handy), 2004 ( guanli)
Handy: Handy guanli
the Login: Handy the Name:
Directory: / Home / Handy Shell: / bin / bash
Never logged in.
No mail.
No Plan.

Guess you like

Origin www.cnblogs.com/sun0917/p/11272362.html