oot@localhost ~]# cat /etc/group
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
......
......
chrony:x:996:
cgred:x:995:
dockerroot:x:994:
gubeiqing:x:1000:
然后使用vi
编辑器删除这个用户组。
4.删除/var/spool/mail
下的邮箱文件
[root@localhost ~]# cd /var/spool/mail
[root@localhost mail]# ls
gubeiqing
[root@localhost mail]# rm -rf gubeiqing
[root@localhost mail]# ls
[root@localhost mail]#
删除完成,再来创建gubeiqing
用户。
[root@localhost mail]# useradd gubeiqing
[root@localhost mail]# passwd gubeiqing
Changing password for user gubeiqing.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
除了这种方法还有一种完全删除的方法。
[root@localhost mail]# userdel -rf gubeiqing
[root@localhost mail]# useradd gubeiqing
[root@localhost mail]# passwd gubeiqing
Changing password for user gubeiqing.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
使用这两种方法都可以完全删除用户。
usermod
usermod
命令用于修改用户的属性,使用方式为:usermod [可选参数] 用户名
。
-e
修改用户账户的到期时间,格式为YYYY-MM-DD
。
-g
变更所属用户组。
-u
修改用户的id
。
-L
锁定账户禁止其登录系统。
-U
解锁账户。
groupadd
groupadd
用于创建一个用户组,使用方式为groupadd [可选参数] 群组名
。
root@ubuntu:~# groupadd test
root@ubuntu:~# cat /etc/group
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
......
......
test1:x:1002:
test:x:1003:
这里我们可以使用usermod
命令修改test1
用户的所属组为test
,通过groups
命令可以看到test1
用户属于test
用户组。
root@ubuntu:~# usermod -g test test1
root@ubuntu:~# groups test1
test1 : test
groupdel
groupdel
用于删除一个用户组,使用方式为groupdel 群组名
。
groupmod
groupmod
用于修改用户组属性,使用方式为groupadd -n 新群组名 当前群组名
。
查看历史命令
history
history
命令用于查看用户都使用过命令:
root@ubuntu:~# history
1 cd
2 hostnamectl
3 sethostname
4 hostname ubuntu
......
......
158 usermod -g test test1
159 groups test1
160 history