现象
Linux创建用户elastic
的时候,用命令
useradd elastic
出现异常:
useradd: group elastic exists - if you want to add this user to that group, use -g.
原因
在创建用户时没有指定用户组,系统默认会创建一个同名的用户组,用户userone不存在,但是用户组userone已经存在,所以会有这个错误。
解决
需要指定用户elastic
的用户组为已存在的elastic
。命令格式:useradd -g user_group user_name
。如:
useradd -g elastic elastic
其他常用相关命令
- 查看所有用户
cat /etc/passwd
- 查看所有用户组
cat /etc/group
- 添加用户组
groupadd group_name
4.删除用户组
groupdel group_name
5.添加组成员
gpasswd -a user group_name
6.删除组成员
gpasswd -d user group_name