E01-The Linux File System

 A Linux file system is like a digital filing cabinet for your computer. It's where all your files, documents, programs, and data are stored. Just as you might organize physical papers in folders and drawers, a Linux file system organizes digital information into directories (like folders) and files. These directories can be nested within each other, creating a structured hierarchy.





Think of it as a way for your computer to keep everything in order, making it easy to find and access your documents and programs. It's the foundation that allows your computer to manage, store, and retrieve all the data and software you use.


What are Pathnames??

A pathname is like a digital address for a file or folder on your computer. It tells your computer where to find that specific item by specifying the directories and subdirectories it's located in, separated by slashes (or backslashes on Windows). It's how you navigate and access your files and folders.

/ is also called the root directory.

There are two types of pathnames:

  • Absolute path and relative path.
Absolute path:
  • it specifies the location from the root directory
  • for example if we are already inside the directory kt which is from /home/kt, even when changing the directory to abc, we still have to give the full path.
  • How do we do that?
  • we have to type in cd /home/kt/abc to change the directory to abc giving the full path.
Relative path:
  • it is related to the current directory.
  • if we are to change our directory to abc, we need not give out all the path.
  • we just have to know the directory we are in and we will know that if we type the command pwd which will show us which directory we are in.
  • lets say it shows /home/kt when we type pwd, now to change the directory to abc we just have to type in the command cd abc and we will be inside the directory abc.
File Types in Linux:
  • In Linux system, everything is a file and if it isn't, it is a processs
  • Most file system implementations defines seven types of files:

Regular or Ordinary Files:
  • They store data of various content types such as text, audio, video, images, scripts, and programs.
  • Regular files can be created with or without an extension.
  • They start with -.
Directories:
  • It is a binary file that tracks and locates other files and directories.
  • You can create directories with the command mkdir directoryName and delete them with rmdir directoryName if they are empty.
  • Linux file systems start with a directory called / or root directory.
  • All other directories have a parent directory except for the root directory.
Character Device Files:

  • Handle data as a stream of characters or bytes.
  • Typically represent devices that work with data in a sequential or serial manner, like keyboards, mice, or serial ports.
  • Data is read or written one character at a time.
  • Character devices are often unbuffered, meaning data is immediately transferred without being stored in a buffer.

Block Device Files:

  •  Handle data in fixed-size blocks or chunks.
  • Typically represent devices that work with data in blocks, like hard drives, solid-state drives, or memory cards.
  • Data is read or written in blocks, making them more suitable for random access and efficient storage.
  • Block devices often use buffers to temporarily store data for more efficient transfer.

Both character and block devices are used to interact with hardware devices, but they handle data differently based on the nature of the device and the specific requirements of the data transfer.

Hard Links:

  • Create an additional reference to an existing inode (data structure representing a file), effectively pointing to the same data on the disk.
  • Changes made to the original file are reflected in all hard links because they share the same data.
  • Hard links can only be created for files, not directories.
  • They have the same inode number as the original file.
  • Provide a more efficient way to have multiple references to the same data without duplicating it on the storage device.

Soft Links (Symbolic Links):

  • Create a separate file that contains a path or reference to the target file or directory.
  • Changes made to the original file or directory do not affect symbolic links.
  • Soft links can reference files or directories.
  • They have a different inode number and are more like shortcuts or aliases.
  • Can point to files or directories on different file systems or even non-existent locations, making them more versatile.

Hard and soft links are used to reference files, but they do so in different ways and have distinct characteristics that suit different purposes.

Socket files:

  • Used for local communication between processes on the same machine.
  • Enable bidirectional data exchange between processes.
  • Represented as special files in the file system.
  • Come in two types: stream (connection-oriented) and datagram (connectionless).
  • Typically located in system-specific directories, like `/tmp`.
  • Efficient for inter-process communication with low overhead.
  • Utilized in various applications for process interaction.
Named pipes, also known as FIFOs:

  • Are special files used for communication between different programs.
  • Allow two programs to send data to each other.
  • Can be used by unrelated programs.
  • Provide a way for programs to work together, even if they weren't designed to do so initially.
  • Are created and managed using system commands in Unix-like systems.
  • Are like a virtual pipe that connects programs, allowing them to exchange data.



Comments

Popular posts from this blog

Topic D02 Introduction to Linux

EO2-Linux Network and Process Managment

Topic D01- Container Technology