Tuesday 24 October 2023

E01: The Linux Filesystem

 Definition:

  • The file system is designed to manage non-volatile storage data by organizing it into files and directories, which can be accessed and modified by users and applications. 
  • Linux uses different file systems such as ext4, XFS, Btrfs, JFS, and ZFS to manage and store data on storage devices.
  • Linux file system has a tree like structure so AKA "directory tree"
  • It has a root directory that contains other files and directories

Understanding Pathnames in a Hierarchical File System
  • A pathname is a text string made up of one or more names separated by forward slashes (/), and it plays a crucial role in navigating a hierarchical file system. 
  • Pathnames guide users and applications on how to find and access files and directories within the file system tree. 
  • Here are some examples and key points to understand pathnames better:
    • Basic Structure: Pathnames are composed of one or more directory and file names, separated by forward slashes. For example, "/home" and "/etc/passwd" are pathnames.
    • Root Directory: A pathname starting with a forward slash ("/") indicates an absolute path, meaning it starts from the root directory. For instance, "/etc/passwd" starts from the root directory.
    • Relative Paths: Pathnames without a leading slash are considered relative paths. They are interpreted relative to the current working directory. For example, "usr/wc" might refer to a subdirectory "usr" within the current directory.
    • Whitespace Handling: Spaces in pathnames should be avoided, as they can lead to confusion and errors. In your example, "assignment 02 /check" includes spaces, which is not a recommended practice.
    • File and Directory Access: Pathnames guide users to access both files and directories. For example, "/etc" is a directory, and "/etc/passwd" is a file within that directory.
    • Hierarchical Structure: The structure of pathnames reflects the hierarchical nature of the file system, with directories containing files and subdirectories.
    • Common Pathnames: Common directories like "/home," "/etc," and "/var" have specific system-wide meanings and purposes. For instance, "/home" typically stores user home directories, and "/etc" contains system configuration files.
    • Absolute vs. Relative Paths: Absolute paths always start from the root directory and provide an unambiguous location. Relative paths depend on the current working directory and can vary depending on where they are used.
    • Pathname Errors: Care must be taken when specifying pathnames to avoid typos or incorrect paths, as this can lead to difficulties in locating and accessing files and directories.


Everything is a File in Linux: Seven Types of Files
  • In the Linux operating system, the philosophy is that "everything is a file." This means that almost all entities, including hardware devices and system processes, are treated as files. 
  • Even when new additions are made to the file tree, they are categorized into one of seven fundamental file types. 
  • These seven types of files in Linux:
    • Regular Files: 
      • Regular files are the most common type. They store data in a human-readable or binary format. This includes text files, documents, images, and executables. Regular files are represented by an "inode" in the file system.
    • Directories:
      • Directories are special files that contain lists of other files and directories. They provide the structure for organizing and navigating the file system. Directory entries map names to inodes.
    • Character Device Files:
      • Character device files represent devices that are read or written character by character, one byte at a time. These files are often associated with input and output devices, such as keyboards and terminals.
    • Block Device Files: 
      • Block device files are used to access block devices like hard drives and SSDs. They allow data to be read and written in blocks or chunks, typically larger than a single character.
    • Local Domain Sockets: 
      • Local domain sockets are a method of inter-process communication (IPC) on the same system. They allow processes to communicate with each other by sending and receiving data through socket files.
    • Named Pipes (FIFO): 
      • Named pipes, also known as FIFOs (First In, First Out), provide a way for processes to communicate through a temporary file. Data written to a named pipe is read in the order it was written, similar to a queue.
    • Link Files: 
      • Link files can be of two types: hard links and symbolic links (symlinks). Hard links point to the same inode as the original file, essentially creating multiple directory entries for the same data. Symbolic links (symlinks) are references to another file or directory by its path. They act as pointers or shortcuts to the target file or directory.


No comments:

Post a Comment

G01:Client Server Architecture

  G01 Client Server Architecture A central server (host computer) serves as both the source of service requests and the destination for ...