Special File Types   «Prev  Next»
Lesson 1

Working with Special File Types in Unix Operating System

In this module, we will discuss:
  1. How UNIX treats regular files and directories differently than other operating systems
  2. The special properties of device files
  3. How to use symbolic links to simplify software maintenance

In addition, we will look at some useful techniques for working with files, including:
  1. Using the options available with the ls command
  2. 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:
  1. reading,
  2. writing,
  3. modifying,
  4. creating, or
  5. 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.

Question: How does UNIX treat 1) regular files and 2) directories differently than other operating systems?
UNIX treats 1) regular files and 2) directories differently than other operating systems in several ways:
  1. Hierarchical File System: UNIX follows a hierarchical file system structure, with a single root directory (/) from which all other directories and files are organized. This structure is more streamlined and efficient compared to other operating systems, which might have more complex or less organized file systems.
  2. Everything is a File: In UNIX, everything is treated as a file, including directories, regular files, and even hardware devices. This approach simplifies the way the system interacts with different types of resources, as it uses a consistent set of system calls and interfaces for all of them.
  3. File Permissions and Ownership: UNIX uses a robust system of file permissions and ownership that allows administrators to control access to files and directories. This system is more granular than in some other operating systems, providing users with read, write, and execute permissions for the owner, the group, and others.
  4. Use of Symbolic Links: UNIX supports symbolic links, which are pointers to other files or directories. These links can span across different file systems and are resolved at runtime. This feature is not as common in other operating systems, which might use shortcuts or file aliases instead.
  5. Device Files: In UNIX, hardware devices are also represented as files, allowing the system to interact with them using standard file system operations. This approach is more transparent and easier to manage compared to other operating systems, which might require specific APIs or drivers to interact with hardware devices.
  6. Special File Types: In addition to regular files and directories, UNIX supports other file types like pipes, sockets, and device files. These special file types facilitate inter-process communication and system management in a more streamlined and efficient manner compared to other operating systems.
  7. Case Sensitivity: UNIX file systems are case-sensitive, meaning that file names and directory names are treated differently based on their capitalization. This is not the case in all other operating systems, which might be case-insensitive or case-preserving.
  8. File System Layout: UNIX follows the Filesystem Hierarchy Standard (FHS), which provides a standard and organized structure for the file system layout. This standardization makes it easier for users and administrators to navigate and manage the system compared to other operating systems, which might have more flexible or less structured file system layouts.
These differences in file and directory management contribute to the efficiency, flexibility, and robustness of the UNIX operating system compared to other systems.

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.

Unix Operating System

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
/ (root)

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.

Figure 4-1. / (root) File System Tree.
Figure 4-1. / (root) File System Tree.

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).
SEMrush Software1