Linux – Can a Linux user belong to more than one group

linuxunixuser-accounts

Can a Linux user belong to more than one group?

If it is allowed, then one use may access files from two groups, that would be quite nice!

If not, is there any alternative way to have this function?

This issue is not the same as Ensuring new files in a directory belong to the group or Help me understand Ubuntu user/group permissions

Best Answer

Yes, a user can be member of multiple groups:

Users are organized into groups, every users is in at least one group, and may be in other groups. Group membership gives you special access to files and directories which are permitted to that group.

For example, you can add the user username to groups group1 and group2 with the following usermod command:

usermod -a -G group1,group2 username
Related Question