usermod returns "group 'thegroupname' does not exist" for known group

15,036

I was trying to add a local user to an Active Directory group. This is not allowed.

Share:
15,036

Related videos on Youtube

Louis Waweru
Author by

Louis Waweru

Updated on September 18, 2022

Comments

  • Louis Waweru
    Louis Waweru over 1 year

    As a member of sudo can I add myself to a group I don't belong to?

    $ getent group thegroupname 
    thegroupname:x:123794798:administrator,users,auser,moreusers,manymoreusers
    
    $ sudo usermod -a -G thegroupname myusername
    usermod: group 'thegroupname' does not exist
    

    When I run the above I can't add myself to the group. The error message says the group doesn't exist, but it does.

    Here I'll make a new group as per @terdon's comment.

    $ sudo groupadd testgroup
    useradd: user 'myusername' already exists
    $ groups
    myusername sudo users
    
    $ getent group testgroup
    testgroup:x:01234:
    
    
    $ sudo usermod -a -G testgroup myusername
    $ groups myusername
    myusername : myusername sudo users testgroup
    

    Sorry for the typo with just using groups instead of groups myusername. I'm not sure if that information is helpful as it still shows me as not belonging to the test group while groups myusername does.

    $ groups
    myusername sudo users
    
    • terdon
      terdon almost 9 years
      I suppose that creating a new group and adding your user to it does work as expected right? It's only thisgroupname that fails?
    • Louis Waweru
      Louis Waweru almost 9 years
      @terdon I'm not sure. I could use usermod but not groupadd. I've updated the question based on your feedback.
    • Louis Waweru
      Louis Waweru almost 9 years
      @terdon reading that again, it seems the answer to your question is "yes".
    • terdon
      terdon almost 9 years
      Hmm. Strange. Could you fix the typo you where groupadd prints a useradd error message (2nd code line in your edit)?
    • Louis Waweru
      Louis Waweru almost 9 years
      @terdon Doh, I overlooked something obvious trying to add a local account to an Active Directory group. If you want to post that in an answer, feel free! Thanks for your troubleshooting.
    • terdon
      terdon almost 9 years
      Huh? You mean the issue was thta you were running sudo useradd testgroup instead of groupadd? If so, lol, and nah, not worth posting an answer, just delete it. It's unlikely to help anyone else.