What goes in /var?
I read The Linux Command Line by William Shotts, and there are some descriptions of Linux files (system directories):
The /var directory contents don’t change. This tree is where data that is likely to change is stored. Various databases, spool files, user mail, etc. are located here.
I am wondering: If the /var directory contents are not supposed to change, why is there a www directory in /var/www after installing apache-php ? The /var/www directory is where we must edit, create or delete files. This is a localhost public directory. Why did he say, that the /var directory contents don’t change?
«don’t change. This tree is where data that is likely to change» — the quote is self-contradictory
Is this really what it says in your book? What I can find on page 23 in «The Linux Command Line» version 17.10 by William Shotts makes more sense: «With the exception of /tmp and /home, the directories we have looked at so far remain relatively static, that is, their contents don’t change. The /var directory tree is where data that is likely to change is stored. Various databases, spool files, user mail, etc. are located here.»
5 Answers 5
That description of /var is self-contradictory. /var contains things that are prone to change, such as websites, temporary files ( /var/tmp ) and databases. The name is an abbreviation of «variable».
@Sandeep I think the accepted answer is chosen by the person who asks the question. This person may not have had enough information before they chose an accepted answer. Generally speaking, answers with more votes will help more people. I suggest reading the comments below each answer, and follow any links provided by the answer’s author before making your decision. In my opinion, for this question, the accepted answer is incorrect.
Change can occur in more than one way. Variable files may change in size (footprint) or possibly quantity. Use /var if you have a set number of files which may be growing (i.e. due to log appending or rotation) over time so as not to run out of disk space.
From man hier , which has a «description of the filesystem hierarchy:»
/var This directory contains files which may change in size, such as spool and log files.
/var/account Process accounting logs (optional).
/var/adm This directory is superseded by /var/log and should be a symbolic link to /var/log .
/var/backups Reserved for historical reasons.
/var/cache Data cached for programs.
/var/cache/fonts Locally-generated fonts (optional).
/var/cache/man Locally-formatted man pages (optional).
/var/cache/www WWW proxy or cache data (optional).
/var/cache/ Package specific cache data (optional).
/var/catman/cat1 or /var/cache/man/cat8 These directories contain preformatted manual pages according to their man page section. (The use of preformatted manual pages is deprecated.)
/var/crash System crash dumps (optional).
/var/cron Reserved for historical reasons.
/var/games Variable game data (optional).
/var/lib Variable state information for programs.
/var/lib/hwclock State directory for hwclock (optional).
/var/lib/misc Miscellaneous state data.
/var/lib/xdm X display manager variable data (optional).
/var/lib/ Editor backup files and state (optional).
/var/lib/ These directories must be used for all distribution packaging support.
/var/lib/ State data for packages and subsystems (optional).
/var/lib/ Packaging support files (optional).
/var/local Variable data for /usr/local.
/var/lock Lock files are placed in this directory. The naming convention for device lock files is LCK.. where is the device’s name in the filesystem. The format used is that of HDU UUCP lock files, that is, lock files contain a PID as a 10-byte ASCII decimal number, followed by a newline character.
/var/log Miscellaneous log files.
/var/opt Variable data for /opt .
/var/mail Users’ mailboxes. Replaces /var/spool/mail .
/var/msgs Reserved for historical reasons.
/var/preserve Reserved for historical reasons.
/var/run Run-time variable files, like files holding process identifiers (PIDs) and logged user information (utmp). Files in this directory are usually cleared when the system boots.
/var/spool Spooled (or queued) files for various programs.
/var/spool Spooled (or queued) files for various programs.
/var/spool/at Spooled jobs for at(1) .
/var/spool/cron Spooled jobs for cron(8) .
/var/spool/lpd Spooled files for printing (optional).
/var/spool/lpd/printer Spools for a specific printer (optional).
/var/spool/mail Replaced by /var/mail.
/var/spool/mqueue Queued outgoing mail (optional).
/var/spool/news Spool directory for news (optional).
/var/spool/rwho Spooled files for rwhod(8) (optional).
/var/spool/smail Spooled files for the smail(1) mail delivery program.
/var/spool/uucp Spooled files for uucp(1) (optional).
/var/tmp Like /tmp, this directory holds temporary files stored for an unspecified duration.
/var/yp Database files for NIS, formerly known as the Sun Yellow Pages (YP).
What would I find in /var/lib/ directory?
Do you think my search is over? Do you think my data is in there too? I realise this is a highly stupid and speculative question. But I’m after a good guess.
It would be a lot less speculative if you told us how postgres ended up on the system. Was it compiled and installed manually? Or with a package manager? What Linux distro is this?
It was installed as part of another piece of software called Lyris Listmanager. I believe this is the flavour Red Hat Linux 7.3 with PostgreSQL 7.3.2
2 Answers 2
/var/lib
Holds dynamic data libraries/files like the rpm/dpkg database and game scores. Furthermore, 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 shouldn’t ever need to modify files in /var/lib to configure a package’s operation. State information is generally used to preserve the condition of an application (or a group of inter-related applications) between invocations and between different instances of the same application. An application (or a group of inter-related applications) use a subdirectory of /var/lib for their data. There is one subdirectory, /var/lib/misc, which is intended for state files that don’t need a subdirectory; the other subdirectories should only be present if the application in question is included in the distribution. /var/lib/’name’ is the location that must be used for all distribution packaging support. Different distributions may use different names, of course.
I would bet your data is in there, but not the executable files.
/var/lib/pgsql is where Postgres stores all its internal data, including the data you put into a database. It’s not, however, in a format that anybody could really see. Unlike MySQL which makes a separate file for each file and index, PostgreSQL stores its data in files with numeric names and in a dense opaque binary format.
You must log in to answer this question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
What is the difference between /lib and /usr/lib and /var/lib?
What is the difference between /lib and /usr/lib and /var/lib ? Some of the files are symbolic links that «duplicate» content of other directories.
2 Answers 2
Someone else can probably explain this with much more detail and historical reference but the short answer:
/lib
is a place for the essential standard libraries. Think of libraries required for your system to run. If something in /bin or /sbin needs a library that library is likely in /lib .
/usr/lib
the /usr directory in general is as it sounds, a user based directory. Here you will find things used by the users on the system. So if you install an application that needs libraries they might go to /usr/lib . If a binary in /usr/bin or /usr/sbin needs a library it will likely be in /usr/lib .
/var/lib
the /var directory is the writable counterpart to the /usr directory which is often required to be read-only. So /var/lib would have a similar purpose as /usr/lib but with the ability to write to them.
Just to improve a bit — it all comes from Filesystem Hierarchy Standard. The definition is a bit old-ish now but still offers interesting insight. pathname.com/fhs/pub/fhs-2.3.html
This answer is at least 15 years late, yeah, «historically» it’s correct but Linux distros haven’t had /bin /sbin and /lib for many years now and all three are linked to the appropriate /usr directories. And /var/lib normally holds transcient data, you may as well delete completely and the system won’t be affected. Lastly it’s probably the 150th time this question has been asked. Dunno why people jump to answer it again and again.
@ArtemS.Tashkinov Sorry, but there’s a whole lot of inaccuracies in your comment. «15 years» is way off, Fedora made the move to /usr in 2012 and it certainly wasn’t the last major distro to do so (if not the first). /var/lib is definitely not for transient data, at least not on most distros. Deleting it is going to have disastrous consequences on a typical system (destroying the yumdb/rpmdb and breaking the package manager with no way to repair it, nuking the default storage location of various SQL databases or VMs with precious data, etc.)
noteworthy: «as it sounds, a user based directory» — usr sounds like «user», but it actually stands for Unix System Resources
@kubi That smells of Folk Etymology or Convenient Backronym to me; it’s not even a good description of its role. Wikipedia cites these notes from Dennis Ritchie describing the origin as «a directory ‘/usr’ which contains all user’s directories, and which is stored on a relatively large, but slow moving head disk».
Files in /lib and /usr/lib are supposed to be mostly read only and identical between systems. (If it was a container image, they could be fully read only and shared between systems; on a stand alone system, they need to be writable to install updates.)
Files in /var are specific to the local system and frequently contain data that is generated by system operation.
Typically distribution versions of templates for config files can be found in /usr/lib and can be used to create localized versions of config files in /etc or possibly /var .
I’m not sure why there would be duplicate files between /lib and /usr/lib , more likely they are symlinks and not duplicates. (There are no such files on my current system, and only one symlink.)
Historically directories like /usr/lib /usr/bin were actually created because /usr was on a separate disk and things were put there because /bin and /lib were on the root disk which was too small to hold everything, and what was left on the root disk were things critical to boot far enough to mount /usr . Of course, this concept is obsolete, and there is a movement to merge them.