| Linux Newbie Guide III - Basics |
|
|
Page: 2/10 [Printable Version]
What are the different directories for?
This is explained very nicely in the Linux System Administrator Guide (SAG),
which should be available on your system. Try:
cd /usr/doc/LDP/sag
lynx sag.html
This will start a text-mode browser "lynx" to view this html book.
You can also use any other browser, e.g. Netscape for Linux or Windows, to
view this book. This book and other LDP books are actually quite easy to read.
Briefly, Linux contains five filesystems. These filesystems can reside on a
single or different physical hard drives and/or hard drive partitions,
depending on the size and need of your system. (A single filesystem can also
be distributed between different physical devices, if needed.)
The root "/" filesystem contains basic operating
system and maintenance tools. The content of this filesystem should be
sufficient to start up the system and perform emergency maintenance and
repairs if they were necessary.
/usr filesystem contains all commands, libraries,
documentation, and other files that do not change during normal operation.
This will also contain major applications that come with your distribution,
for example Netscape.
/var filesystem contains files that change: spool
directories, log files, lock files, temporary files, and formatted manual
pages.
/home filesystem contains user files (users' own
settings, customization files, documents, data, mail, caches, etc). The
contents of this directory should be preserved on an operating system upgrade.
/proc filesystem contains entirely illusionary files. They
don't really exist on the disk and don't take up any space there (although ls
-l will show their size). When viewing them, you really access
information stored in the memory. It is used to access information about the
system.
The parts of the root filesystem are:
/bin--executables (binaries) needed during bootup that might be used
by normal users.
/sbin--executables (system binaries) not intended for use by general
users (users may still use them, but this directory is not on their PATH).
/etc--system-wide configuration files for your operating system.
/root--the home directory of the system administrator (called
super-user or root).
/dev--device files. Devices appear on Linux as files so it is easy to
write to them or read from them.
/mnt--mount points for removable media (floppy, cdrom, zipdrive),
partitions of other operating systems (e.g. MS Windows), network shares, and
anything else that is mounted on the file system temporarily. It normally
contains a separate subdirectory for each mounting share. The contents of
these drives/shares appear in these subdirectories--there are no drive letters
on Linux.
/lib--shared libraries for programs that reside on the root
filesystem and kernel modules.
/boot--files used by the bootstrap loader (LILO or GRUB), the thing
that loads first when the computer is booted and perhaps gives you the option
of which operating system to boot, if you have more than one OS on your
computer). It typically also contains the Linux kernel (compressed, file vmlinuz),
but this can be stored somewhere else, if only LILO is configured to know
where it is.
/opt--optional large applications, for example kde under RedHat 5.2
(under RedHat 6.0, kde is distributed as any other X-windows distribution,
main executables are in the /usr/bin directory).
/tmp--temporary files. This directory may clean up
automatically.
/lost+found--files recovered during the filesystem repair.
The most interesting parts of the /usr filesystem are:
/usr/X11R6--X-windows system (version 11, release 6).
/usr/X11--the same as /usr/X11R6 (it is a symbolic link to /usr/X11R6).
/usr/X11R6/bin --lots of small X-windows apps, and perhaps symbolic
links to the executables of some larger X-windows applications that reside in
their own subdirectories somewhere else).
/usr/doc--Linux documentation (on newer systems, this moved to /usr/share/doc).
/usr/share --Data independent from your computer architecture, e.g.,
dictonary words.
/usr/bin and /usr/sbin--similar to their equivalents on the
root filesystem (/bin and /sbin), but not needed for basic
bootup (e.g. during emergency maintenance). Most commands will reside here.
/usr/local--the applications installed by the local administrator
(perhaps each application in a separate subdirectory). After the
"main" installation, this directory is empty. The contents of this
directory should survive normal re-installation or upgrade of the operating
system.
/usr/local/bin--perhaps smaller "user"-installed
executables, plus symbolic links to the larger executables contained in
separate subdirectories under /usr/local .
It is important to understand that all directories appear in a single
directory tree, even if the directories are contained on different partitions,
physical drives (including floppies, etc), or even if they are distributed
over the network. Therefore, there are no DOS-type "drive letters"
under Linux. What would be a "drive" under DOS or MS Windows,
appears on Linux as a subdirectory in a special "mounting" location.
The directory system is well-established and standard on most Linux
distributions (the small differences are being currently addressed by the
Linux Standard Base). It is also quite similar to that found on many
commercial UNIX systems.
More about the /proc filesystem (only for really
curious).
The /proc "pseudo" file system is a
real-time, memory-resident file system that tracks the state of the
operating system kernel and the processes running on your computer.
The /proc file system is totally virtual, i.e., it is not written
on any particular disk or other persistent media, it exists only in the
computer memory, and it is constantly updated to reflect any changes to your
system. The size of the /proc directory is always zero and the last
modification time is the current date. In some cases, it is possible to
change your system settings by manually changing the contents of files in
the /proc filesystem. Many Linux utilities use the /proc
filesystem as the source of their information, e.g., dmesg, ps,
top.
Contents of the /proc filesystem.
Directories with numerical names like
"1" "170" "4908" are IDs of the processes
running on your computer. Each directory contains several files, e.g.,: cmdline
(contains the entire command line that was used to envoke the process), cwd
(symbolic link to the cwd of the process), environ (the environment
variables defined for this particular process in the form VARIABLE=value), exe
(a symbolic link to the executable file that the current process is linked
to), fd (a list of the file descriptors opened by the
process),maps (a named pipe that can be used to access the process
memory), root (a symbolic link to the directory which is the root
file system for the particular process), stat (info on the status
of the process).
Other files in the /proc filesystem:
/proc/cpuinfo --information about the processor,
such as its type, make, model, and performance.
/proc/devices --list of device drivers configured
into the currently running kernel.
/proc/dma --DMA channels being used at the moment.
/proc/filesystems --filesystem types configured
into the kernel.
/proc/interrupts --interrupts in use, and how many
of each there have been.
/proc/ioports --I/O ports in use at the moment.
For example, I can read the cpu info on my system using
the following command:
cat /proc/cpuinfo
|