Purchase  Copyright © 2002 Paul Sheer. Click here for copying permissions.  Home 

next up previous contents
Next: 18. UNIX Devices Up: rute Previous: 16. Pre-installed Documentation   Contents

Subsections

17. Overview of the UNIX Directory Layout

Here is an overview of how UNIX directories are structured. This is a simplistic and theoretical overview and not a specification of the LINUX file system. Chapter 35 contains proper details of permitted directories and the kinds of files allowed within them.

17.1 Packages

LINUX systems are divided into hundreds of small packages, each performing some logical group of operations. On LINUX, many small, self-contained packages interoperate to give greater functionality than would large, aggregated pieces of software. There is also no clear distinction between what is part of the operating system and what is an application--every function is just a package.

A software package on a RedHat type system is distributed in a single RedHat Package Manager (RPM) file that has a .rpm extension. On a Debian distribution, the equivalent is a .deb package file, and on the Slackware distribution there are Slackware .tgz files.

Each package will unpack as many files, which are placed all over the system. Packages generally do not create major directories but unpack files into existing, well-known, major directories.

Note that on a newly installed system there are no files anywhere that do not belong to some package.

17.2 UNIX Directory Superstructure

The root directory on a UNIX system typically looks like this:

 
 
 
 
5 
 
 
 
 
10 
 
 
drwxr-xr-x   2 root     root         2048 Aug 25 14:04 bin
drwxr-xr-x   2 root     root         1024 Sep 16 10:36 boot
drwxr-xr-x   7 root     root        35840 Aug 26 17:08 dev
drwxr-xr-x  41 root     root         4096 Sep 24 20:55 etc
drwxr-xr-x  24 root     root         1024 Sep 27 11:01 home
drwxr-xr-x   4 root     root         3072 May 19 10:05 lib
drwxr-xr-x   2 root     root        12288 Dec 15  1998 lost+found
drwxr-xr-x   7 root     root         1024 Jun  7 11:47 mnt
dr-xr-xr-x  80 root     root            0 Sep 16 10:36 proc
drwxr-xr-x   3 root     root         3072 Sep 23 23:41 sbin
drwxrwxrwt   5 root     root         4096 Sep 28 18:12 tmp
drwxr-xr-x  25 root     root         1024 May 29 10:23 usr

The /usr directory typically looks like this:

 
 
 
 
5 
 
 
 
 
10 
 
 
 
 
15 
 
drwxr-xr-x   9 root     root         1024 May 15 11:49 X11R6
drwxr-xr-x   6 root     root        27648 Sep 28 17:18 bin
drwxr-xr-x   2 root     root         1024 May 13 16:46 dict
drwxr-xr-x 261 root     root         7168 Sep 26 10:55 doc
drwxr-xr-x   7 root     root         1024 Sep  3 08:07 etc
drwxr-xr-x   2 root     root         2048 May 15 10:02 games
drwxr-xr-x   4 root     root         1024 Mar 21  1999 i386-redhat-linux
drwxr-xr-x  36 root     root         7168 Sep 12 17:06 include
drwxr-xr-x   2 root     root         9216 Sep  7 09:05 info
drwxr-xr-x  79 root     root        12288 Sep 28 17:17 lib
drwxr-xr-x   3 root     root         1024 May 13 16:21 libexec
drwxr-xr-x  15 root     root         1024 May 13 16:35 man
drwxr-xr-x   2 root     root         4096 May 15 10:02 sbin
drwxr-xr-x  39 root     root         1024 Sep 12 17:07 share
drwxr-xr-x   3 root     root         1024 Sep  4 14:38 src
drwxr-xr-x   3 root     root         1024 Dec 16  1998 var

The /usr/local directory typically looks like this:

 
 
 
 
5 
 
 
 
 
10 
drwxr-xr-x   3 root     root         4096 Sep 27 13:16 bin
drwxr-xr-x   2 root     root         1024 Feb  6  1996 doc
drwxr-xr-x   4 root     root         1024 Sep  3 08:07 etc
drwxr-xr-x   2 root     root         1024 Feb  6  1996 games
drwxr-xr-x   5 root     root         1024 Aug 21 19:36 include
drwxr-xr-x   2 root     root         1024 Sep  7 09:08 info
drwxr-xr-x   9 root     root         2048 Aug 21 19:44 lib
drwxr-xr-x  12 root     root         1024 Aug  2  1998 man
drwxr-xr-x   2 root     root         1024 Feb  6  1996 sbin
drwxr-xr-x  15 root     root         1024 Sep  7 09:08 share

and the /usr/X11R6 directory also looks similar. What is apparent here is that all these directories contain a similar set of subdirectories. This set of subdirectories is called a directory superstructure or superstructure. [To my knowledge this is a new term not previously used by UNIX administrators.]

The superstructure always contains a bin and lib subdirectory, but almost all others are optional.

Each package will install under one of these superstructures, meaning that it will unpack many files into various subdirectories of the superstructure. A RedHat package would always install under the /usr or / superstructure, unless it is a graphical X Window System application, which installs under the /usr/X11R6/ superstructure. Some very large applications may install under a /opt/<package-name> superstructure, and homemade packages usually install under the /usr/local/ superstructure ( local means specific to this very machine). The directory superstructure under which a package installs is often called the installation prefix. Packages almost never install files across different superstructures. [Exceptions to this are configuration files which are mostly stored in /etc/.]

Typically, most of the system is under /usr. This directory can be read-only, since packages should never need to write to this directory--any writing is done under /var or /tmp ( /usr/var and /usr/tmp are often just symlinked to /var or /tmp, respectively). The small amount under / that is not part of another superstructure (usually about 40 megabytes) performs essential system administration functions. These are commands needed to bring up or repair the system in the absence of /usr.

The list of superstructure subdirectories and their descriptions is as follows:

bin
Binary executables. Usually all bin directories are in the PATH environment variable so that the shell will search all these directories for binaries.
sbin
Superuser binary executables. These are programs for system administration only. Only the root will have these executables in their PATH.
lib
Libraries. All other data needed by programs goes in here. Most packages have their own subdirectory under lib to store data files into. Dynamically Linked Libraries (DLLs or .so files.) [Executable program code shared by more than one program in the bin directory to save disk space and memory.] are stored directly in lib.
etc
Et cetera. Configuration files.
var
Variable data. Data files that are continually being re-created or updated.
doc
Documentation. This directory is discussed in Chapter 16.
man
Manual pages. This directory is discussed in Chapter 16.
info
Info pages. This directory is discussed in Chapter 16.
share
Shared data. Architecture-independent files. Files that are independent of the hardware platform go here. This allows them to be shared across different machines, even though those machines may have a different kind of processor altogether.
include
C header files. These are for development.
src
C source files. These are sources to the kernel or locally built packages.
tmp
Temporary files. A convenient place for a running program to create a file for temporary use.

17.3 LINUX on a Single 1.44 Megabyte Floppy Disk

You can get LINUX to run on a 1.44 megabyte floppy disk if you trim all unneeded files off an old Slackware distribution with a 2.0.3x kernel. You can compile a small 2.0.3x kernel to about 400 kilobytes (compressed) (see Chapter 42). A file system can be reduced to 2-3 megabytes of absolute essentials and when compressed will fit into 1 megabyte. If the total is under 1.44 megabytes, then you have your LINUX on one floppy. The file list might be as follows (includes all links):

/bin /etc /lib /sbin /var
/bin/sh /etc/default /lib/ld.so /sbin/e2fsck /var/adm
/bin/cat /etc/fstab /lib/libc.so.5 /sbin/fdisk /var/adm/utmp
/bin/chmod /etc/group /lib/ld-linux.so.1 /sbin/fsck /var/adm/cron
/bin/chown /etc/host.conf /lib/libcurses.so.1 /sbin/ifconfig /var/spool
/bin/cp /etc/hosts /lib/libc.so.5.3.12 /sbin/iflink /var/spool/uucp
/bin/pwd /etc/inittab /lib/libtermcap.so.2.0.8 /sbin/ifsetup /var/spool/uucp/SYSLOG
/bin/dd /etc/issue /lib/libtermcap.so.2 /sbin/init /var/spool/uucp/ERRLOG
/bin/df /etc/utmp /lib/libext2fs.so.2.3 /sbin/mke2fs /var/spool/locks
/bin/du /etc/networks /lib/libcom_err.so.2 /sbin/mkfs /var/tmp
/bin/free /etc/passwd /lib/libcom_err.so.2.0 /sbin/mkfs.minix /var/run
/bin/gunzip /etc/profile /lib/libext2fs.so.2 /sbin/mklost+found /var/run/utmp
/bin/gzip /etc/protocols /lib/libm.so.5.0.5 /sbin/mkswap
/bin/hostname /etc/rc.d /lib/libm.so.5 /sbin/mount /home/user
/bin/login /etc/rc.d/rc.0 /lib/cpp /sbin/route
/bin/ls /etc/rc.d/rc.K /sbin/shutdown /mnt
/bin/mkdir /etc/rc.d/rc.M /usr /sbin/swapoff
/bin/mv /etc/rc.d/rc.S /usr/adm /sbin/swapon /proc
/bin/ps /etc/rc.d/rc.inet1 /usr/bin /sbin/telinit
/bin/rm /etc/rc.d/rc.6 /usr/bin/less /sbin/umount /tmp
/bin/stty /etc/rc.d/rc.4 /usr/bin/more /sbin/agetty
/bin/su /etc/rc.d/rc.inet2 /usr/bin/sleep /sbin/update /dev/<various-devices>
/bin/sync /etc/resolv.conf /usr/bin/reset /sbin/reboot
/bin/zcat /etc/services /usr/bin/zless /sbin/netcfg
/bin/dircolors /etc/termcap /usr/bin/file /sbin/killall5
/bin/mount /etc/motd /usr/bin/fdformat /sbin/fsck.minix
/bin/umount /etc/magic /usr/bin/strings /sbin/halt
/bin/bash /etc/DIR_COLORS /usr/bin/zgrep /sbin/badblocks
/bin/domainname /etc/HOSTNAME /usr/bin/nc /sbin/kerneld
/bin/head /etc/mtools /usr/bin/which /sbin/fsck.ext2
/bin/kill /etc/ld.so.cache /usr/bin/grep
/bin/tar /etc/psdevtab /usr/sbin
/bin/cut /etc/mtab /usr/sbin/showmount
/bin/uname /etc/fastboot /usr/sbin/chroot
/bin/ping /usr/spool
/bin/ln /usr/tmp
/bin/ash

Note that the etc directory differs from that of a RedHat distribution. The system startup files /etc/rc.d are greatly simplified under Slackware.

The /lib/modules directory has been stripped for the creation of this floppy. /lib/modules/2.0.36 would contain dynamically loadable kernel drivers (modules). Instead, all needed drivers are compiled into the kernel for simplicity (explained in Chapter 42).

At some point, try creating a single floppy distribution as an exercise. This task should be most instructive to a serious system administrator. At the very least, you should look through all of the commands in the bin directories and the sbin directories above and browse through the man pages of any that are unfamiliar.

The preceding file system comes from the morecram-1.3 package available from http://rute.sourceforge.net/morecram-1.3.tar.gz. It can be downloaded to provide a useful rescue and setup disk. Note that there are many such rescue disks available which are more current than morecram.


next up previous contents
Next: 18. UNIX Devices Up: rute Previous: 16. Pre-installed Documentation   Contents