next up previous contents
Next: 1.3 Commands Up: 1. Basic Linux Commands Previous: 1.1.0.4 Virtual Consoles   Contents

1.2 File System

On some single-user operating systems, placement of files and directories, is at the whim of the system operator, and the software developer. In Linux and other Unix-like operating systems, the filesystem design has been agreed upon, by consensus, over time. This is important in a system designed to be multi-user. Lack of an agreed-upon standard, for file placement, would make the sharing of resources difficult, if not impossible. So a consensus has built over time, and we see these agreed upon attributes on Linux systems.

Understanding some of the basic file concepts on a Linux system, is one of the keys to understanding how to make the best uses of it. One concept that is fundamental to understanding Linux is that to the system, everything is a file. The tape drive is a file, the keboard, mouse and monitor are files, the serial port is a file.

Files in Linux have three important features or attributes standard in, standard out and error. The concept is deceptively simple and some would even say elegant. By creating simple files that have only a few, predictable actions, and then allowing these files to be strung together, we can create a powerful, yet flexible system. By taking the standard out of one file, and directing it to the standard in of another file, we can build powerful and complex systems to accomplish our task. So the file is the primary building block of the system. All directories branch from the root of the file system represented by the single character ``/''. The standard common subdirectories are as follows.

/bin is the primary binary directory, bin is designated as a directory on the system where binary executable files are. Nearly all the commands shown below are contained in the /bin directory. Also you will find other similar binary directories for a similar purpose, in /usr/bin and /usr/local/bin. Generally, the deeper in the directory tree you go, the more unique the system becomes. Often users will have their own /bin directory, where they keep custom scripts and binaries for their personal use.

/boot is where the kernel, related files and files necessary to boot the system are kept. If you compile a new kernel, you will place the kernel in this directory.

/dev the device directory. This points to one of the features of Linux. To the system, everything is a file. So nearly every hardware device in you system will have a file in this directory associated with it. Some of these include fd0 for the first floppy, hda and sda for the first ide and scsi hard drives.

/etc is where most all system wide configuration files are. Files to configure nameservices, web servers, Login, filesystem, ftp-server, name-server, newserver, filesystem, X, configuration files are all kept in /etc as well as most of the system initialization files. If your looking for a file to configure a service on your system, the first place to look is /etc. There are other etc directories on some systems /usr/etc, /usr/local/etc and /usr/X11R6/lib/X11/etc which are directories for configurations of other parts of the system.

/lib is where shared libraries are. These are the libraries that are shared among applications running under Linux. These libraries are shared among running applications to reduce program overhead, by only loading those functions needed at run time. And by making one copy of the libraries available to multiple running programs, memory is conserved.

/home is where the users home directories are located. For example, the home directory for user joe, would be located in /home/joe. A user can abbreviate the reference to their home directory with the tilde ``''. For example joe could abbreviate a file in his home directory by refering to it by /filename. If joe had created a bin directory in his home directory, he could reach it by the command cd /bin/.

/mnt is by convention and usage the directory where temporary filesystems would be mounted. /opt is a commonly the directory where commercial applications will be installed.

/proc is a virtualized file system. If you were able to look at the filesystem on a Linux system, when it wasn't running, you would find nothing in the directory. The files and directories under /proc are a model of what is going on within the running kernel. Under special circumstances files and instructions can be echoed to the /proc filesystem to make changes to the running kernel.

/root is the home directory of the super-user root. The root user's environment is set up by files in this directory, and files reserved for the use of the super-user are kept in this directory. In most ways this is the same as and other user's home directory.

/sbin is the system binary directory. It contains binaries or programs used to administer the system, for creating filesystems, starting system services and other administrative tasks. Binaries in /sbin are similar across different Linux systems. There is a similar directory

/usr/sbin where binary programs for administering services specific to the installation are. Another directory /usr/local/sbin will contain binaries for custom installed programs, that are not a part of the Linux distribution.

/tmp is a temporary directory. Files that are not essential to the operation of the system, temporary scratch files, and other fast changing files are created in /tmp

/usr is known as the users directory. system wide applications, libraries and documentation that are for the most part installed as part of the distribution, are in this directory and it's subdirectories. This is the users shared resource directory.

/var contains many files that change often. The subdirectories and files may remain somewhat constant, but the contents of those files is dynamic. Cache files, spool files, log files, pid files are all to be found in /var. The print and mail spools are both in subdirectories of /var.


next up previous contents
Next: 1.3 Commands Up: 1. Basic Linux Commands Previous: 1.1.0.4 Virtual Consoles   Contents