During my application install, I used to create a new group and a new user using the 'groupadd' and 'useradd' commands
groupadd my_group useradd -r -s /sbin/nologin -g my_group my_user
But in one of the Linux machines, where the LDAP is enabled (the LDAP server is not running on this machine, but it's configured for LDAP client), I find that the 'groupadd
anduseradd` commands are adding the group and user into the LDAP and not as local user / group.
I didn't want to add the user/group to LDAP, as I actually needed a local user, who will be owning my applications config file and one of the process will be run using the new user. I don't thing that LDAP user's can be used for
chown commands to change the file ownerships.
On googling, I found that there is a
lgroupadd command which can add the user locally. But this tools are present in only RHEL by default. So on other distros like Ubuntu and SUSE, it' is not present by default and needs to be explicitly installed. So i can not rely on this
I don't want to manually add the user and group in
/etc/passwd file as it is a hack and it involves generating a unique group id and user id for my new group and user.
Is there any other alternative to add a local user which can be used across all linux distros ?
What is the best check to see if my machine is LDAP enabled ? I want to use this check to decide if I have to use
groupaddcommands or not.