Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 2094  / 1 Year ago, mon, january 16, 2023, 3:52:31

About user and groups administration I found in many tutorials that appear:



  • gpasswd - to add and delete users to a group

  • usermod/deluser - to add, modify and delete users of a group


What is not very clear is - When gpasswd would be mandatory over usermod/deluser and viceversa?


More From » users

 Answers
1

deluser is a command to delete an user altogether from the system, not to remove an user from group.


There is no moduser command, you probably meant usermod.


Both with usermod and gpasswd you can add/remove users to/from group. They are two different ways to achieve the same.


However, you cannot change the user's primary group with gpasswd. That can be done with usermod only. gpasswd manages only so called supplementary groups. You can view user's primary and supplementary groups with a command: id -a username. Sample output:


uid=1000(raj) gid=1000(raj) groups=1000(raj),4(adm),20(dialout),24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),131(lxd),132(sambashare)

The group listed as gid= is the user's primary group. groups= lists all groups the user belongs to (primary group is first, followed by supplementary groups).


There are also some things (not directly related to group membership) that each of those commands can do. With usermod you can modify other attributes of the user (like users' default shell or home directory), and with gpasswd you can set a group password, that allows users who are not members of the group to temporarily join the group if they know the password.


[#1150] Monday, January 16, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
truwom

Total Points: 101
Total Questions: 99
Total Answers: 100

Location: Ivory Coast
Member since Tue, Sep 15, 2020
4 Years ago
;