[root@localhost ~]# groupadd group1
[root@localhost ~]# mkdir -p /testgroup1
[root@localhost ~]# groupadd jiaoxue
[root@localhost ~]# useradd -d /testgroup1/tom/ -g group1 -G jiaoxue -s /bin/bash -e 2016-01-01 tom
[root@localhost ~]# passwd tom
更改用户 tom 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@localhost ~]# tail -1 /etc/passwd
tom:x:1001:1001::/testgroup1/tom/:/bin/bash
[root@localhost ~]# tail -1 /etc/shadow
tom:$6$/46q2wnB$LDJjpwzVLcgkwymoIJFGZhkYoFLI4CWP6Elzw1KIkmmCWxiiVaXJC1HC9mEdwu5cHkK002jexd2mhaakaXhVq.:18106:0:99999:7::16801:
[root@localhost ~]# vi ~tom/.bash_profile
[root@localhost ~]# vi ~tom/.bashrc
[root@localhost ~]# vi ~tom/.bash_logout
[root@localhost ~]# passwd -l tom
锁定用户 tom 的密码 。
passwd: 操作成功
[root@localhost ~]# passwd -S tom
tom LK 2019-07-29 0 99999 7 -1 (密码已被锁定。)
[root@localhost ~]# passwd -u tom
解锁用户 tom 的密码。
passwd: 操作成功
[root@localhost ~]# passwd -S tom
tom PS 2019-07-29 0 99999 7 -1 (密码已设置,使用 SHA512 算法。)
[root@localhost ~]# passwd -d tom
清除用户的密码 tom。
passwd: 操作成功
[root@localhost ~]# usermod -l tom1 tom
[root@localhost ~]# tail -1 /etc/passwd
tom1:x:1001:1001::/testgroup1/tom/:/bin/bash
[root@localhost ~]# usermod -c jiaoxue tom1
[root@localhost ~]# tail -1 /etc/passwd
tom1:x:1001:1001:jiaoxue:/testgroup1/tom/:/bin/bash
[root@localhost ~]# userdel -r tom1
[root@localhost ~]# ls /testgroup1
[root@localhost ~]# tail -3 /etc/group
chrnyu:x:1000:chrnyu
group1:x:1001:
jiaoxue:x:1002:
[root@localhost ~]# groupadd -g 888 market
[root@localhost ~]# tail -4 /etc/group
chrnyu:x:1000:chrnyu
group1:x:1001:
jiaoxue:x:1002:
market:x:888:
[root@localhost ~]# useradd test1
[root@localhost ~]# useradd test2
[root@localhost ~]# useradd test3
[root@localhost ~]# gpasswd -a test1 market
正在将用户“test1”加入到“market”组中
[root@localhost ~]# tail -4 /etc/group
market:x:888:test1
test1:x:1003:
test2:x:1004:
test3:x:1005:
[root@localhost ~]# gpasswd -d test1 market
正在将用户“test1”从“market”组中删除
[root@localhost ~]# tail -4 /etc/group
market:x:888:
test1:x:1003:
test2:x:1004:
test3:x:1005:
[root@localhost ~]# gpasswd -M test1,test2,test3 market
[root@localhost ~]# tail -4 /etc/group
market:x:888:test1,test2,test3
test1:x:1003:
test2:x:1004:
test3:x:1005:
[root@localhost ~]# gpasswd -M test1 market
[root@localhost ~]# tail -4 /etc/group
market:x:888:test1
test1:x:1003:
test2:x:1004:
test3:x:1005:
[root@localhost ~]# groupdel market
[root@localhost ~]# tail -5 /etc/group
group1:x:1001:
jiaoxue:x:1002:
test1:x:1003:
test2:x:1004:
test3:x:1005:
[root@localhost ~]# id amber
id: amber: no such user
[root@localhost ~]# id
uid=0(root) gid=0(root) 组=0(root) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[root@localhost ~]# groups amber
groups: amber: no such user
[root@localhost ~]# groups
Root
[root@localhost yum.repos.d]# finger
Login Name Tty Idle Login Time Office Office Phone Host
root root *:0 Jul 29 18:34 (:0)
root root pts/0 45 Jul 29 18:35 (:0)
root root pts/1 Jul 29 18:35 (192.168.100.150)
[root@localhost ~]# w
19:21:40 up 47 min, 3 users, load average: 0.03, 0.04, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root :0 :0 18:34 ?xdm? 21.75s 0.15s /usr/libexec/gnome-session-binary --session gnome
root pts/0 :0 18:35 46:28 0.03s 0.03s bash
root pts/1 192.168.100.150 18:35 4.00s 0.34s 0.03s w
[root@localhost ~]# whoami
root
[root@localhost ~]# who
root :0 2019-07-29 18:34 (:0)
root pts/0 2019-07-29 18:35 (:0)
root pts/1 2019-07-29 18:35 (192.168.100.150)