| Purchase | Copyright © 2002 Paul Sheer. Click here for copying permissions. | Home |
|
| |
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.
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.
The root directory on a UNIX system typically looks like this:
5 10 |
drwxr-xr-x 2 root root 2048 Aug 25 14:04 bindrwxr-xr-x 2 root root 1024 Sep 16 10:36 bootdrwxr-xr-x 7 root root 35840 Aug 26 17:08 devdrwxr-xr-x 41 root root 4096 Sep 24 20:55 etcdrwxr-xr-x 24 root root 1024 Sep 27 11:01 homedrwxr-xr-x 4 root root 3072 May 19 10:05 libdrwxr-xr-x 2 root root 12288 Dec 15 1998 lost+founddrwxr-xr-x 7 root root 1024 Jun 7 11:47 mntdr-xr-xr-x 80 root root 0 Sep 16 10:36 procdrwxr-xr-x 3 root root 3072 Sep 23 23:41 sbindrwxrwxrwt 5 root root 4096 Sep 28 18:12 tmpdrwxr-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 X11R6drwxr-xr-x 6 root root 27648 Sep 28 17:18 bindrwxr-xr-x 2 root root 1024 May 13 16:46 dictdrwxr-xr-x 261 root root 7168 Sep 26 10:55 docdrwxr-xr-x 7 root root 1024 Sep 3 08:07 etcdrwxr-xr-x 2 root root 2048 May 15 10:02 gamesdrwxr-xr-x 4 root root 1024 Mar 21 1999 i386-redhat-linuxdrwxr-xr-x 36 root root 7168 Sep 12 17:06 includedrwxr-xr-x 2 root root 9216 Sep 7 09:05 infodrwxr-xr-x 79 root root 12288 Sep 28 17:17 libdrwxr-xr-x 3 root root 1024 May 13 16:21 libexecdrwxr-xr-x 15 root root 1024 May 13 16:35 mandrwxr-xr-x 2 root root 4096 May 15 10:02 sbindrwxr-xr-x 39 root root 1024 Sep 12 17:07 sharedrwxr-xr-x 3 root root 1024 Sep 4 14:38 srcdrwxr-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 bindrwxr-xr-x 2 root root 1024 Feb 6 1996 docdrwxr-xr-x 4 root root 1024 Sep 3 08:07 etcdrwxr-xr-x 2 root root 1024 Feb 6 1996 gamesdrwxr-xr-x 5 root root 1024 Aug 21 19:36 includedrwxr-xr-x 2 root root 1024 Sep 7 09:08 infodrwxr-xr-x 9 root root 2048 Aug 21 19:44 libdrwxr-xr-x 12 root root 1024 Aug 2 1998 mandrwxr-xr-x 2 root root 1024 Feb 6 1996 sbindrwxr-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:
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.