设为首页 加入收藏

TOP

Linux快速入门(四)Linux用户管理(二)
2023-07-23 13:31:24 】 浏览:36
Tags:Linux 管理
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
首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇8 月份全球 Wi-Fi6 技术标准更新 下一篇Linux快速入门(六)Linux网络管理

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目