Unfortunately I missed and suddenly change permission for whole /var
folder content (chown -R www-data:www-data ../../
, but I was inside /var/www_virthost/mydomain
), what is wrong as I guess 😉
But the problem that I don't remember who was the owner/group for next folders
backups
cache
crash
lib
lob
local
lock -> /run/lock
log
mail
opt
run -> /run
spool
tmp
www
thanks
Best Answer
/var/
is probably the most complicated ownership setup in the entire operating system. It's not all root-owned and doing that is about as harmful as letting your user own it all. Some things won't work if you leave it like that, namely the desktop.If you want to see the array of users and owners you're dealing with, look at the following command on a working system:
On my system, 59 distinct user/owner combinations in
/var/
. This is the point where I expect most people give up and reinstall. Let's be honest, if you haven't gone that far with your computer, there isn't going to be much lost from a nice install-over-the-top. It's almost certainly going to be quicker.If you're still reading, you're completely mad but you're in good company. Let's start by owning everything to
root:root
.And now we have to correct for the things that aren't and can't be root. I have written short command that shows me the files and directories that aren't owned by root:root.
In the output I have trimmed out some things that aren't going to be relevant to a lot of people (nginx, rabbitmq, schroot stuff, lxc, and a lot more). This is all specialist stuff. If you've borked those permissions, ask me for the output and I'll include it. I have also broken down some big directories that are owned by the same user/group all the way through with wildcards.
I'm including this output so you can see how things are supposed to be owned. You can manually
chown
things to approximately the right user/group.oli
is my$USER
.