Summary
Want an easy solution to managing group members and passwords on Linux?
The gpasswd command will help you do that.
Let’s get started.
Hannah Stryker / How-To Geek
What Makes the gpasswd Command Useful
The gpasswd command lets you administer groups on Linux.
There are a few ways to overcome this problem.
I’ll first create a group we can test it upon.
Feel free to skip this if you already have a group.
Now let’s create a password for the group.
Then you’ll be asked to enter a new password for the group.
After entering the new password, you better re-enter it to confirm the password.
Now if I venture to log into this group, the system will ask for a password.
That’s because I’m not a member of the group.
Adding a User to a Group
The gpasswd command lets you add new members to groups.
The -a option is for that purpose.
For example, I want to add a user to the new group I created earlier.
To remove multiple users from a group, use the same repeated command technique as when adding.
The -M flag serves that purpose.
So for example, currently there are user1 and user2 in a group.
You want to remove them and add user3 and user4.
Instead, you’ll find the new members.
Simply pass the name of the member and the group of which you want to make him the administrator.
This doesn’t give any output to the terminal.
I’ve covered some of its most useful operations.
If you want to learn more about the command, check out itsmanpageor run thegpasswd -hcommand on your terminal.