[NBLUG/talk] Correct use of directories

ME dugan at passwall.com
Sun Jul 6 13:07:00 PDT 2003


Todd Cary said:
> Wanting to get off to a good start with my new Linux system, I would
> like to get some suggestions on the "correct" use of directories.
> Currently, everything is pretty much "standard RH 9".  I am running one
> one HD that is RAID'ed though there are two other RAID'ed drives, but
> these are for backup for my wife's Windows system (using Samba on my
> TCP/IP network that has a NT Primary Domain Controller).
>
> My "www root" is /home/httpd.  I was told that this is the "best" place
> to put the "www root", howevern my old system it is at /var/www/html/.
> Any comments?

Sure. Like Augie said, this mostly a matter of preference. Here is a brief
view of locations and what are stored in those locations and some systems
and justification used by people:

/tmp     - often a separate partition where anyone can use up any and all
space without it impacting their quota on quota based systems. Some
applications will use /tmp to store data, and it is better to have /tmp
filled up than to have "/" filled up.

/home    - often a separate partition where users' files are stored. By
only placing users' files here, it makes it easier to move all of your
users' files from an older system to a new one. Users' custom web pages
located in their own home directories under "public_html" for example.

/var     - often a separate partition where your system may add data
without your direct control. Such examples include "/var/log" where system
logging takes place, "/var/mail" where mail may be delivered from remote
hosts or locally, and there are others. When you have multiple users doing
web developing for a single site, or multiple sites, you can "sort-of"
view ther additions and removal as "content being added and removed
without your direct control." So why use "/var" instead of "/home" ? One
technical reason can be for the use of quotas. You may wan to impose user
based quotas on disk space and/or files on the "/home" directory, but you
may not want to have the web based files for sites count against these
users. Such a system would be more difficult when placing shared web
content under "/home" instead of "/var".
Again, if you are on a single user system, and you have no other users
adding content, or you just want to do it one way over another, then it
does not really matter too much which place you web content is located (so
long as it works. :-)

/boot    - contains information used for booting your system like kernels,
System.map etc. Not a good idea to put anything in here unless you are
building a kernel or know what you are doing.

/bin     - contains binaries (applications) used by users and root. You
should not add or remove things from here. When you add and remove
packages, your OS will add and remove from here for you.

/dev     - contains "device special files" that permit users to talk to
hardware. Access to devices and control can be granted and removed on a
per-device fashion. For example, maybe you only want a few users to be
able to play with sound... you make sure your sound devices are owned by
an "audio" group and then put people into that group who should have
access to it.

/etc     - contains configuration information about your system: how
drives should be mounted, configuration filed for daemons and default
config files used by users, etc.

/lib     - support libraries. You should not need to add anything here
manually. Your packages will put stuff here and take stuff out.

/opt     - another convention for installing extra application trees. this
is sometimes used by Sun in Solaris (and in other OS) to permit "optional"
additions to the OS. This is another way of doing things than the
"/usr/local" method that I use.

/proc    - a "virtual" directory that has special "files" and directories
that are not really on your disk. These virtual files contain information
about applications running on your machine or about the kernel itself.
Though you are safe if you just "look" (with 'ls') at the files, it is not
a good idea to try anything that could alter them unless you know what you
are doing - i.e. you are told to do something with these files by a
reliable source.

/root    - on many systems, where the user "root" stores their home files.
Other *NIX systems unkindly put the user "root" files into "/". Why put
root's files outside of "/home"? If there are problems with a mounted
partition for "/home" having a "/root" that is part of the "/" volume
makes it easier for root to login and fix the problem. Also, this permits
root to unmount "/home" to perform any other maintenance without losing
root's home directory.

/sbin    - contains applications mostly used by the sysadmin. You should
not need to add or remove anything here. Your packages will add and remove
files here for you.

/usr     - contains user "stuff" (libs "/usr/lib", binaries (applications)
for users "/usr/bin" binaries (applications) primarily for the sysadmin
(/usr/sbin), a source for your kernel (if kernel source is installed)
(/usr/src), header files installed by packages and used when building some
things from source (/usr/include) and "/usr/local" to be mentioned below.

/usr/local - often a separate partition (unless the "/opt" method is used,
then "/opt" may be a separate partition). When you want to install your
own applications from source (configure, make and install) you don't want
to have your applications overwrite or be overwritten by any installs of
packages or removals of packages. /usr/local/bin, /usr/local/lib,
/usr/local/sbin, /usr/local/include, /usr/local/etc (etc., etc., etc.) are
all fairly safe from being altered by a vast majority of packages. (If you
download and use packages not made by your distro, then there is no
guarantee they won't try to use /usr/local)

Separation of stuff into different partitions is useful for preventing
your "/" filesystem from filling up. When "/var/log" or "/" gets filled
up, weird, odd, or bad things can happen. Using partitions insulates
volumes from being filled by users, or run-away processes that may
generate or log too much data.

When you are not on a multi-user system, (like maybe a laptop) use of
separate partitions for "everything" is less useful  and can be a problem
for the single user system.

Of course, anyone can choose a completely different system for locations,
but keeping things consistent makes it easier for other admins to take
over for you when you leave a job, or in cases when others want to help
you.

Again, like Augie said, the choice between /home and /var is mostly an
issue of preference, but there are some reasons for using /var instead of
/home (like use of quotas.)

> Interbase installed itself at /opt/interbase/ .  Where is the best place
> to put my actual databases?  I use MySQL and Interbase.  Is there a
> custom?

Well, a database can shrink and expand without your explicit direction, so
I would probably put it in /var/ and some directory under that. If I
planned to add many databases, I would probably do something like this:

# mkdir /var/ibdb
(ibdb, I would have chosen from "i"nter"b"ase "d"ata"b"ase, but any
convention you can remember works.)
and then either create multiple directories for each db under that or have
all my db located in that dir.

> When I download the latest Apache and PHP rpm's, where should I store
> them?  I will use /tmp/ to untar them since those files can be blown
> away once everything is insalled.

If the files are like the php source, you will want to store those in
/usr/local/src (like I was suggesting.) If the file are ".rpm" files, and
they are not on your CDs, then you may want to store them in
/usr/local/rpm or in root's home. (Sometimes you may want to use the rpms
again to reinstall, and it is nice to have them around if you have plenty
of disk space.)

> Sorry for the basic questions, but I do want to be as conventional as
> possible in the hopes that my learning will be a little easier.

Questions are good.

-ME




More information about the talk mailing list