I'm using Ubuntu 16.04 LTS. In the terminal I was in the htdocs/project folder and I have run this command to change permission of current folder:

asus@asus-X541UJ:~/Bureau/htdocs/project$ sudo chmod -R 777 /

After many of texts were appeared in the terminal , sudo command isn't working anymore.

sudo: /etc/sudoers is world writable
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

marked as duplicate by PerlDuck, Zanna, N0rbert, Fabby, guiverc Sep 13 '18 at 8:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    This is because you did a 777 recursively on the entire disk. You actually changed all the permissions on the entire system (ALL folders, ALL files, ALL programs), and that is going to be a HUGE problem. You've basically torched the permissions on your entire system with that sudo chmod -R 777 / since that changes permissions on every single file on the disk. Hopefully you can back up the information you want to keep and then reinstall, because youo're going to have a hell of a time getting a lot of apps to run (including sudo itself), and SSH keys won't work right either. – Thomas Ward Sep 12 '18 at 15:33
  • 2
    @ThomasWard "Hopefully you can back up the information you want to keep and then reinstall," you mean that I must reinstall ubuntu from the beginning ? – hous Sep 12 '18 at 15:42

You did something really wrong: you gave everyone the power to modify the root directory and all of its subdirectories (there included /etc and /etc/sudoers*).

For this reasons sudo will refuse to run. From the friendly manual:

            To help prevent the editing of unauthorized files, the following restrictions are enforced unless explicitly allowed by the security policy:

             ·  Symbolic links may not be edited (version 1.8.15 and higher).

             ·  Symbolic links along the path to be edited are not followed when the parent directory is writable by the invoking user unless that user is root (version 1.8.16 and higher).

             ·  Files located in a directory that is writable by the invoking user may not be edited unless that user is root (version 1.8.16 and higher).

If you have root's password, please use su - to become root and fix back the permissions.

Otherwise you need to reboot the machine with init=/bin/sh, remount the / file system as rw (read-and-write) and, again, fix all those permissions. That can be tedious and error prone, indeed, but it's still possible.

As root you can start with:

find / -type d -maxdepth 1 -exec chmod -vc go-w {} \; chmod -vc 440 /etc/sudoers

  • 4
    Note that it's not possible to just 'fix the permissions' from this type of recursive 777 - the only way to really 'fix' those permissions is to reinstall the system and then not screw up and run a recursive 777 on the entire system again. This is because MANY things are going to be obscenely broken by this permissions change that happened, not just sudo. – Thomas Ward Sep 12 '18 at 15:37
  • 1
    I have to agree with @ThomasWard It will be quite tedious to go through each and every system files in each folder including files installed by installed applications and first determine what the original permissions were (how does one do that?) and then change them back to the original state. – user68186 Sep 12 '18 at 15:40
  • 1
    Not going to have this argument here. TL;DR, "tedious" without you explaining exactly what permissions go where and how OP is supposed to actually reset the permissions means that you don't give them the means to do it, and such recommendations in your answer are basically "Yeah you can restore it" but not giving them the means to do so. And judging that the user ran the command they did, they don't really know what permissions to reset. Therefore, the point I was trying to make still stands. (If you wish to continue this argument you can try to in chat, no guarantee I'll reply though) – Thomas Ward Sep 12 '18 at 15:45
  • 1
    To find the permissions of all the files that is screwed up. First build an identical system similar to the one screwed up. Then compare permission of each file from the new system with the screwed up system. Change as needed when you find a discrepancy. Sure, not impossible, but you need a second computer and endless time. – user68186 Sep 12 '18 at 15:45
  • 1
    @user68186 Permissions could be saved and restored using getfacl -R and setfacl --restore but that's still no guarantee and you would need a 2nd system with the exact same set of files. Unlikely. I'd also suggest to backup personal data and then reinstall. – PerlDuck Sep 12 '18 at 16:19

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