Results 1 to 5 of 5

Thread: gpasswd question

  1. #1
    Join Date
    Aug 2024
    Beans
    12

    Question gpasswd question

    Hello Forum,

    Is there a way to remove multiple users from a group with gpasswd or any other tool?
    I know you can add multiple users by entering the following:

    Code:
    sudo gpasswd -M userA,userB,userC mygroup
    But can I don't know if you can do the opposite.

    Any suggestions would be highly appreciate it!!!

  2. #2
    Join Date
    Jun 2010
    Location
    London, England
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: gpasswd question

    Open a terminal and type

    Code:
    man gpasswd
    That will tell you what you can do with gpasswd.

    Regards
    It is a machine. It is more stupid than we are. It will not stop us from doing stupid things.
    Ubuntu user #33,200. Linux user #530,530


  3. #3
    Join Date
    Jun 2014
    Beans
    7,895

    Re: gpasswd question

    If the man pages aren't good for you, do an online search for sites which might be a little more informative and easy to follow, one such site at the link below.

    https://www.geeksforgeeks.org/how-to...roup-in-linux/

  4. #4
    Join Date
    Dec 2014
    Beans
    2,721

    Re: gpasswd question

    You misunderstand the way the '-M' option works. It doesn't add members to the group, it sets the group to have these (and only these) members. If mygroup has the users UserB,UserC,UserD, and UserE then the result of 'gpasswd -M UserA,UserB,UserC' is that UserA is added to the group and UserD and UserE are removed from it.

    Another way to remove multiple users from a group is looping over a list of users you want removed and run the command to remove each user like so:
    Code:
    for user in username anotheruser onemore ; do gpasswd -d $user mygroup; done
    Holger

  5. #5
    Join Date
    Mar 2010
    Location
    Been there, meh.
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: gpasswd question

    This may seem old school, but I'd use sudoedit on the 3 relevant files in /etc/. What each field means is well documented in the manpage for each. The file formats are pretty simple.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •