For an application I created, I am trying to find the best folder locations. I installed the application, as suggested by documentation, in /usr/share/company_name/product_name, save a config.ini file in a hidden folder in users home directory, and user created documents in users home directory.

The application requires other resources:

A resources database (with content that can be modified through code, though it is recommended the user has no outside access)

The resource database must be common and accessible to ALL users, so it cannot be in the users home directory. It cannot be in a hidden directory since the program can use a browser window to locate it and change its location.

I would have liked to place it in a "well-known" folder like /var or /opt - but I get errors when trying to open it through code, with a command like

FILE *resource = fopen(path, "r+");

What is a good location for a resource, preinstalled, non-read-only, accessible to all users and modifiable through code, not hidden (should be able to browse to it) ?

Update: I was able to place my resources in /srv/MyCompany/MyProduct thanks to the link provided in the answer below.

I hope it is a good location ?

  • Are you saying the user application can move shared files around, but only inside the shared application direcctories, and the users home? Oct 3, 2014 at 15:04
  • The user can modify the shared file through the program (which would update database based on items found on the system). The user can also browse for a database elsewhere - but he should be able to find the default one again
    – Thalia
    Oct 3, 2014 at 15:13
  • Reading the link you posted, I saw /srv as a possibility - the only non-read-only non-user-owned location, I am about to test it - will it be reasonable ?
    – Thalia
    Oct 3, 2014 at 15:14
  • Do all users need write access to shared files or just read access? In case of write access, do you need to guard the files against user modifications from outside of the application? Oct 3, 2014 at 15:50
  • all users need write access. I am not particularly worried about users accessing it outside the application... except for removing it...
    – Thalia
    Oct 3, 2014 at 15:56

1 Answer 1


The handling of configuration files is described in the XDG Base Directory Specification.

It defines a set of related path environment variables like XDG_CONFIG_HOME and XDG_CONFIG_DIRS, which define, for example, where the .config directory is by default, and how to handle it in various other controlled ways .

Very common is obviously the form ~/.config/product_name, and when it's about only one product of the company, ~/.config/company_name would not really be different.
But assuming there are multiple products - I think that the structure
~/.config/company_name/product1, ~/.config/company_name/product2...
makes much sense;

I do not know whether it's described in these or related standards. But it can be that the XDG standard would see that as a normal product directory, only that it sees the whole set of software of the company as one product for that purpose.

The general standard use of the fielsystem hierarchy is described in the Linux Filesystem Hierarchy.

As a place for the application itself, take a look at the /opt directory; You would install the application in either /opt/company_name/product1 etc or /opt/product1 etc, both is correct according to the standard.

You found out yourself that the /srv directory could be a good option.
I agree it is the right solution - so I describe here to have it in an answer:

The directory /srv is similar to /opt - the standard does not say much about the subdirectory structure, you can use the same separation as above.
While /opt is explicitly intended for readonly application code, like executables, static data files and documentation, /srv does not restrict much about the variability of the data; It even allows mixing files with different access permissions and variability.
For example, it would be acceptable to deploy files there that can be changed in place by users of the system.

From Linux Filesystem Hierarchy: 1.19:

  This main purpose of specifying this is so that users may find
  the location of the data files for particular service, and so that
  services which require a single tree for readonly data, writable data
  and scripts (such as cgi scripts) can be reasonably placed. Data that
  is only of interest to a specific user should go in that users'
  home directory.

  The methodology used to name subdirectories of /srv is unspecified as there
  is currently no consensus on how this should be done.

To manage the access permissions to the data that needs to be writable to all users of the software, you should use permissions assigned to a group, that contains all the users.
That is true even when "all users of that computer" would be in this group - there are many system users that should not be able to write the data; An attacker may get access to one of the system user accounts.

  • thank you - will i not have problems with write permissions in /opt ?
    – Thalia
    Oct 2, 2014 at 14:39
  • That depends on your definition of 'problem' ;) /opt is owned by root, and installing software is normally done with root permissions. The alternative is to install software for one user only, under his home directory. But that is not a general practice, it's more a workaround. You can not require a customer to install software in a user directory. (Or in 500, for 500 users, for that matter) Oct 2, 2014 at 14:55
  • I'm not sure what you are trying to do in terms of permissions, it would help it you clearly write it down as a separate question. Oct 2, 2014 at 14:56
  • Sorry I edited the question - since finding a place for the resource WAS my question. Both /var and /opt make my resource read-only so I cannot use them. Also I cannot have it hidden, the program must open a "File Open" window to browse to it, and having it in ~ can't be good because the program is installed for all users not a single one.
    – Thalia
    Oct 3, 2014 at 14:42
  • Placed my resource in /srv, thank you for the information.
    – Thalia
    Oct 3, 2014 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.