I'm developing an application that needs to store some data. I'm doubting between storing it in /usr/local/myapp
, or in /var/lib/myapp
.
Which is the most suitable directory for this?
A seemingly better place to store your application state data would be /var , or more specifically, /var/lib . This also comes from the Hierarchy Standard. You could create a /var/lib/myapp , or if you're also using things like lock files or logs, you could leverage /var/lock or /var/log .
Variable data for local programs (i.e., programs that have been installed by the system administrator) that are installed in /usr/local (as opposed to a remotely mounted '/var' partition). Note that even locally installed programs should use the other /var directories if they are appropriate, e.g., /var/lock.
Purpose. /var contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files.
The /etc and /var directories contain system control files. The /etc directory contains customization data that you maintain and the /var directory contains customization data that IBM® maintains.
As /usr
is for constant data and /var
for variable data, use /var
to store these data.
And, concerning /usr/local/
: Make sure that packagers can choose to install your software to /usr/lib/
/ /usr/share
/ /usr/bin
by providing an appropriate variable in your make file.
Software installed manually (i. e. with make install
etc.) should resinde in /usr/local/*
, while software packaged via .rpm / .deb / whatever should avoid /usr/local
and directly be installed under the appropriate folders in /usr
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With