Chapter6

1、创建/guanli 目录,在/guanli下创建zonghe jishu 两个目录(一条命令)

[root@localhost /]# mkdir -pv /guanli/{zonghe,jishu}

mkdir: 已创建目录 "/guanli"

mkdir: 已创建目录 "/guanli/zonghe"

mkdir: 已创建目录 "/guanli/jishu"

2、添加组帐号zonghecaiwujishuGID号分别设置为200120022003

[root@localhost /]# groupadd -g 2001 zonghe

[root@localhost /]# groupadd -g 2002 caiwu

[root@localhost /]# groupadd -g 2003 jishu

3、创建jerrykylintsengiaobama用户,其中的kylin用户帐号在20201230日后失效

[root@localhost /]# useradd jerry

[root@localhost /]# useradd -e 2020-12-30 kylin

[root@localhost /]# useradd tsengin

[root@localhost /]# useradd obama

[root@localhost /]# tail -4 /etc/passwd

jerry:x:1003:1003::/home/jerry:/bin/bash

kylin:x:1004:2004::/home/kylin:/bin/bash

tsengin:x:1005:2005::/home/tsengin:/bin/bash

obama:x:1006:1006::/home/obama:/bin/bash

4、将jerrykylintsengiaobama等用户添加到zonghe组内

[root@localhost /]# gpasswd -M jerry,kylin,obama,tsengia zonghe

5、创建handycucci用户,其中cucci帐号的登录Shell设置为“/sbin/nologin

[root@localhost /]# useradd -s /sbin/nologin cucci

[root@localhost /]# useradd handy

6、将handycucci等用户添加到jishu组内

[root@localhost /]# gpasswd -M handy,cucci jishu

 

7、将上述的所有用户均要求加入到guanli组内

[root@localhost /]# groupadd guanli

[root@localhost /]# gpasswd -M jerry,kylin,tsengia,obama,handy,cucci guanli

8、将zonghe组内的obama用户删除

[root@localhost /]# gpasswd -d obama zonghe

9、为jerry用户设置密码为“123456”(使用普通方法)

   cucci用户设置密码为“redhat”(使用--stdin方法)  

[root@localhost /]# passwd jerry

更改用户 jerry 的密码 。

新的 密码:

无效的密码: 密码少于 8 个字符

重新输入新的 密码:

passwd:所有的身份验证令牌已经成功更新。   

[root@localhost /]# echo "redhat"|passwd --stdin cucci

更改用户 cucci 的密码 。

passwd:所有的身份验证令牌已经成功更新。

10、将jerry用户锁定,并查看锁定状态

[root@localhost /]# passwd -l jerry

锁定用户 jerry 的密码 。

passwd: 操作成功

[root@localhost /]# passwd -S jerry

jerry LK 2019-07-30 0 99999 7 -1 (密码已被锁定。)

11、打开两个xshell窗口,通过(who 或者 w)命令查看连接状态,并通过fuser杀掉其中一个

[root@localhost /]# w

 10:24:43 up  2:02,  3 users,  load average: 0.03, 0.02, 0.05

USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT

root     :0       :0               08:24   ?xdm?   1:12   0.28s /usr/libexec/gnome-session-binary --se

root     pts/0    192.168.100.103  08:25    3.00s  0.47s  0.02s w

root     pts/1    192.168.100.103  10:24   17.00s  0.05s  0.05s -bash

[root@localhost /]# fuser -k /dev/pts/1

/dev/pts/1:           4164

12、查看cucci用户,属于那些组,并查看其详细信息

[root@localhost /]# groups cucci

cucci : cucci jishu guanli

13、手工创建账号student

[root@localhost ~]# vi /etc/passwd

[root@localhost ~]# vi /etc/shadow

[root@localhost ~]# vi /etc/group

[root@localhost ~]# vi /etc/group

[root@localhost ~]# mkdir /home/qingqing

[root@localhost ~]# cp /etc/skel/.bash* /home/qingqing

[root@localhost ~]# su qingqing

14、设置权限及归属:

   /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 o-r /guanli

[root@localhost /]# ls -ld /guanli

drwxr-x--x. 4 root guanli 33 7月  30 09:48 /guanli

[root@localhost /]# ls -l /guanli

总用量 0

drwxr-x--x. 2 root jishu  6 7月  30 09:48 jishu

drwxr-x--x. 2 root zonghe 6 7月  30 09:48 zonghe

15、建立公共目录/ceshi

   允许技术组内的所有用户读取、写入、执行文件

   禁止其他用户读、写、执行

[root@localhost /]# mkdir /ceshi

[root@localhost /]# chown :jishu /ceshi

[root@localhost /]# chmod 770 /ceshi

[root@localhost /]# setfacl -m g:jishu:rwx /ceshi

[root@localhost /]# getfacl /ceshi

getfacl: Removing leading '/' from absolute path names

# file: ceshi

# owner: root

# group: jishu

user::rwx

group::rwx

group:jishu:rwx

mask::rwx

other::---

16、清除jerry用户密码    

[root@localhost /]# passwd -d jerry                        

17、锁定cucci用户密码并查看状态

[root@localhost /]# passwd -l cucci

锁定用户 cucci 的密码 。

passwd: 操作成功

[root@localhost /]# passwd -S cucci

cucci LK 2019-07-30 0 99999 7 -1 (密码已被锁定。)

[root@localhost /]#

18、修改obama用户的UID8888

[root@localhost /]# usermod -u 8888 obama

19、通过passwd命令修改kylin用户的最长密码使用期限为60

[root@localhost /]# passwd -x 60 kylin

调整用户密码老化数据kylin

passwd: 操作成功

[root@localhost /]#

20、通过id groups finger等命令查看用户handy信息

[root@localhost Packages]# id handy

uid=1009(handy) gid=1009(handy) =1009(handy),2003(jishu),2005(guanli)

 

[root@localhost Packages]# groups handy

handy : handy jishu guanli

 

[root@localhost Packages]# finger handy

Login: handy           Name:

Directory: /home/handy               Shell: /bin/bash

Never logged in.

No mail.

No Plan.

猜你喜欢

转载自www.cnblogs.com/qingqing1/p/11279025.html