1.1 用户管理
查看当前用户:
# who
[root@localhost ~]# who
创建用户:
# useradd [-g 群组] 用户名
[root@localhost ~]# useradd admin
# 在群组下创建用户
[root@localhost ~]# useradd -g root admin
查看用户目录:
[root@localhost ~]# ls /home
设置密码:
# passwd 用户名
[root@localhost ~]# passwd admin
密码要大于8个字符,包含数字、大小写字母、符号
切换用户:
# su 用户名
[root@localhost ~]# su admin
删除用户:
# userdel [-r] 用户名
[root@localhost ~]# userdel -r admin
1.2 群组管理
查看群组:
# groups [用户名]
# 查看当前用户所在群组
[root@localhost ~]# groups
# 查看指定用户所在群组
[root@localhost ~]# groups admin
创建群组:
# groupadd 群组名
[root@localhost ~]# groupadd test
删除群组:
# groupdel 群组名
[root@localhost ~]# groupdel test
用户群组修改:
# usermod [-g 群组名] 用户名
[root@localhost ~]# usermod -g test admin
查看所有群组:
[root@localhost ~]# cat /etc/group