linuxsudoers

How to edit the sudoers file when it has nothing and has no permission?


I login with non-root user, e.g. jason, and can not edit the /etc/sudoers file. After type "ls -la /etc/sudoers", it shows following:

-r--r----- 1 root root 792 Jan  6 06:31 /etc/sudoers

And type "vi /etc/sudoers", the file shows nothing, it is empty. However I have no permission to edit it, and also cannot become a root user.

How to edit the sudoers file to edit the "jason" user?


Solution

  • This is a basic security feature.

    If you don't have root permissions (sudo), you should not be able to edit the sudoers file (if not you wil just give yourself permissions)

    note: never edit directly the sudoers file, but use the command visudo. This will validate the file before saving it, preventing to save a corrupt file and 'locking yourself out'