Scenario / Questions
I am aware that usermod -g is not best practice from many posts like this however they normally explain the usermod should not be used as it changes the primary group of a user. These posts dont seem to take into account the -aG switch which just appends the group.
Is this still poor practice or no different than using gpasswd -a?
Find below all possible solutions or suggestions for the above questions..
They both can do the same, it’s just with
usermod you can do it wrong if you don’t pay enough attention.
In this wiki from Arch Linux (it is the same for other distros), it’s explained:
To add a user to other groups use (additional_groups is a
# usermod -aG additional_groups username
Warning: If the
-aoption is omitted in the
usermodcommand above, the
user is removed from all groups not listed in additional_groups (i.e.
the user will be member only of those groups listed in
gpasswdmay be used. Though the username can only be
added (or removed) from one group at a time.
# gpasswd --add username group
Kubernetes Free Online Tutorial, Kubernetes Beginner Tutorial
DevOps Free Online Tutorial, DevOps Beginner Tutorial
Ansible Free Online Tutorial, Ansible Beginner Tutorial
Docker Free Online Tutorial, Docker Beginner Tutorial
Openstack Free Online Tutorial, Openstack Beginner Tutorial
Disclaimer: This has been sourced from a third party syndicated feed through internet. We are not responsibility or liability for its dependability, trustworthiness, reliability and data of the text. We reserves the sole right to alter, delete or remove (without notice) the content in its absolute discretion for any reason whatsoever.