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, quitting

What am I doing wrong?

link|improve this question
1  
What you are doing wrong is not reading what your machine "throws back". The problem is described in the very first line. – grawity Oct 26 '11 at 11:20
feedback

2 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"

    enter image description here

  • At the command prompt (which should say root@your-computer:~#, enter:

    chmod 0440 /etc/sudoers
    
  • Then, 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-users

Replace <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-users

And give the right permissions:

sudo chgrp www-users /var/www
sudo chmod –R 775 /var/www
sudo chmod g+s /var/www
link|improve this answer
I tried the first command you said but i got the "operation not permitted" error. If this doesn't work is there any way else i can get my php projects to run under LAMP in ubuntu – Bezaleel Oct 26 '11 at 11:24
@Bezaleel Are you sure you are in recovery mode? (That means, you only boot to a console, and not to any graphical login, etc.) – slhck Oct 26 '11 at 11:33
Yes, i made sure i choose the second option that included (recovery mode), i also had to type my login and password before i could proceed, it was all console, no GUI – Bezaleel Oct 26 '11 at 11:45
@Bezaleel You never have to log in at recovery mode. See my edited post above – you need to get into the root shell prompt. You don't have to enter a password there. – slhck Oct 26 '11 at 11:54
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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