MySQL, fail2ban and many other server applications store their data in /var/lib.
Are they using the correct directory?
If so why is it named lib, which implies libraries?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this community/var/lib
is indeed the correct directory; as described in the filesystem hierarchy standard,
This hierarchy holds state information pertaining to an application or the system. State information is data that programs modify while they run, and that pertains to one specific host. Users must never need to modify files in
/var/lib
to configure a package's operation, and the specific file hierarchy used to store the data must not be exposed to regular users.
The /var/lib
directory was added to FSSTND (the FHS’ ancestor) in version 1.1, which gives a timeline for its discussion (between February and October 1994), but I haven’t been able to find archives of the FSSTND mailing list to check. I suspect the lib
name was used to parallel /usr/lib
, not because the latter stores libraries, but because it stores files which are “not exposed to regular users”: /usr/lib
stores files which are essential to the system’s operation, but aren’t exposed to regular users either. It’s likely that /var/lib
usage pre-dates its integration in FSSTND.
One might expect /srv
to be a better alternative nowadays, but that’s explicitly excluded:
If the directory and file structure of the data is not exposed to consumers, it should go in
/var/lib
.
Yes, they are using the correct directory.
/var
means variable and this directory has always been intended to store data which changes over time.
https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s08.html