I have somehow locked or removed my access to sudo – how can I fix it? [duplicate]

I am fairly new at Ubuntu system and commands. I was trying to follow some tutorial online explaining how to setup using no password to download apps. I was in visudo, and next thing I know I can’t use the sudo command, nor download any software/apps.

I don’t know where to start looking. If anyone could point me in the right direction, that would be an awesome way to start my weekend.


visudo edits the sudoers file, which defines the users and groups with administrator rights.
So It looks like you have changed `/etc/sudoers’. Now you can’t edit it so only way to edit it is by running Ubuntu directly from either a USB stick or a DVD and edit it back to its original.

for that:

Boot from Ubuntu installation DVD or USB drive and choose ‘Try Ubuntu without installing’. Mount the partition of your Ubuntu Installation. If you are not sure which one, launch GParted (included in the Ubuntu installation DVD or USB) or. Open a terminal (Ctrl+Alt+T) and use the following command:

sudo fdisk -l

and find out. It is usually a EXT4 Partition. Replace the XX with the drive letter, and partition number, for example: sudo mount /dev/sda1 /mnt.

sudo mount /dev/sdXX /mnt

XX being the partition where Ubuntu is installed.


sudo gedit /mnt/etc/sudoers

and edit the file as per the text here

If you want to disable password for sudo add this line


below the line

%sudo   ALL=(ALL:ALL) ALL

save and

sudo umount /mnt


sudo reboot

Boot into your Ubuntu. Done.

Source : Link , Question Author : Mike Dugger , Answer Author : Vijay

Leave a Comment