Sunday, July 27, 2008

Unix File Systems



1) "/bin" - contains essential system commands and programs (in machine-readable format, or "binary" format, which is what "bin" stands for),
such as "ls," "cp" (used to copy files), "mv" (used to move files to a different location), and so on. It also contains "bash," which is most likely the shell you are currently using. The shell is a program that allows you to issue commands to the operating system and view their output. When you are working in a terminal window, you are using the shell.

2) "/boot" - contains files necessary for booting the system. If you're not familiar with this term, it describes the process of starting the system when it is powered on or restarted. During this process, a number of things happen. These might include checking the integrity of your disks, detecting hardware and getting it ready for use by the system, and starting essential programs that help to keep the system running. Also, the kernel (the "guts" of your system) may be stored in "/boot".

3) "/dev" - contains files which represent system devices, such as your hard disks, serial ports, mouse, etc. For example, "/dev/hda" represents the first IDE device on your system, usually your hard drive. If this sounds confusing, don't worry -- understanding what is in this directory is the most important part.

4) "/etc" - contains essential system-wide configuration files. When administering your system, you'll frequently be editing files in this directory. They control many system services and settings. Some examples of files in this directory are "/etc/resolv.conf" (contains your nameserver information) and "/etc/fstab" (a table of devices or directories that hold data and need to be accessed by the system, such as your hard drive or a CD-ROM drive). Program-specific configuration files may be here as well, and are usually identified by the letters "rc" at the end of the filename, for "run commands." An example of this might be "/etc/vimrc" (a system-wide configuration file for the vim text editor).

5) "/home" - contains the home directories for all regular users. A home directory is where a user generally stores personal files. For example, if your username is "tom," then your home directory is "/home/tom." A convenient shortcut for referring to your home directory is "~/" (a tilde, followed by a forward slash). So, for the user "tom," "~/mp3/moby.mp3" actually refers to the file "/home/tom/mp3/moby.mp3".

6) "/lib" - contains system libraries. Libraries are files that contain program code that is common to several applications. For example, a common thing that a program might need to do is write out to a file somewhere on disk. Rather than have to include that code in every program they write, programmers can simply point to a specific library which contains that functionality. Libraries help to keep programs smaller, more efficient, and easier to maintain. Another thing you'll find in this directory, under "/lib/modules/(kernel-version)" are your kernel modules. Modules usually serve as device drivers -- that is, they provide the necessary interface for "talking" to your system hardware, such as a network card or a SCSI CD-ROM drive.

7) "/mnt" - contains "mount points," which are the locations you would use to access files on various different media such as floppies or CD-ROMs. For example, "/mnt/floppy" would be where you would usually access your floppy. All this is defined by the "/etc/fstab" file mentioned above.

8) "/proc" - contains files with system information. For example, "/proc/cpuinfo" has information about your computer's processor, and "/proc/modules" lists which kernel modules are currently loaded in the system.

9) "/root" - contains the "root" user's home directory.

10) "/sbin" - contains commands used by the superuser ("root") for system administration. These include commands such as "shutdown" (used to shutdown or reboot the system) and fsck (a tool for checking and repairing the data on your hard disk, similar to "scandisk" on Windows).

11) "/tmp" - a place to put temporary files. Applications use this directory often, which can be accessed by all users on the system.

12) "/usr" - contains a number of important subdirectories. "/usr/bin" contains the bulk of the programs on your system. "/usr/sbin" contains important commands for system administration that are not already in "/sbin." So, why the difference between "/bin" and "/usr/bin", or "/sbin" and "/usr/sbin"? Well, "/bin" and "/sbin" should contain all the commands necessary for getting the system up and running, without being connected to the network. This allows "/usr" to actually be located on another computer on the network, and remotely accessed. Now, let's take a look at the rest of the "/usr" subdirectories. "/usr/lib" contains more system libraries, (as discussed above). "/usr/include" contains additional common pieces of code, similar to libraries, but used when compiling software. Compiling software is the process of taking "source code" (the human-readable instructions written by programmers using a programming language, such as C), and using a special program called a "compiler" to create a file that can be understood by the computer, called a binary file. "/usr/src" contains source code stored on the system (such as the Linux kernel source, or source code that you may have downloaded so that you can compile a program by hand). Finally, "/usr/local" contains programs and data files that have been added locally to the system, and are intended to be kept separate from the main system directories.

13) "/var" - contains administrative files (such as system logs), and data that changes frequently (such as incoming mail and news).

No comments: