Issue
I have a server running where I use php to run a bash script to verify certain information of a user. For example, I have a webhosting server set up, and in order to be able to add another domain to their account I want to verify if the user is actually a member of the 'customers' group. What would be the best way to do this?
I have searched google, but all it comes up with is ways to check whether a user or a group exists, so google is not being a big help right now.
Solution
Try doing this :
username=ANY_USERNAME
if getent group customers | grep -qw "$username"; then
echo true
else
echo false
fi
or
username=ANY_USERNAME
if groups $username | grep -qw 'customers'; then
echo true
else
echo false
fi
Answered By - Gilles Quénot Answer Checked By - Terry (WPSolving Volunteer)