linux使用useradd添加用户失败,出现异常useradd: group elastic exists

现象

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

其他常用相关命令

  1. 查看所有用户
cat /etc/passwd
  1. 查看所有用户组
cat /etc/group
  1. 添加用户组
groupadd group_name

4.删除用户组

groupdel group_name

5.添加组成员

gpasswd -a user group_name

6.删除组成员

gpasswd -d user group_name

猜你喜欢

转载自blog.csdn.net/macaiyun0629/article/details/108397387