/var/
and /var/www/
are wrong.
sudo chmod 755 /var/
sudo chmod 755 /var/www/
(sudo required). To fix directories and files inside /var/www/
:
sudo find /var/www/ -type d -exec chmod 755 {} \;
sudo find /var/www/ -type f -exec chmod 644 {} \;
(sudo probably not required but there might be "root" owned files in those directories) Directories need the executable set, so 755, you might want to change it to 750, 775, 770 based on preferences; it lets group and others have more/less permissions). files do not, so 644, you might want to change it to 640, 664, 660 based on preferences; same reason).
That should be it.
In case you also want to reset the user and group setting (not needed if I look at the history):
sudo chown -R www-data:www-data /var/www/
In order to fix this, you can either reinstall sudo
, or download a default /etc/sudoers
and edit it. Both ways require these steps: First, restart your computer. When the Grub screen displays, instead of choosing Ubuntu xxx
, choose Advanced options for Ubuntu xxx
. Under Advanced Options
, choose Recovery mode
. The second step is to mount your partitions rw
. To do this, choose Clean packages
, Ok
, and then when you see the recovery screen again, select Root shell
. Enable the wifi from the root shell. Either reinstall sudo
:
apt-get install --reinstall sudo
or insert this into /etc/sudoers
:
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
# Uncomment to allow members of group sudo to not need a password
%sudo ALL=NOPASSWD: ALL
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL) ALL
# Members of the admin group may gain root privileges
# %admin ALL=(ALL) ALL
(from Sudoers Ubuntu Wiki)
Before restarting, su
back to your normal user, and try sudo apt-get upgrade
or anything with sudo
. If it works, then reboot. Otherwise, comment with the error message.
Best Answer
What I would do :
Maybe it's not sufficient, but without any backup, that's a good start.