UNIX file system
- All the stored information on a UNIX computer is kept in a filesystem.
- The place in the filesystem tree where you are located is called the current working directory.
- Every item in the UNIX filesystem tree is either a file, or a directory.
- A directory is like a file folder. A directory contained within another is called the child of the other. A directory in the filesystem tree may have many children, but it can only have one parent.
- A file can hold information, but cannot contain other files, or directories. The file is the smallest unit in which information is stored.
- The UNIX file system has several important features.
- Different types of file; to you, the user, it appears as though there is only one type of file in UNIX - the file which is used to hold your information. In fact, the UNIX filesystem contains several types of file.
- Ordinary files; this type of file is used to store your information, such as some text you have written or an image you have drawn. Files which you create belong to you - you are said to "own'' them - and you can set access permissions to control which other users can have access to them. Any file is always contained within a directory.
- Directories; a directory is a file that holds other files and other directories. You can create directories in your home directory to hold files and other sub-directories. Directories which you create belong to you, too.
- Special files; this type of file is used to represent a real physical device such as a printer, tape drive or terminal. It may seem unusual to think of a physical device as a file, but it allows you to send the output of a command to a device in the same way that you send it to a file. For example:
$cat scream.au /dev/audio
This sends the contents of the sound file scream.au to the file /dev/audio which represents the audio device attached to the system.
- Pipes; UNIX allows you to link two or more commands together using a pipe. The pipe acts as a temporary file which only exists to hold data from one command until it is read by another. The pipe takes the standard output from one command and uses it as the standard input to another command.
$ command1 command2 command3
The (vertical bar) character is used to represent the pipeline connecting the commands. With practice you can use pipes to create complex commands by combining several simpler commands together.
- Structure of the file system; the UNIX file system is organized as a hierarchy of directories starting from a single directory called root which is represented by a / (slash). Immediately below the root directory are several system directories that contain information required by the operating system.
The standard system directories are given below. Each one contains specific types of file. The details may vary between different UNIX systems, but these directories should be common to all.
- / ; The root of ALL files and directories
- /bin/ ; Executable system utilities, like ls, cp, rm
- /boot/ ; The kernel program
- /dev/ ; Where special device files are kept
- /etc/ ; System configuration files and databases
- /home/ ; Where the personal files and directories of all users are kept
- /lib/ ; Operating system and programming libraries
- /lost+found/ ; Where the file system checker puts detached files
- /usr/bin/ ; Additional user commands
- /root/ ; The home directory of super user. The contents of this directory is usually hidden for other users available on the system.
- /tmp/ ; System scratch files (all users can write here)
- /usr/include/ ; Standard system header files
- /usr/lib/ ; More programming and system call libraries
- /usr/local/ ; Typically a place where local utilities go
- /usr/man ; The manual pages are kept here
- Home directory; any UNIX system can have many users on it at any one time. As a user you are given a home directory in which you are placed whenever you log on to the system. User's home directories are usually grouped together under a system directory such as /home. A large UNIX system may have several hundred users, with their home directories grouped in subdirectories according to some schema such as their organizational department.
- Pathnames; every file and directory in the file system can be identified by a complete list of the names of the directories that are on the route from the root directory to that file or directory. Each directory name on the route is separated by a / (forward slash). For example: /usr/bin/gcc.
This gives the full pathname starting at the root directory and going down through the directories usr and bin to the file gcc - the GNU c compiler.
Cem Ozdogan
2011-02-14