Linux – How to add a user to multiple groups in Ubuntu

command linelinuxpermissionsUbuntu

What's the command line utility and the arguments it requires?

Best Answer

The utility is usermod and is used like:

usermod -a -G group1,group2 username

Where username is the user you want to modify and group1 and group2 are the new groups you want that user to join. Running the command without the -a argument will remove that user from all groups except group1 and group2.

To check a users group memberships use the groups command:

groups username
Related Question