In Linux, user permissions and security access are heavily managed through “groups.” For example, if you want a specific user to have the ability to execute administrator commands via sudo, or access a restricted shared folder, they must be added to the correct group. If a user is complaining that they get a “Permission denied” error when trying to run a script, the very first troubleshooting step is to check which groups they actually belong to.
Using the ‘groups’ Command
The fastest way to check group membership is by using the built-in groups command.
- Open your Linux terminal.
- To check your own current user groups, simply type:
groups - Press Enter.
The terminal will print out a space-separated list of all your assigned groups (e.g., john sudo docker www-data).
Checking Another User’s Groups
If you are an administrator and need to verify the permissions of a different user on the server (for example, a new employee named “sarah”), you can append their username directly to the end of the command.
groups sarah
This will instantly output something like sarah : sarah developers hr, confirming exactly which group permissions she has currently been granted. This command is completely safe and does not require sudo privileges to run.