Instead of changing the ownership of /var/www directory, I changed the ownership of /var directory recursively (couple of days back). Now owner of every directory in /var is www-data. All my sites are down and showing "Error establishing a database connection."

There are 12 directories in /var folder : backups, cache, lib, local, lock, log, mail, opt, run, spool, tmp, www

Now how I will rectify my mistake? I don't know which directory is owned by which user. Do I have to find about the owner of each folder one by one and change its permission settings or there is some other way to do it ?

(Operating system : Debian 7.8)

  • 5
    Restore from, or consult the backups you ought to have to determine the proper owners. Feb 5, 2015 at 17:42
  • 1
    It is a waste of time doing anything but restoring.
    – Sirch
    Feb 5, 2015 at 18:09

1 Answer 1


Install fresh Debian on separate server. Check owners and set the same on your current server.

  • 1
    This doesn't help with the files installed manually by the user. Feb 5, 2015 at 20:12

You must log in to answer this question.

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