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...
I read The Linux Command Line by William Shotts, and there are some descriptions of Linux files (system directories):
The
/vardirectory 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?
4 Answers
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".
man hier
/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>
Package specific cache data (optional).
/var/catman/cat[1-9] or /var/cache/man/cat[1-9]
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>
Editor backup files and state (optional).
/var/lib/<name>
These directories must be used for all distribution packaging support.
/var/lib/<package>
State data for packages and subsystems (optional).
/var/lib/<pkgtool>
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..<device> where <device> 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).
The definition of various files (including directories) which are expected to be available is given by the Linux File-system Hierarchy Standard and the Linux Standard Base. The /var hierarchy
contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files.
Interestingly /var/www/ is not defined in such normative specifications.
I'd say that the contents in /var don't change so often. In my experience it's mostly used to store database files, cache files and of course, the /var/www directory. These objects do change but for example, a website doesn't change every second.