https://unix.stackexchange.com/questions/410367/how-to-get-the-primary-group-of-a-user
Group ID (GID)
The Group ID (GID) is a number used to uniquely identify the primary group that the user
https://unix.stackexchange.com/questions/605531/primary-vs-secondary-groups-in-linux
Primary group – Specifies a group that the operating system assigns to files that are created by the user. Each user must belong to a primary group.
Secondary groups – Specifies one or more groups to which a user also belongs. Users can belong to up to 15 secondary groups.
https://askubuntu.com/questions/165942/how-to-change-primary-group
https://www.freecodecamp.org/news/linux-user-groups-explained-how-to-add-a-new-group-a-new-group-member-and-change-groups/
create user:
useradd -m quincy -p password
add user to secondary group
usermod -a -G writers quincy
change user's primary group based on secondary group
usermod -g editors quincy
To remove a user from a secondary group you need to overwrite the current groups of a user with a new set of groups that does not contain the group that is being removed.
First, use the id command to check what secondary groups a user belongs to:
id -nG quincy
Let's say that this returns editors writers indicating that quincy is part of the "editors" and "writers" group. If you want to remove the "writers" group, use this command:
usermod -G editors quincy
No comments:
Post a Comment