Announcement

Collapse
No announcement yet.

[fixed] can't use sudo because not in sudoers file

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [fixed] can't use sudo because not in sudoers file

    My worst fear about Ubuntu has been realized. I can't run commands with sudo because all of a sudden I'm not in /etc/sudoers and of course I can't edit /etc/sudoers because I can't do "sudo kate /etc/sudoers". Nor can I log out of my regular user account and log in as root because during the OS installation I was never asked for a password for the root account. I have only my password for my regular account and when I do sudo kate /etc/sudoers it replies:

    jujube@norman64:~$ sudo kate /etc/sudoers
    [sudo] password for jujube:
    jujube is not in the sudoers file. This incident will be reported.
    jujube@norman64:~$

    I don't know if it makes any difference but when I installed the OS (Kubuntu 11.10) I elected to have it log me in automatically. The sudo command worked perfectly for 2 months until today. I've never edited the sudoers file so how could I be removed from it (asking to prevent this happening again in the future)?

    I've rebooted but that hasn't helped. What can I do to get me back in the sudoers file? Is there another way out of this?

    #2
    Re: can't use sudo because not in sudoers file

    Ok, try some of the fixes suggested by Psychocats: http://www.psychocats.net/ubuntu/fixsudo

    I've no idea what could break sudo like that though.

    .

    Comment


      #3
      Re: can't use sudo because not in sudoers file

      Thanks very much! As suggested at psychocats, my username somehow got removed from the admins group. I think Santa Claus did it. I was bad this year ;-)

      Comment


        #4
        Re: can't use sudo because not in sudoers file

        Originally posted by jujube
        when I installed the OS (Kubuntu 11.10) I elected to have it log me in automatically. The sudo command worked perfectly for 2 months until today. I've never edited the sudoers file
        I've never built a machine with auto-login enabled, so it's difficult to predict whether that's a cause. I know that if you perform a command-line install of Ubuntu, it doesn't create the admin group at all -- that's a manual step you have to take. But it sounds like this wasn't what you did.

        Between your install date and when sudo broke, what else have you done on your system? Have you installed anything? Updated anything?

        Comment


          #5
          Re: can't use sudo because not in sudoers file

          Originally posted by jujube
          My worst fear about Ubuntu has been realized. I can't run commands with sudo because all of a sudden I'm not in /etc/sudoers and of course I can't edit /etc/sudoers because I can't do "sudo kate /etc/sudoers". Nor can I log out of my regular user account and log in as root because during the OS installation I was never asked for a password for the root account. I have only my password for my regular account and when I do sudo kate /etc/sudoers it replies:

          jujube@norman64:~$ sudo kate /etc/sudoers
          [sudo] password for jujube:
          jujube is not in the sudoers file. This incident will be reported.
          jujube@norman64:~$

          I don't know if it makes any difference but when I installed the OS (Kubuntu 11.10) I elected to have it log me in automatically. The sudo command worked perfectly for 2 months until today. I've never edited the sudoers file so how could I be removed from it (asking to prevent this happening again in the future)?

          I've rebooted but that hasn't helped. What can I do to get me back in the sudoers file? Is there another way out of this?
          Glad you got it working, but as a general rule, the first thing I do when I set up any new *ubuntu system is set the root password after installation. This way, I can always su - to root...

          Just sudo -i to root and then issue passwd and set the password. Then, no matter what you ever do to your account, you can always get to root when needed .

          Hope this helps!

          Joe

          Comment


            #6
            Re: can't use sudo because not in sudoers file

            Originally posted by SteveRiley
            Originally posted by jujube
            when I installed the OS (Kubuntu 11.10) I elected to have it log me in automatically. The sudo command worked perfectly for 2 months until today. I've never edited the sudoers file
            I've never built a machine with auto-login enabled, so it's difficult to predict whether that's a cause. I know that if you perform a command-line install of Ubuntu, it doesn't create the admin group at all -- that's a manual step you have to take. But it sounds like this wasn't what you did.

            Between your install date and when sudo broke, what else have you done on your system? Have you installed anything? Updated anything?
            I've done all of that and more. I run BOINC 24/7/365, develop software, run Windows in a VM, run 4 VMs in 4 primary VMs running as guests on the host, edit video, live video online chat. I think what caused me to be deleted from the sudoers file was that I mistakenly used the adduser command to add me to an existing group. I think adduser is not intended for that purpose and it deleted me from sudoers file. Just a few hours after using the adduser command incorrectly I discovered I was no longer in sudoers file.

            Comment


              #7
              Re: can't use sudo because not in sudoers file

              Originally posted by LinuxRocks
              Originally posted by jujube
              My worst fear about Ubuntu has been realized. I can't run commands with sudo because all of a sudden I'm not in /etc/sudoers and of course I can't edit /etc/sudoers because I can't do "sudo kate /etc/sudoers". Nor can I log out of my regular user account and log in as root because during the OS installation I was never asked for a password for the root account. I have only my password for my regular account and when I do sudo kate /etc/sudoers it replies:

              jujube@norman64:~$ sudo kate /etc/sudoers
              [sudo] password for jujube:
              jujube is not in the sudoers file. This incident will be reported.
              jujube@norman64:~$

              I don't know if it makes any difference but when I installed the OS (Kubuntu 11.10) I elected to have it log me in automatically. The sudo command worked perfectly for 2 months until today. I've never edited the sudoers file so how could I be removed from it (asking to prevent this happening again in the future)?

              I've rebooted but that hasn't helped. What can I do to get me back in the sudoers file? Is there another way out of this?
              Glad you got it working, but as a general rule, the first thing I do when I set up any new *ubuntu system is set the root password after installation. This way, I can always su - to root...

              Just sudo -i to root and then issue passwd and set the password. Then, no matter what you ever do to your account, you can always get to root when needed .

              Hope this helps!

              Joe
              Thanks for that suggestion, Joe! I've run Fedora for years and miss being able to just su to root. I hate having to preface commands with sudo. Yes, I am aware of the security implications but I'll live with it rather than typing sudo all the time.

              Comment


                #8
                Re: can't use sudo because not in sudoers file

                Originally posted by jujube
                I think what caused me to be deleted from the sudoers file was that I mistakenly used the adduser command to add me to an existing group. I think adduser is not intended for that purpose and it deleted me from sudoers file. Just a few hours after using the adduser command incorrectly I discovered I was no longer in sudoers file.
                Hmm...

                adduser existing-user existing-group

                ...shouldn't do anything other that what you expect: add the existing user to the existing group without changing any other group membership.

                If you're inclined to examine what happened, the command still might be in your .bash_history file...

                Comment


                  #9
                  Re: can't use sudo because not in sudoers file

                  Originally posted by jujube
                  Thanks for that suggestion, Joe! I've run Fedora for years and miss being able to just su to root. I hate having to preface commands with sudo. Yes, I am aware of the security implications but I'll live with it rather than typing sudo all the time.
                  When I set up an Ubuntu box for friends and family, the first thing I do is enable the root account. One doesn't even have to use it, but having it can be beneficial in times of trouble.
                  "The only way Kubuntu could be more user friendly would be if it came with a virtual copy of Snowhog and dibl"

                  Comment


                    #10
                    Re: can't use sudo because not in sudoers file

                    Originally posted by SteveRiley
                    Originally posted by jujube
                    I think what caused me to be deleted from the sudoers file was that I mistakenly used the adduser command to add me to an existing group. I think adduser is not intended for that purpose and it deleted me from sudoers file. Just a few hours after using the adduser command incorrectly I discovered I was no longer in sudoers file.
                    Hmm...

                    adduser existing-user existing-group

                    ...shouldn't do anything other that what you expect: add the existing user to the existing group without changing any other group membership.

                    If you're inclined to examine what happened, the command still might be in your .bash_history file...
                    I reversed the existing-user and existing-group parameters and added a -G (for group) parameter thusly:

                    adduser -G existing-group existing-user

                    I didn't get an error msg so I thought it worked.

                    Comment


                      #11
                      Re: [fixed] can't use sudo because not in sudoers file

                      Originally posted by jujube
                      I reversed the existing-user and existing-group parameters and added a -G (for group) parameter thusly:

                      adduser -G existing-group existing-user

                      I didn't get an error msg so I thought it worked.
                      Hmm... that syntax throws an error for me. Admittedly, I haven't played with user accounts too much on Linux. In my testing, the lower-level useradd utility didn't work for modifying group memberships if the user already exists. The usermod utility with the -G switch operates in replace mode; it removes the user from existing groups and adds to the groups you specify.

                      Comment

                      Working...
                      X