Or the owner is a group?

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.)
 
. 1 1 xshell two open windows, by (who or w) command to check the connection status, and wherein through a fuser kill
       fuser -k /dev/pts/2
 
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 o-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、建立公共目录/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/

16、清除jerry用户密码
[root@localhost ~]# passwd -d jerry
清除用户的密码 jerry。
passwd: 操作成功

17、锁定cucci用户密码并查看状态
[root@localhost ~]# passwd -l cucci
锁定用户 cucci 的密码 。
passwd: 操作成功
[root@localhost ~]# passwd -S cucci
cucci LK 2019-07-30 0 99999 7 -1 (密码已被锁定。)

18、修改obama用户的UID为8888
[root@localhost ~]# usermod -u 8888 obama
[root@localhost ~]# cat /etc/passwd | grep "obama"
obama:x:8888:1007::/home/obama:/bin/bash
 
19、通过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.

Guess you like

Origin www.cnblogs.com/WELLLEE/p/11279143.html