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.

A laptop running Linux with the time visible on the desktop.

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.

The Linux terminal displaying the process of creating a new group on Linux using the groupadd command

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.

The Linux terminal showing a list of all groups in the system

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.

The Linux terminal displaying the process of setting a new password for a group using the gpasswd command

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.

The Linux terminal showing the process of logging into a group in Linux using the newgrp command

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.

The Linux terminal showing the process of removing the password from a a group in Linux using the gpasswd command

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.

The Linux terminal showing how to use the gpasswd command to add a member to a group

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.

The Linux terminal shows the current members of the group named demogroup

The Linux terminal showing how to remove a user from a group using the gpasswd command

The Linux terminal showing the process of setting the list of members of a group using the gpasswd command

The Linux terminal displaying the current the members of a group in Linux after setting the members list using gpasswd

The Linux terminal showcasing how to make a user the administrator of a group using the gpasswd command

The Linux terminal displaying the the administrators of every group in Linux