0

I recently switched from Windows 8.1 to Ubuntu.

Yesterday, I wanted to install PHP but during tutorial I did this:

sudo chown -R joy /var/www 

but now onward for every command it ask for password

$ sudo apt-get install vlc 
sudo: /var/lib/sudo owned by uid 1000, should be uid 0
[sudo] password for joy: 

I tried to search on google about that & I come to know that I recursively granted ownership of the directory /var/www and all files and subdirectories, to user joy.

Now I want to reset everything back like before I recursively granted ownership.

4
  • /var/lib is not under /var/www; are you sure about the command you used? You probably did sudo chown -R joy /var /www --- notice the space between /var and /www (and the sudo). That could have royally destroyed your system. Nevertheless, the fact that the system is asking your password for installing a package is completely normal.
    – Rmano
    Oct 12, 2014 at 15:00
  • This is very similar to askubuntu.com/questions/43621/…
    – Rmano
    Oct 12, 2014 at 15:14
  • 1
    ...and after that, please read askubuntu.com/questions/20105/… (I know you didn't do that, but it's the next step ;-) ... prevention!)
    – Rmano
    Oct 12, 2014 at 15:20
  • 1
    Here's a list of files/directories in my system's /var, which aren't owned by root:root: paste.ubuntu.com/8546503. You can use those as a reference (bro3886 is my username, so replace that with joy).
    – muru
    Oct 12, 2014 at 15:22

1 Answer 1

-1

Update:

Try this:
sudo chown -h root /var/lib/sudo

This will change the owner of /var/lib/sudo to root

7
  • 2
    Most directory under /var are owned by root, yes, but there are important exceptions. Look at /var/spool/cron for example; cron will have difficult time to work without the access to them. The chown -R command is destructive, and it's impossible to go back short of a restore form backup or reinstall.
    – Rmano
    Oct 12, 2014 at 15:05
  • Not all subdirectories and files in /var are owned by root though, so this is not an absolute fix.
    – douggro
    Oct 12, 2014 at 15:05
  • I Agree. But, that won't harm the @user3146073 as in this case Ubuntu is not installed on a host machine. It's only a single user. And, he won't mind using sudo -i otherwise
    – devGeek
    Oct 12, 2014 at 15:11
  • 1
    Even if it is only a single user system, there are system users like lightdm, cron, etc. which need to have directories owned by them. This suggestion is likely to severely harm this user's system.
    – muru
    Oct 12, 2014 at 15:12
  • 1
    @yes that can solve the specific problem --- better like that. But it's still not a solution (btw, I didn´t downvote).
    – Rmano
    Oct 12, 2014 at 15:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .