第四章作业
[root@localhost ~]# groupadd group1
[root@localhost ~]# mkdir -p /testgroup1
[root@localhost ~]# groupadd mengwei
[root@localhost ~]# useradd -d /testgroup1/tom/ -g group1 -G mengwei -s /bin/bash -e 2019-07-29 tom
[root@localhost ~]# passwd tom
更改用户 tom 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@localhost ~]# tail -1 /etc/passwd
tom:x:1001:1004::/testgroup1/tom/:/bin/bash
[root@localhost ~]# tail -1 /etc/shadow
[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: 操作成功0YA5cf/ZqkfNlJMnNaYxsILfPegwiauc1SYSGt.2ZafqWBNwt0nsfsz6Ns.:18106:0:99999:7::18106:
[root@localhost ~]# passwd -x 120 tom
调整用户密码老化数据tom。
passwd: 操作成功
[root@localhost ~]# passwd -n 1 tom
调整用户密码老化数据tom。
passwd: 操作成功
[root@localhost ~]# passwd -w 5 tom
调整用户密码老化数据tom。
passwd: 操作成功
[root@localhost ~]# passwd -i 7 tom
调整用户密码老化数据tom。
passwd: 操作成功
[root@localhost ~]# grep tom /etc/shadow
tom::18106:1:120:5:7:18106:
[root@localhost ~]# usermod -l tom1 tom
[root@localhost ~]# tail -1 /etc/passwd
tom1:x:1001:1004::/testgroup1/tom/:/bin/bash
[root@localhost ~]# usermod -c jiaoxue tom1
[root@localhost ~]# tail -1 /etc/passwd
tom1:x:1001:1004:jiaoxue:/testgroup1/tom/:/bin/bash
[root@localhost ~]# userdel -r tom1
[root@localhost ~]# ls /testgroup1/
[root@localhost ~]# groupadd -g 666 market
[root@localhost ~]# tail -4 /etc/group
goup1:x:1003:
group1:x:1004:
mengwei:x:1005:
market:x:666:
[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:666:test1
test1:x:1001:
test2:x:1006:
test3:x:1007:
[root@localhost ~]# gpasswd -d test1 market
正在将用户“test1”从“market”组中删除
[root@localhost ~]# tail -4 /etc/group
market:x:666:
test1:x:1001:
test2:x:1006:
test3:x:1007:
[root@localhost ~]# gpasswd -M test1,test2,test3 market
[root@localhost ~]# tail -4 /etc/group
market:x:666:test1,test2,test3
test1:x:1001:
test2:x:1006:
test3:x:1007
[root@localhost ~]# tail -4 /etc/group
market:x:666:test1
test1:x:1001:
test2:x:1006:
test3:x:1007:
[root@localhost ~]# groups test2
test2 : test2
[root@localhost ~]# groups test3
test3 : test3
[root@localhost ~]# vi /etc/group
[root@localhost ~]# groupdel market
[root@localhost ~]# tail -5 /etc/group
group1:x:1004:
mengwei:x:1005:
test1:x:1001:
test2:x:1006:
test3:x:1007:
[root@localhost ~]# id amber
uid=1004(amber) gid=1008(amber) 组=1008(amber)
[root@localhost ~]# id
uid=0(root) gid=0(root) 组=0(root)
[root@localhost ~]# groups amber
amber : amber
[root@localhost ~]# groups
root
[root@localhost ~]# finger
Login Name Tty Idle Login Time Office Office Phone Host
root root *:0 Jul 29 19:52 (:0)
root root pts/0 7 Jul 29 19:52 (:0)
root root pts/1 6 Jul 29 19:53 (:0)
root root pts/2 Jul 29 19:54 (192.168.100.169)
root root pts/3 3 Jul 29 19:56 (192.168.100.169)
[root@localhost ~]# w
20:02:02 up 9 min, 5 users, load average: 0.60, 0.35, 0.17
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root :0 :0 19:52 ?xdm? 48.44s 0.06s gdm-session-worker [pam/gdm-password]
root pts/0 :0 19:52 9:06 0.01s 0.01s /bin/bash
root pts/1 :0 19:53 8:02 0.01s 0.01s /bin/bash
root pts/2 192.168.100.169 19:54 2.00s 0.04s 0.01s w
root pts/3 192.168.100.169 19:56 4:42 0.02s 0.02s -bash
[root@localhost ~]# whoami
root
[root@localhost ~]# who
root :0 2019-07-29 19:52 (:0)
root pts/0 2019-07-29 19:52 (:0)
root pts/1 2019-07-29 19:53 (:0)
root pts/2 2019-07-29 19:54 (192.168.100.169)