7

I was messing with ubuntu trying to make autogen.sh work and did a dumb thing. I typed:

sudo chown -R emilia /usr/bin/

and after that I cannot use sudo anymore.

I tried so far:

logging as root and typing:

chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo

Didn't help.

I ran some tests and here are the results:

emilia@emilia:~$ ls -la /usr/bin | grep -v "root *root"
total 147656
drwxr-xr-x  2 emilia root      65536 Aug 14 16:06 .
-rwxr-xr-x  1 emilia root      51920 Feb 18 14:37 [
lrwxrwxrwx  1 emilia root          8 Aug  7 16:04 2to3 -> 2to3-2.7
-rwxr-xr-x  1 emilia root         96 Jul  2 21:02 2to3-2.7

emilia@tenshi:~$ ls -la /usr/bin | grep -v "rwxr-xr-x\|^l"
total 147656
-rwxrwxr-x  1 emilia emilia       22 Aug 14 16:06 autogen.sh

emilia@emilia:~$ ls -l /usr/bin/sudo
-rwxr-xr-x 1 emilia root 136808 Maj  4 19:25 /usr/bin/sudo
6
  • 2
    Are you sure you ran the commands you say as root? Were there any errors? What happened? The chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo should have at least fixed the permissions and ownership of the sudo binary.
    – terdon
    Aug 14, 2016 at 14:45
  • @terdon yes I was sure, I entered root by restarting, entering advanced ubuntu settings, root and then I entered those commands. No errors were shown.
    – Mirakurun
    Aug 14, 2016 at 15:21
  • could you please do the same thing again and show us the output of your ls commands run as root?
    – terdon
    Aug 14, 2016 at 15:24
  • @terdon postimg.org/image/5gw0yc4d5
    – Mirakurun
    Aug 14, 2016 at 15:37
  • 1
    there we go, that's what I thought. You see the error messages about read only file system? You need to remount it read write. Run mount -o rw,remount / before attempting to fix the permissions.
    – terdon
    Aug 14, 2016 at 15:42

2 Answers 2

14

Since you cannot use sudo anymore, there are two things you can do:

  1. If you have placed a root password (not your user password), use su on a terminal and you will be able to use the root account by using that password.

  2. If you haven't placed a root password, you can reboot your system and go to Recovery mode, and open a root session. Since you haven't placed a root password you won't be asked to enter one. After that, type: mount -o rw,remount / and press Enter to enable read/write access to your system.

Having gained root access by either of the methods above, issue chown -R root:root /usr/bin and you should be back to business.

2
  • That did the trick.
    – Mirakurun
    Aug 14, 2016 at 15:57
  • Very nice. You will probably have to restore some permissions now since you changed them but having root access now, that won't be an issue. ;-)
    – Stormlord
    Aug 14, 2016 at 16:02
10

Your commands are not working because recovery mode mounts the file system as read-only. To make it writable, run this command:

mount -o rw,remount /

Now, execute:

chmod 4755 /usr/bin/sudo
chown -R root:root /usr/bin

to fix the permissions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.