Usermod and history output

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite












I used usermod -G without the -a option, now the main user has only 2 groups. I want to restore all the previous groups but the problem is that i need to list all the groups before the changes



I am trying to use




locate /etc/groups




and grep username in the previous version of the file to get all the previous group



How can I access to the file from the db and read them ?







share|improve this question






















  • Possible duplicate of Default groups for user in Ubuntu?
    – muru
    May 15 at 15:46










  • And you'll probably need askubuntu.com/q/70442/158442 as well to get back your lost sudo rights.
    – muru
    May 15 at 15:46






  • 1




    Possible duplicate of How do I add myself back as a sudo user?
    – karel
    May 15 at 21:03














up vote
1
down vote

favorite












I used usermod -G without the -a option, now the main user has only 2 groups. I want to restore all the previous groups but the problem is that i need to list all the groups before the changes



I am trying to use




locate /etc/groups




and grep username in the previous version of the file to get all the previous group



How can I access to the file from the db and read them ?







share|improve this question






















  • Possible duplicate of Default groups for user in Ubuntu?
    – muru
    May 15 at 15:46










  • And you'll probably need askubuntu.com/q/70442/158442 as well to get back your lost sudo rights.
    – muru
    May 15 at 15:46






  • 1




    Possible duplicate of How do I add myself back as a sudo user?
    – karel
    May 15 at 21:03












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I used usermod -G without the -a option, now the main user has only 2 groups. I want to restore all the previous groups but the problem is that i need to list all the groups before the changes



I am trying to use




locate /etc/groups




and grep username in the previous version of the file to get all the previous group



How can I access to the file from the db and read them ?







share|improve this question














I used usermod -G without the -a option, now the main user has only 2 groups. I want to restore all the previous groups but the problem is that i need to list all the groups before the changes



I am trying to use




locate /etc/groups




and grep username in the previous version of the file to get all the previous group



How can I access to the file from the db and read them ?









share|improve this question













share|improve this question




share|improve this question








edited May 15 at 15:52

























asked May 15 at 15:14









eDen

379




379











  • Possible duplicate of Default groups for user in Ubuntu?
    – muru
    May 15 at 15:46










  • And you'll probably need askubuntu.com/q/70442/158442 as well to get back your lost sudo rights.
    – muru
    May 15 at 15:46






  • 1




    Possible duplicate of How do I add myself back as a sudo user?
    – karel
    May 15 at 21:03
















  • Possible duplicate of Default groups for user in Ubuntu?
    – muru
    May 15 at 15:46










  • And you'll probably need askubuntu.com/q/70442/158442 as well to get back your lost sudo rights.
    – muru
    May 15 at 15:46






  • 1




    Possible duplicate of How do I add myself back as a sudo user?
    – karel
    May 15 at 21:03















Possible duplicate of Default groups for user in Ubuntu?
– muru
May 15 at 15:46




Possible duplicate of Default groups for user in Ubuntu?
– muru
May 15 at 15:46












And you'll probably need askubuntu.com/q/70442/158442 as well to get back your lost sudo rights.
– muru
May 15 at 15:46




And you'll probably need askubuntu.com/q/70442/158442 as well to get back your lost sudo rights.
– muru
May 15 at 15:46




1




1




Possible duplicate of How do I add myself back as a sudo user?
– karel
May 15 at 21:03




Possible duplicate of How do I add myself back as a sudo user?
– karel
May 15 at 21:03










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










There is no /etc/groups. There's /etc/group and /etc/group- (the backup). To get results for your user from the backup, you can do:



grep username /etc/group-


Or, to get just the groups, using awk:



awk -F: -v u=username '$NF ~ u print $1' /etc/group-


To then add those groups back, as root:



awk -F: -v u=username '$NF ~ u print $1' /etc/group- |
xargs -n1 gpasswd -a username





share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1036577%2fusermod-and-history-output%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    There is no /etc/groups. There's /etc/group and /etc/group- (the backup). To get results for your user from the backup, you can do:



    grep username /etc/group-


    Or, to get just the groups, using awk:



    awk -F: -v u=username '$NF ~ u print $1' /etc/group-


    To then add those groups back, as root:



    awk -F: -v u=username '$NF ~ u print $1' /etc/group- |
    xargs -n1 gpasswd -a username





    share|improve this answer
























      up vote
      1
      down vote



      accepted










      There is no /etc/groups. There's /etc/group and /etc/group- (the backup). To get results for your user from the backup, you can do:



      grep username /etc/group-


      Or, to get just the groups, using awk:



      awk -F: -v u=username '$NF ~ u print $1' /etc/group-


      To then add those groups back, as root:



      awk -F: -v u=username '$NF ~ u print $1' /etc/group- |
      xargs -n1 gpasswd -a username





      share|improve this answer






















        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        There is no /etc/groups. There's /etc/group and /etc/group- (the backup). To get results for your user from the backup, you can do:



        grep username /etc/group-


        Or, to get just the groups, using awk:



        awk -F: -v u=username '$NF ~ u print $1' /etc/group-


        To then add those groups back, as root:



        awk -F: -v u=username '$NF ~ u print $1' /etc/group- |
        xargs -n1 gpasswd -a username





        share|improve this answer












        There is no /etc/groups. There's /etc/group and /etc/group- (the backup). To get results for your user from the backup, you can do:



        grep username /etc/group-


        Or, to get just the groups, using awk:



        awk -F: -v u=username '$NF ~ u print $1' /etc/group-


        To then add those groups back, as root:



        awk -F: -v u=username '$NF ~ u print $1' /etc/group- |
        xargs -n1 gpasswd -a username






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 15 at 16:04









        muru

        129k19271460




        129k19271460






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1036577%2fusermod-and-history-output%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491