Results 1 to 10 of 10

Thread: User not in sudoers anymore.

  1. #1
    Join Date
    Nov 2012
    Beans
    25

    User not in sudoers anymore.

    I was trying to give my user (lenz) root privileges for running commands.
    So I edited the sudoers file in /etc using gedit, and I added lenz ALL=(ALL:ALL) ALL to the sudoers.

    But I made an error any mistyped "lenz" for lenzi... Now my user (lenz) is not in the sudoers file anymore. When I try to edit the sudoers file, it:
    Code:
    lenz@lenz-Studio-1537:~$ sudo visudo /etc/sudoers
    [sudo] password for lenz: 
    lenz is not in the sudoers file.  This incident will be reported.
    lenz is the only user (other than root) on this system.

    How could I solve this problem? I'd need to log in as root and edit the sudoers file again, right?

    Help me please...

  2. #2
    Join Date
    Apr 2012
    Beans
    5,531

    Re: User not in sudoers anymore.

    IMO adding individual users to the sudoers file only makes sense if you want to grant / deny permission for individual commands

    If you want to give a user general administrative privileges you just need to add them to the 'sudo' user group (or 'admin' on older versions of Ubuntu)

    Code:
    gpasswd --adduser lenz sudo
    You will need to do this as root from the recovery console if you don't have another valid sudo login. Then edit /etc/sudoers back to how it was before.

  3. #3
    Join Date
    May 2009
    Location
    Fareham, UK
    Beans
    Hidden!
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: User not in sudoers anymore.

    Boot into a live cd/usb and use sudo from there to edit the file /etc/sudoers and correct your mistake
    Catch me on Freenode - imark

  4. #4
    Join Date
    Nov 2012
    Beans
    25

    Re: User not in sudoers anymore.

    Thanks for quick & helpful response, Captain Mark & Steeldriver.

    You will need to do this as root from the recovery console if you don't have another valid sudo login. Then edit /etc/sudoers back to how it was before.
    Indeed I'll have to use a recovery disk, because:
    Code:
    lenz@lenz-Studio-1537:~$ sudo gpasswd --add lenz sudo
    [sudo] password for lenz: 
    lenz is not in the sudoers file.  This incident will be reported.
    When logged in as root, what would be the commands I'd have to type to be able to edit/reset the sudoers file? Do I have to use vi to edit it?

  5. #5
    Join Date
    Apr 2012
    Beans
    5,531

    Re: User not in sudoers anymore.

    You should use 'visudo' regardless of how you are logged in afaik - iirc it provides some basic checks to stop you screwing up the file. The actual editor it uses under the hood will depend on how your default editor is set.

    You *could* do everything from a live cd / usb boot if you prefer - personally I think it's more work though (need to mount the original root partition etc.)

  6. #6
    Join Date
    Nov 2012
    Beans
    25

    Re: User not in sudoers anymore.

    Quote Originally Posted by steeldriver View Post
    You should use 'visudo' regardless of how you are logged in afaik - iirc it provides some basic checks to stop you screwing up the file. The actual editor it uses under the hood will depend on how your default editor is set.

    You *could* do everything from a live cd / usb boot if you prefer - personally I think it's more work though (need to mount the original root partition etc.)
    So how would I do it from the recovery console?

  7. #7
    Join Date
    Apr 2012
    Beans
    5,531

    Re: User not in sudoers anymore.


  8. #8
    Join Date
    Nov 2012
    Beans
    25

    Re: User not in sudoers anymore.

    Thanks a lot, steeldriver.

    I'll be back in 20mins to tell you whether or not this is to be tagged [solved].

  9. #9
    Join Date
    Aug 2011
    Location
    52° N 6° E
    Beans
    2,555
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: User not in sudoers anymore.

    In which case you can tag it as [solved] yourself, see the thread tools near the top of this page.

  10. #10
    Join Date
    Nov 2012
    Beans
    25

    Re: User not in sudoers anymore.

    Worked fine, thanks for your help.

Tags for this Thread

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
  •