I'm new to Ubuntu and just installed LAMP. I'm trying to paste files into the /var/www/ directory so i can test my PHP projects, but I can't.
I have searched on the web and all I read is: "type sudo chmod 077 /var/www/" or something like that, but my machine throws back this:
sudo: /etc/sudoers is mode 0777, should be 0440
sudo: no valid sudoers sources found, quittingWhat am I doing wrong?
12 Answers
Your problem seems to be a bigger one. Try the following:
Restart your computer
Boot into Recovery Mode (select the "Recovery" option from the boot screen. If you're single-booting Ubuntu, you need to hold the Shift key to get to the GRUB menu)
At the prompt you see, select "Drop to root shell prompt"
At the command prompt (which should say
root@your-computer:~#, enter:chmod 0440 /etc/sudoersThen, restart your machine
shutdown -r now
Now, you should be able to use sudo again. It seems you've tried a few wrong commands before.
Note:
Always take care that you know what you're doing when you use sudo.
Another note:
Running sudo chmod 077 /var/www/ is definitely not what you want to do. If you want to set permissions on /var/www, it would be advisable to create a new group of users that have write-access to the directory.
sudo addgroup www-users
sudo adduser <your-username> www-usersReplace <your-username> with your real username. This will add a new group www-users and add yourself to it.
Then, add the webserver user to it:
sudo adduser www-data www-usersAnd give the right permissions:
sudo chgrp www-users /var/www
sudo chmod –R 775 /var/www
sudo chmod g+s /var/www 4 If you have the root password, type in su -c chmod 0440 /etc/sudoers. This should fix your issue.
The issue is most likely caused by the fact that something changed the permission value of your /etc/sudoers file to 0777, which makes it write-able by everyone, which is a major security risk. Therefore sudo denies you access, since anybody could have gained sudo access.
1