Welcome to the Linux Foundation Forum!

I messed up the sudoers file, please help correct it


I created a file for user ubuntu under /etc/sudoers.d but had a typo, so I could not run commands as sudo. Would you please help delete the file or correct the typo by changing "PASSWORD" to "PASSWD"?



  • unitiger
    unitiger Posts: 5

    I noticed the environment has been refreshed, no issue any more, please ignore the question. Sorry for any confusion.

  • coop
    coop Posts: 915

    I don't quite understand how this got fixed, but in the future:

    1) Do not edit files in /etc/sudoers.d directly, but use "visudo" as in "visudo ubuntu" as it checks for errors before saving. WIthout an argument, visudo works directly on /etc/sudoers, but with an argument it works on the file you care about.

    2) On a non-ubuntu like system (where the root account is hidden behind sudo) you can do a "su" to become root and fix.
    On a system where the superuser is a normal user and only sudo is used normally, your only other course of remedy is to boot into an emergency kernel and try to fix there, usually just do a rm /etc/sudoers.d/[whatever].

    3) If it is a virtual machine you can use the hypervisor's ability to mount the disk on the host system, and go in and edit the
    file and then boot. In vmware this is really easy as the "Machine settings" gui works just fine or you can use vmware-mount
    from the command line. I don't remember how to do this in virtual box but I'm sure you can and I know you can with kvm.


Upcoming Training