0

Ran below commands to create a group

[root@u87 ~] # groupadd -g 2441 somegroup
groupadd: group 'somegroup' already exists
[root@u87 ~]# cat /etc/group | grep somegroup
[root@u87 ~]#
[root@u87 ~]#
[root@u87 ~]# 
[root@u87 ~]# cat /etc/system-release
Red Hat Enterprise Linux Server release 7.5 (Maipo)

How do I understand this error?

overexchange
  • 1,536

1 Answers1

2

Groups (and other user information) can be defined in places other than /etc/group; e.g. LDAP. The sources of information are configured in /etc/nsswitch.conf.

To retrieve information from whatever sources are used, use getent:

getent group somegroup

You can use this to check the existence of a group before trying to add it:

getent group somegroup || groupadd -g 2441 somegroup
Stephen Kitt
  • 434,908