Introduction to Working with Special File Types in Unix Operating System
In this module, we will discuss:
How UNIX treats regular files and directories differently than other operating systems
The special properties of device files
How to use symbolic links to simplify software maintenance
In addition, we will look at some useful tricks for working with files, including:
Using the options available with the ls command
Using the find command, its predicates, and other utilities to create more targeted finds
When using a computer system, users are mostly performing file-related operations: reading, writing, modifying, creating, or executing files.
These operations are interacting with the file system. Therefore, readers need to understand the file system and file concept in UNIX, how they are managed and represented in the operating system, and how they are stored on the disk.
In this module, we will discuss the file system structure, file concept in UNIX, how to manage file and file system, and the file representation and storage.
UNIX File System Structure
The UNIX file system can be characterized with the hierarchical structure consistent treatment of file data, ability to create and delete files, dynamic growth of files, file data protection, and treatment of peripheral devices
(such as terminals and disk) as files. For users, it is easy to understand the UNIX file system from three aspects: how files in the system are organized, how files are stored on the secondary storage, and how files are read,
and written. The UNIX kernel keeps regular files and directories on block devices such as disks.
The system may have several physical disk units. Partitioning a disk into several parts makes it easier for administrators to manage the data stored there.
Otherwise, the kernel deals on a logical level with file systems rather than with disks, treating each one as a logical device identified by a logical device number.
Since the UNIX kernel provides its services transparently and hides the device distinction from users, even though a computer system has several disk
drives that contain user and system files, for a user, it is not necessary to worry about which disk drive contains the file that is needed to access.
Users who are familiar with MS-DOS and Microsoft Windows know that there can be several disks or partitions in thses operating systems, such as C:, D:, E.
In UNIX, however, these disks or partitions hide from its users. All the several disk drives or disk partitions can be mounted on the same file system structure, allowing their access as directories and not as named drives C:, D:, E:.
Files and directories on these disks or partitions can be accessed by specifying their pathnames as if they are part of the file system on one single partition of one single disk.
The benefit of this mechanism is for users not to remember in what drive or partition files (and directories) are.
What is a file system?
A file system is a section of hard disk that has been allocated to contain files. This section of hard disk is accessed by mounting the file system over a directory.
After the file system is mounted, it will look like any other directory to the end user.
Because of structural differences between 1) the file systems and 2) directories, the data within these entities can be managed separately. When the operating system is installed for the first time, it is loaded into a directory structure,
as shown in the following illustration.
Figure 4-1. / (root) File System Tree. This tree chart shows a directory structure with the
file system at the top, branching downward to directories and file systems.
Directories branch to
/bin, /dev, /etc, and /lib.
File systems branch to /usr, /tmp, /var, and /home.
The directories on the right
(/usr, /tmp, /var, and /home)
are all file systems so they have separate sections of the hard disk allocated for their use.
These file systems are mounted automatically when the system is started, so the end user does not see the difference between these file systems and the directories listed on the left (/bin, /dev, /etc, and /lib).