Linux Tutorial
Linux File/Directory Management
Linux Packaging And Compression
Vim Text Editor
Linux Text Processing
Linux Software Installation
Linux User/User Group Management
Linux Permission Management
Linux Filesystem Management
Linux Advanced Filesystem Management
Linux System Management
Linux Backup and Recovery
Linux System Service Management
Linux System Log Management
Linux Boot Management
LAMP/LNMP Environment
SELinux Management
gpasswd
is a command-line utility in Linux used to administer the /etc/group
and /etc/gshadow
files. It allows you to manage group membership by adding or removing users from groups. In this tutorial, we will go over the basics of the gpasswd
command and its usage.
The basic syntax for the gpasswd
command is:
gpasswd [options] group
Here are some common tasks you can perform with the gpasswd
command:
To add a user to a group, use the -a
option followed by the username and the group name:
sudo gpasswd -a username groupname
To remove a user from a group, use the -d
option followed by the username and the group name:
sudo gpasswd -d username groupname
To set a password for a group, use the -A
option followed by the group name. You will be prompted to enter and confirm the password:
sudo gpasswd groupname
To remove a password from a group, use the -r
option followed by the group name:
sudo gpasswd -r groupname
To display information about a group, use the -M
option followed by the group name:
sudo gpasswd -M groupname
Here are some examples to illustrate the usage of the gpasswd
command:
john
to the group developers
:sudo gpasswd -a john developers
john
from the group developers
:sudo gpasswd -d john developers
developers
:sudo gpasswd developers
developers
:sudo gpasswd -r developers
developers
:sudo gpasswd -M developers
In summary, the gpasswd
command is a useful utility for managing group memberships and passwords in Linux. It provides an efficient way to add or remove users from groups and set group passwords as needed.
How to use the gpasswd
command in Linux:
gpasswd
is a command-line tool in Linux used for managing group memberships and properties.gpasswd
Adding users to groups with gpasswd
:
gpasswd
to add users to a specific group.gpasswd -a username groupname
Removing users from groups using gpasswd
:
-d
option with gpasswd
.gpasswd -d username groupname
Managing group membership with gpasswd
:
gpasswd
allows you to manage group memberships, adding or removing users as needed.gpasswd -a username groupname # Add user to group gpasswd -d username groupname # Remove user from group
Assigning a new group owner with gpasswd
:
gpasswd
to set a new group owner.gpasswd -A newowner groupname
Viewing group membership using gpasswd
:
gpasswd
without any additional options.gpasswd groupname
Setting group password with gpasswd
in Linux:
gpasswd
.sudo gpasswd -r groupname # Remove password sudo gpasswd -a username groupname # Add user to group
Batch adding and removing users with gpasswd
:
gpasswd -M user1,user2 groupname # Set members