By default, in Ubuntu, the first user account you created during the installation process is also the administrator of the system. Using this user account, he/she is able to perform administrative tasks with the “sudo” command. If you are not aware, “sudo” refers to Super User Do and all users in this group are geared with administrative rights to manage the system. However, if you accidentally removed yourself from this “sudo” group, you will not be able to do anything. Instead, the only thing you will see is:
damien is not in the sudoers file. This incident will be reported
How I removed myself from the sudo group
For my case, while adding myself to another group, I used the command
without using the ‘
-a‘ parameter and this cause myself to be removed from the sudo group. While I still can use the computer (as a standard user), I am no longer able to update the system, nor install/remove applications.
If you are in the same situation like me, here’s the fix:
1. Reboot the computer. If Ubuntu is your primary and the only operating system in your computer, press the “Shift” button when it is booting up. This should make the Grub screen show up on your monitor. On the Grub screen, press the down button to the Recovery mode and press Enter.
2. On the next screen, select “Check all file system (will exit read only mode)”.
When you see the message “Finished, press Enter“, press Enter.
3. Next, select “Drop to root shell prompt”.
4. You will now be at the command line. Type:
Replace the username with your own login name.
5. That’s it. Now type “
exit” and select “Resume normal boot”.
Follow these steps only if you have messed up the /etc/sudoers file
The above steps assume that your /etc/sudoers file is still intact. If you have mishandled the /etc/sudoers file and cause it to be corrupted. Here is what you need to do:
1. Do the above steps until Step 3.
2. At the command line, type
Enter the following lines to the file
Press “Ctrl + o” to save the file and “Ctrl + x” to exit.
3. Next, set the file permission of the sudoers file:
4. Lastly, add yourself to the sudo group:
exit the shell prompt and resume normal boot.
You should be able to perform administrative task again.