Is there a command that shows a user exists and is assigned to a group?I have just used the command usermod -a -G [GROUP] [NAME OF USER] and assigned a user to a group but, I was wondering if there was a command which lists the users and which group they was assigned to?If I input cd .. and go to [user@user HOME] $then once here input the command ls this command lists the users I have created but not what group name they're assigned to.
Show a user exists command
users;group;accounts
The groups command does exactly what you are looking for. By doing groups <username>, it lists the groups a user is a part of. And, if the user does not exist, it will output an error saying so.This is just if you want to list all the groups the user is a part of. If you want more information about the user and his/her groups, the id command also includes the ID for each group the user is a part of.