Ubuntu – the default permission of folder /var

permissionsUbuntu

I just installed Ubuntu 12.04 in a pendrive, then installed MySQL and Apache PHP and then I tried to install Moodle (a distance learning platform I use at work).
The installation in Moodle stopped when the program tried to create a folder called moodledata inside the folder /var, and did not have permission to do so.
So I did a chmod 777 to folder /var and removed the blockade, but I fear what I have done is not safe and I want to go back to the previous (initial/default) permission value of /var
I can't find anywhere what value should it be. Can you help me?

Best Answer

The default permission for /var is 755 = rwxr-xr-x: readable and executable (you need both for a directory) by everyone, and only writable by root.

Setting the permission on a file or directory to 777 is never right. In your case, you should

  • either have created the directory as root and then set its ownership to the user running Moodle (is this a web application? Then either www-data if the web application is supposed to write to this directory, or root if not);
  • or have configured the application to use a directory it can write to (e.g. under /var/www for a web application).
Related Question