Here’s how to add an existing user to a user group in Linux.
usermod -a -G groupname username usermod -a -G www-data john |
List all users belonging to a group.
lid -g www-data |
List all the groups the user belongs to.
groups john |
cloud engineer
Here’s how to add an existing user to a user group in Linux.
usermod -a -G groupname username usermod -a -G www-data john |
usermod -a -G groupname username usermod -a -G www-data john
List all users belonging to a group.
lid -g www-data |
lid -g www-data
List all the groups the user belongs to.
groups john |
groups john
Here’s the command to add a Linux user.
useradd -m -s $(which bash) -G sudo ulysses |
useradd -m -s $(which bash) -G sudo ulysses
-m creates a home directory. -s selects a shell. -G adds user to a sudo group.
Here’s an alternate way to give Linux users sudo access by adding them to the wheel group. Most Linux systems come with the wheel group already predefined. By adding users to the wheel group, they now have the ability to sudo and run root commands. The wheel group is in the sudoers file for Redhat, Centos, Debian and Ubuntu.
usermod -aG wheel username |
usermod -aG wheel username