文章目录 14. Linux 用户 - 用户组管理 14.1 用户-用户组概述 14.2 查看用户登录 14.3 用户和用户组配置文件概述 14.4 用户账号配置文件信息 14.5 用户账号管理 14.6 用户密码管理 14.7 用户密码配置文件 14.8 用户删除 14.9 用户组管理 14.10 用户组文件信息 14.11 用户深入管理
14. Linux 用户 - 用户组管理
14.1 用户-用户组概述
$#
在大部分系统中( windows/linux) , 默认包含多个系统自带用户/用户组在系统中可以包含多个用户,多个用户组。 一个用户可以属于多个用户组,一个用户组也可以包含多个用户。在Windows中一个用户可以不隶属于任何组,在Linux中一个用户必须隶属于某一个组。在windows中每个用户都有自己的一个桌面。 | C:\ Users\ zy\ ( zy的家目录) C:\ Users\ zy\ Desktop( zy的桌面目录) 在Linux中每个用户都有自己的一个桌面 |
[ zy@localhost ~] $ pwd
/home/zy
[ zy@localhost Desktop] $ pwd
/home/zy/Desktop
[ zy@localhost Desktop] $
14.2 查看用户登录
$#
在windows 桌面系统 - 同一时刻只允许单用户登录。 windows 服务器系统, 同一时刻可以允许多用户登录。
在linux系统 同一时刻允许多个用户同时登录,并且允许一个用户使用多种方式查看。
[ zy@localhost Desktop] $ who zy pts/0 2023 -02-02 22 :52 ( 192.168 .8.1) zy :0 2023 -02-02 23 :09 ( :0) zy pts/1 2023 -02-02 23 :18 ( :0)
登录用户名称 使用终端 登录时间 ( 什么方式登录)
[ zy@localhost Desktop] $ root@localhost Desktop] 00:08:34 up 33 min, 2 users, load average: 0.00 , 0.01 , 0.02
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
zy pts/0 192.168 .8.1 23 :45 4 :26 0 .05s 0 .05s -bash
zy pts/1 192.168 .8.1 00:03 2 .00s 0 .07s 0 .12s sshd: zy [ priv]
[ root@localhost Desktop] 1 :0 鼠标、键盘、显示器-直接通过图形和界面方式打开主机
2 pts/0 伪终端( psedo-terminal slave) -提供和linux主机进行交互命令界面右键 open terminal | telnet/ssh xshell 3 tty 早期电传打字机( teletypewrites) 只能用于打字-命令交互/无法提供图形化界面-无鼠标、无窗口
ctrl + alt +( F2~F6) ctrl + alt + F2
ctrl + alt + F6
[ zy@localhost ~] $ who
zy tty2 2023 -02-02 23 :40
zy tty6 2 023-02-02 23 :41
[ zy@localhost ~] $
14.3 用户和用户组配置文件概述
$#
每一行都是一个用户信息
在linux中,不同服务可以通过不同linux账户来维护, 默认包含了多个系统自带账户。
[ root@localhost Desktop]
tcpdump:x:72:72::/:/sbin/nologin
zy:x:1000:1000:zy:/home/zy:/bin/bash
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
zhangsan zy
[ root@localhost Desktop] [ root@localhost Desktop]
[ root@localhost Desktop]
zhangsan zy lisi( 并不是用户)
[ root@localhost Desktop] [ root@localhost Desktop]
zy:x:1000:1000:zy:/home/zy:/bin/bash
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
zhangsan:x:1001:1001::/home/zhangsan:/bin/bash
[ root@localhost Desktop]
14.4 用户账号配置文件信息
$#
zy:x:1000:1000:zy:/home/zy:/bin/bash
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologinzhangsan: x: 1001 : 1001 : : /home/zhangsan: /bin/bash[ 1 ] : [ 2 ] : [ 3 ] : [ 4 ] : [ 5 ] : [ 6 ] : [ 7 ] :
[ 用户名] : [ 用户密码] : [ 用户ID] : [ 组ID] : [ 用户描述信息] : [ 用户的家目录] : [ 用户所使用的shell] [ 1 ] : 用户名
[ 2 ] : 用户密码 | x( 代号) 密码单独存储在/etc/shadow
[ 3 ] : 用户ID user-id ( UID )
[ 4 ] : 主组ID group-id ( GID)
[ 5 ] : 用户描述信息
[ 6 ] : 用户的家目录
[ 7 ] : 用户所使用的shell( 壳)
[ root@localhost Desktop]
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh
[ root@localhost Desktop]
[ root@localhost Desktop]
/bin/bash
[ root@localhost Desktop] [ root@localhost Desktop]
root:x:0:0:root:/root:/bin/bash
[ root@localhost Desktop]
[ root@localhost Desktop]
sh-4.2
exit
[ root@localhost Desktop]
[ root@localhost Desktop]
sh-4.2
[ root@localhost Desktop]
[ root@localhost ~]
Changing shell for root.
Shell changed.
[ root@localhost ~]
logout
[ zy@localhost ~] $ su - root
Password:
Last login: Fri Feb 3 00:39:47 CST 2023 on pts/1
-sh-4.2
[ root@localhost ~]
root:x:0:0:root:/root:/bin/sh
[ root@localhost ~]
14.5 用户账号管理
$# 1 . 在centos linux环境
创建用户时,如果没有指定UID ,GID,系统会自动创建( 从ID = 1001 开始)
如果没有指定家目录,系统会自动创建( /home/username) 作为家目录
如果没有指定shell,系统会自动创建( /bin/bash) shell,与系统进行交互$# 2 . 实战
[ root@localhost Desktop]
[ root@localhost Desktop]
username01:x:2001:2001::/home/username01:/bin/bash
[ root@localhost Desktop]
[ root@localhost Desktop]
username01:x:2001:
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
username02:x:2002:2002:我的电话号码是:15678:/home/username02:/bin/bash
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
username03:x:2003:2003::/home/username03:/bin/csh
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
username04:x:2004:2004::/home/username04lbp:/bin/bash
[ root@localhost Desktop]
zy username01 username02 username03 username04lbp
[ root@localhost Desktop]
$#
[ root@localhost Desktop]
[ root@localhost Desktop]
username05:x:2005:2004::/home/username05:/bin/bash
[ root@localhost Desktop]
useraddname05:x:2005:2004::/home/useraddname05:/bin/bash[ root@localhost Desktop]
uid = 2005 ( username05) gid = 2004 ( username04) groups = 2004 ( username04)
[ root@localhost Desktop] [ root@localhost Desktop]
useradd: group '2006' does not exist
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
username07:x:2007:2003::/home/username07:/bin/bash
[ root@localhost Desktop]
[ root@localhost Desktop]
uid = 2007 ( username07) gid = 2003 ( username03) groups = 2003 ( username03) ,2004( username04)
[ root@localhost Desktop] [ root@localhost Desktop]
[ username07@localhost Desktop] $ cd ~
[ username07@localhost ~] $ pwd
/home/username07
[ username07@localhost ~] $ touch 1 .txt
[ username07@localhost ~] $ ls -lh
-rw-r--r--. 1 username07 username03 0 Feb 3 01:27 1 .txt
[ username07@localhost ~] $
[ username07@localhost ~] $ newgrp username04
[ username07@localhost ~] $ touch 2 .txt
[ username07@localhost ~] $ ls -lh
total 0
-rw-r--r--. 1 username07 username03 0 Feb 3 01:27 1 .txt
-rw-r--r--. 1 username07 username04 0 Feb 3 01:29 2 .txt
[ username07@localhost ~] $
[ username07@localhost ~] $ exit
exit
[ username07@localhost ~] $ touch 3 . txt
[ username07@localhost ~] $ ls -lh -rw-r--r--. 1 username07 username03 0 Feb 3 01:27 1 .txt
-rw-r--r--. 1 username07 username04 0 Feb 3 01:29 2 .txt
-rw-r--r--. 1 username07 username03 0 Feb 3 01:32 3 .txt
[ username07@localhost ~] $ id username07
uid = 2007 ( username07) gid = 2003 ( username03) groups = 2003 ( username03) ,2004( username04)
[ username07@localhost ~] $
14.6 用户密码管理
$# 1 .
[ root@localhost ~]
Changing password for user username01.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[ root@localhost ~]
[ username01@localhost Desktop] $ passwd
Changing password for user username01.
Changing password for username01.
( current) UNIX password:
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[ username01@localhost Desktop] $
14.7 用户密码配置文件
$# 1 .
[ root@localhost Desktop]
username01:$6 $6oue2ZrC $M0cgIBO8YKzGBGiZ /JNTd/Og8a33UeYX27Rb8T6e2178SY2bbR0GQ.cLWL6mxLcD.Cm3rSZSdWkW9Ks0M2Jo./:19390:0:99999:7:::
username02:! ! :19390:0:99999:7:8::
[ root@localhost Desktop] username02: ! ! : 19390 : 0 : 99999 : 7 : 8 : : [ 1 ] : [ 2 ] : [ 3 ] : [ 4 ] : [ 5 ] : [ 6 ] : [ 7 ] : [ 8 ] : [ 9 ]
[ 1 ] : 用户名
[ 2 ] : 密码 ---- "!!" : 账号锁定 | $6 $: 密码已经设置, 并且密码本地加密
[ 3 ] : 上次修改密码时间 ( 从1970-1-1 到 修改密码当天) 没有修改过的话,是创建账户的时间
[ 4 ] : 密码的最短有效期 ( 3 ) 3 天之内不可以修改密码 0 ( 随时可修改) 系统默认
[ 5 ] : 密码的最长有效时间 (30) 30 天之内必须修改密码 99999
[ 6 ] : 密码到期前多久发送告警( 提前 7 天发送警告)
[ 7 ] : 密码过期后的宽限日期 ( 8 ) 再宽限8天
[ 8 ] : 账号的失效日期 ----优先级最高, 一旦当前参数到期,该账号直接立即无法使用
[ 9 ] : 保留
[ root@localhost Desktop]
ENCRYPT_METHOD SHA512
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
username01:$6 $6oue2ZrC $M0cgIBO8YKzGBGiZ /JNTd/Og8a33UeYX27Rb8T6e2178SY2bbR0GQ.cLWL6mxLcD.Cm3rSZSdWkW9Ks0M2Jo./:0:0:99999:7:::
[ root@localhost Desktop]
username01:$6 $6oue2ZrC $M0cgIBO8YKzGBGiZ /JNTd/Og8a33UeYX27Rb8T6e2178SY2bbR0GQ.cLWL6mxLcD.Cm3rSZSdWkW9Ks0M2Jo./:19390:0:99999:7:::
[ root@localhost Desktop]
username01 PS 1970 -01-01 0 99999 7 -1 ( Password set, SHA512 crypt.)
[ root@localhost Desktop]
[ root@localhost Desktop]
Locking password for user username01.
passwd: Success
[ root@localhost Desktop]
username01:! ! $6 $6oue2ZrC $M0cgIBO8YKzGBGiZ /JNTd/Og8a33UeYX27Rb8T6e2178SY2bbR0GQ.cLWL6mxLcD.Cm3rSZSdWkW9Ks0M2Jo./:0:0:99999:7:::
[ root@localhost Desktop]
username01 LK 1970 -01-01 0 99999 7 -1 ( Password locked.)
[ root@localhost Desktop]
[ root@localhost Desktop]
Unlocking password for user username01.
passwd: Success
[ root@localhost Desktop]
username01:$6 $6oue2ZrC $M0cgIBO8YKzGBGiZ /JNTd/Og8a33UeYX27Rb8T6e2178SY2bbR0GQ.cLWL6mxLcD.Cm3rSZSdWkW9Ks0M2Jo./:0:0:99999:7:::
[ root@localhost Desktop]
[ root@localhost Desktop]
username01 PS 1970 -01-01 0 99999 7 -1 ( Password set, SHA512 crypt.)
[ root@localhost Desktop]
[ root@localhost Desktop]
Removing password for user username01.
passwd: Success
[ root@localhost Desktop]
Locking password for user username01.
passwd: Success
[ root@localhost Desktop]
username01:! ! :19390:0:99999:7:::
[ root@localhost Desktop]
[ root@localhost Desktop]
Expiring password for user username01.
passwd: Success
[ root@localhost Desktop]
username01:$6 $oqrKE9Bx $I65yShC1Q4WQZtit2HWTdnVoumoqjnZz74wQt1rlmew7mEe0bJjFACHelq3urIs2U .40lkzN8P3tAAaTzhOus1:0:0:99999:7:::
[ root@localhost Desktop]
$# 2 . 实战设置密码( 通过管道-输入方式)
[ root@localhost Desktop]
Changing password for user username01.
passwd: all authentication tokens updated successfully.
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
username01:$6 $oqrKE9Bx $I65yShC1Q4WQZtit2HWTdnVoumoqjnZz74wQt1rlmew7mEe0bJjFACHelq3urIs2U .40lkzN8P3tAAaTzhOus1:0:0:99999:7:::
[ root@localhost Desktop]
Adjusting aging data for user username01.
passwd: Success
[ root@localhost Desktop]
username01:$6 $oqrKE9Bx $I65yShC1Q4WQZtit2HWTdnVoumoqjnZz74wQt1rlmew7mEe0bJjFACHelq3urIs2U .40lkzN8P3tAAaTzhOus1:0:3:30:5:2::
[ root@localhost Desktop]
[ root@localhost ~]
[ root@localhost ~]
username01:$6 $TkEqrYWS $iQ4C85rquhlgFQYq7 /04CXxdmAfTqkMb6HJFVFuq3eTtonBl1dI5qmv24QCOHSrMbwNXg2sQYp.6nXPiAU2k8/:19390:3:30:5:2:19886:
[ root@localhost ~]
14.8 用户删除
$# 1 .
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
username01 username03 username04 username07 zhangsan zy
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
username01 username03 username04 username07 zhangsan zy
[ root@localhost Desktop]
[ root@localhost ~]
[ root@localhost ~]
username01 username03 username04 username07 zy
[ root@localhost ~]
14.9 用户组管理
$# 1 .
[ root@localhost Desktop]
zy:x:1000:zy
apache:x:48:
username01:x:2001:
username04:x:2004:
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
username04:x:2004:
groupname01:x:2005:
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
username04:x:2004:
groupname01:x:2005:
groupname02:x:30001:
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
uid = 1001 ( username01) gid = 2005 ( groupname01) groups = 2005 ( groupname01)
[ root@localhost Desktop]
$# 2 .
[ root@localhost Desktop]
useradd: user 'username01' already exists
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
uid = 1001 ( username01) gid = 2005 ( groupname01) groups = 2005 ( groupname01) ,30001( groupname02)
[ root@localhost Desktop]
[ root@localhost Desktop]
uid = 1001 ( username01) gid = 2005 ( groupname01) groups = 2005 ( groupname01) ,30001( groupname02)
[ root@localhost Desktop]
[ root@localhost Desktop]
uid = 1001 ( username01) gid = 2005 ( groupname01) groups = 2005 ( groupname01)
[ root@localhost Desktop]
$# 3 .
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
uid = 1001 ( username01) gid = 2005 ( groupname01) groups = 2005 ( groupname01) ,3003( groupname03)
[ root@localhost Desktop]
[ root@localhost Desktop]
[ root@localhost Desktop]
uid = 1001 ( username01) gid = 2005 ( groupname01) groups = 2005 ( groupname01) ,30001( groupname02) ,3003( groupname03)
[ root@localhost Desktop]
14.10 用户组文件信息
$# 1 . 用户组信息
[ root@localhost Desktop]
groupname01:x:2005:
groupname02:x:30001:username01
groupname03:x:3003:username01
[ root@localhost Desktop] groupname03: x: 3003 : username01
[ 用户组名称] : [ 用户组密码信息] : [ 用户组ID] : [ 附加组成员] :[ 1 ] : 用户组名称[ 2 ] : 用户组密码信息 [ 3 ] : 用户组ID [ 4 ] : 附加组成员创建用户的同时,默认会创建一个跟用户名相同的组如果先创建了组,再创建与组名称相同的用户,需要填加-g + 用户名称
[ root@localhost Desktop]
[ root@localhost Desktop]
groupname01:x:2005:
groupname02:x:30001:username01
groupname03:x:3003:username01
username02:x:30002:
[ root@localhost Desktop]
useradd: group username02 exists - if you want to add this user to that group, use -g.
[ root@localhost Desktop]
id: username02: no such user
[ root@localhost Desktop]
[ root@localhost Desktop]
$# 2 . 组密码文件信息
[ root@localhost Desktop]
Changing the password for group groupname02
New Password:
Re-enter new password:
[ root@localhost Desktop]
[ username01@localhost Desktop] $ cd ~
[ username01@localhost ~] $ ls
[ username01@localhost ~] $ touch 2 .txt
[ username01@localhost ~] $ id username01
uid = 1001 ( username01) gid = 2005 ( groupname01) groups = 2005 ( groupname01) ,30001( groupname02) ,3003( groupname03)
[ username01@localhost ~] $ newgrp groupname02
[ username01@localhost ~] $ touch 3 .txt
[ username01@localhost ~] $ ls -lh
-rw-r--r--. 1 username01 groupname01 0 Feb 3 00:27 2 .txt
-rw-r--r--. 1 username01 groupname02 0 Feb 3 00:28 3 .txt
[ username01@localhost ~] $
[ root@localhost Desktop]
[ root@localhost Desktop]
uid = 1001 ( username01) gid = 2005 ( groupname01) groups = 2005 ( groupname01) ,30001( groupname02) ,3003( groupname03)
[ root@localhost Desktop]
Removing user username01 from group groupname03
[ root@localhost Desktop]
uid = 1001 ( username01) gid = 2005 ( groupname01) groups = 2005 ( groupname01) ,30001( groupname02)
[ root@localhost Desktop]
[ root@localhost Desktop]
Adding user username01 to group groupname03
[ root@localhost Desktop]
uid = 1001 ( username01) gid = 2005 ( groupname01) groups = 2005 ( groupname01) ,30001( groupname02) ,3003( groupname03)
[ root@localhost Desktop]
14.11 用户深入管理
$# 1 . 关于用户删除
[ root@localhost ~]
[ root@localhost ~]
username01 username02 username03
[ root@localhost ~]
[ root@localhost ~]
username01 username02
[ root@localhost ~]
root rpc username01 username02 username03
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
[ root@localhost ~]
[ root@localhost ~]
. ..
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
. .. .bash_logout .bash_profile .bashrc .mozilla
[ root@localhost ~] [ root@localhost ~]
. .. .bash_logout .bash_profile .bashrc .mozilla
[ root@localhost ~]
[ root@localhost ~]
bash-4.2$
[ root@localhost ~]
[ root@localhost ~]
cp: cannot stat ‘/etc//skel/*’: No such file or directory
[ root@localhost ~]
drwxr-xr-x. 3 root root 78 Dec 12 23 :11 .
drwxr-xr-x. 135 root root 8 .0K Feb 3 01:05 ..
-rw-r--r--. 1 root root 18 Aug 3 2017 .bash_logout
-rw-r--r--. 1 root root 193 Aug 3 2017 .bash_profile
-rw-r--r--. 1 root root 231 Aug 3 2017 .bashrc
drwxr-xr-x. 4 root root 39 Dec 12 23 :11 .mozilla
[ root@localhost ~]
cp: cannot stat ‘/etc/skel/*’: No such file or directory
[ root@localhost ~]
cp: will not create hard link ‘/home/username03/skel’ to directory ‘/home/username03/.’
cp: overwrite ‘/home/username03/.bash_logout’? yes
cp: overwrite ‘/home/username03/.bash_profile’? yes
cp: overwrite ‘/home/username03/.bashrc’? yes
cp: will not create hard link ‘/home/username03/.mozilla’ to directory ‘/home/username03/./.mozilla’
[ root@localhost ~]
. fonts maven rpc
.. fprintd.conf mcelog rpm
abrt fstab mke2fs.conf rsyncd.conf
flatpak man_db.conf resolv.conf
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
total 12K
drwxr-xr-x. 3 root root 78 Feb 3 01:22 .
drwxr-xr-x. 7 root root 81 Feb 3 01:21 ..
-rw-r--r--. 1 root root 18 Aug 3 2017 .bash_logout
-rw-r--r--. 1 root root 193 Aug 3 2017 .bash_profile
-rw-r--r--. 1 root root 231 Aug 3 2017 .bashrc
drwxr-xr-x. 4 root root 39 Dec 12 23 :11 .mozilla
[ root@localhost ~]
[ username03@localhost root] $ [ root@localhost ~]
[ root@localhost ~]
drwx------. 3 username04 username04 78 Feb 3 01:28 .
drwxr-xr-x. 8 root root 99 Feb 3 01:28 ..
-rw-r--r--. 1 username04 username04 18 Aug 3 2017 .bash_logout
-rw-r--r--. 1 username04 username04 193 Aug 3 2017 .bash_profile
-rw-r--r--. 1 username04 username04 231 Aug 3 2017 .bashrc
drwxr-xr-x. 4 username04 username04 39 Dec 12 23 :11 .mozilla
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost skel]
[ root@localhost skel]
[ root@localhost skel]
[ root@localhost skel]
[ root@localhost ~]
[ root@localhost ~]
drwx------. 3 username05 username05 95 Feb 3 01:37 .
drwxr-xr-x. 9 root root 117 Feb 3 01:37 ..
-rw-r--r--. 1 username05 username05 18 Aug 3 2017 .bash_logout
-rw-r--r--. 1 username05 username05 193 Aug 3 2017 .bash_profile
-rw-r--r--. 1 username05 username05 231 Aug 3 2017 .bashrc
drwxr-xr-x. 4 username05 username05 39 Dec 12 23 :11 .mozilla
-rw-r--r--. 1 username05 username05 19 Feb 3 01:35 README.md
[ root@localhost ~]
Wecome to my Cloud
[ root@localhost ~]
[ root@localhost ~]
username05:x:1006:1006::/home/username05:/bin/bash
[ root@localhost ~]
[ username05@localhost root] $ chfn
Changing finger information for username05.
Name [ ] : 求伯君
Office [ ] : wps
Office Phone [ ] : 123456789
Home Phone [ ] : 987654321
Password:
Finger information changed.
[ username05@localhost root] $ tail /etc/passwd -n 1
username05:x:1006:1006:求伯君,wps,123456789,987654321:/home/username05:/bin/bash
[ username05@localhost root] $
[ username05@localhost root] $ chsh -s /bin/sh
Changing shell for username05.
Password:
Shell changed.
[ username05@localhost root] $ exit
exit
[ root@localhost ~]
sh-4.2$
sh-4.2$
[ root@localhost ~]
total 4 .0K
drwxr-xr-x. 9 root root 117 Feb 3 01:37 .
dr-xr-xr-x. 18 root root 239 Jan 5 04:39 ..
drwxr-xr-x. 3 root root 78 Feb 3 01:22 username03
drwx------. 5 username05 username05 145 Feb 3 02:04 username05
drwxr-xr-x. 2 root root 6 Feb 3 00:52 username3
drwx------. 13 zy zy 4 .0K Feb 3 01:43 zy
[ root@localhost ~]
userdel: /home/username03 not owned by username03, not removing
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
zy:x:1000:1000:zy:/home/zy:/bin/bash
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
username01:x:1001:1001:周伯通,阿里巴巴,1234,4321:/home/username01:/bin/bash
[ root@localhost ~]
[ root@localhost ~]
zy:$6 $NUIlmI90 $pP2QceY5LncMxboRdG0bTRxRaHvH8HkInMESBaXXt5Gd /T4tvYj0qV6RpctxXyL5n0a1CTZcpBWf8Q/NOX.27/:19388:0:99999:7:::
apache:! ! :19361::::::
username01:! ! :19362:0:99999:7:::
[ root@localhost ~]
a[ root@localhost ~]
groupname01:x:2005:
groupname02:x:30001:
groupname03:x:3003:username01
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ username01@localhost root] $ ls
ls: cannot open directory .: Permission denied
[ username01@localhost root] $ [ root@localhost ~]
total 12K
drwxr-xr-x. 3 root root 78 Feb 3 02:30 .
drwxr-xr-x. 4 root root 34 Feb 3 02:29 ..
-rw-r--r--. 1 root root 18 Aug 3 2017 .bash_logout
-rw-r--r--. 1 root root 193 Aug 3 2017 .bash_profile
-rw-r--r--. 1 root root 231 Aug 3 2017 .bashrc
drwxr-xr-x. 4 root root 39 Dec 12 23 :11 .mozilla
[ root@localhost ~]
[ root@localhost ~]
userdel: /var/spool/mail/username01 not owned by username01, not removing
userdel: /home/username01 not owned by username01, not removing
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
Changing password for user username02.
passwd: all authentication tokens updated successfully.
[ root@localhost ~]
[ root@localhost ~]
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh
[ root@localhost ~]
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh
[ root@localhost ~]
sbin/nologn
[ root@localhost ~]
Changing shell for username02.
Shell changed.
[ root@localhost ~]
[ root@localhost ~] Broadcast message from root@localhost.localdomain ( pts/1) ( Fri Feb 3 02:43:49 2023 ) :This server will be shutdown, please exit
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]