Examples of gpasswd Command

Creating a group and adding a user to it. After that deleting the user.

  • Adding a group named as geeks.
    $ sudo groupadd geeks

    adding group name

  • To display the created group with their id you can use:
    $cat /etc/group

    listing groups

  • Now the group geeks is added so now execute command under to add the user to group geeks:
    $ sudo gpasswd -a umang geeks

  • Deleting the created user from group geeks.
    $ sudo gpasswd -d umang geeks

gpasswd Command in Linux with examples

gpasswd command is used to administer the /etc/group and /etc/gshadow. As every group in Linux has administrators, members, and a password. It is an inherent security problem as more than one person is permitted to know the password. However, groups can perform co-operation between different users. This command assigns a user to a group with some security criteria. This command is called by a group administrator with a group name only which prompts for the new password of the group. System administrators can use the -A option to define group administrator(s) and -M option to define members. They have all the rights of the group administrators and members.

Similar Reads

Basic Syntax of gpasswd Command:

The basic syntax of the gpasswd command is straightforward:...

Options in gpasswd Command:

Here only -A and -M options can be combined....

Examples of gpasswd Command :

Creating a group and adding a user to it. After that deleting the user....

gpasswd command – FAQs

What is the gpasswd command in Linux, and what does it do?...

Conclusion

In conclusion, the gpasswd command in Linux serves as a crucial tool for managing group passwords and membership, addressing inherent security challenges by enabling administrators to control access effectively. Through its simple syntax and various options like adding or removing users, setting passwords, and designating administrators and members, gpasswd empowers system administrators to enhance security and collaboration within the Linux environment....