4

I don't know what came in my mind that I just typed this in my shell:

sudo chmod 700 /usr/bin/sudo

and then also entered my password. The above command ran and I lost control over sudo. sudo is owned by root. I am not the root user. My username is aditya.

Previously sudo had a permission of 711. That means I could execute it being a non-root user. But now, I have lost control.

When I try to access sudo from my shell, I get:

-bash: /usr/bin/sudo: Permission denied  

Is there any way I can re-gain access to sudo without having to re-install my OS or call some engineer to fix it?

1 Answer 1

3

First use pkgutil to list the installer information for sudo.

pkgutil --file-info /usr/bin/sudo

Note the mode which is the permissions in octal notation for the file.

Shutdown your computer and then start the computer holding down the command key and the "s" key. You are booting the computer into single user mode.

At the prompt force check the file system with the command

/sbin/fsck -fy

then mount the file system read write

/sbin/mount -uw /

Now change the permissions on sudo

chmod 4511 /usr/bin/sudo

Then reboot the computer

reboot
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .