6 Overview of GNU/Linux filesystem

Mr. Hardik Joshi

epgp books

 

Introduction

 

Usually, a file is an object that stores data, information, settings or commands in a computer system. A directory is a structure that is used to store collection of files. A filesystem is the methods and data structures that an operating system uses to keep track of files on a disk or partition; that is, the way the files are organized on the disk.

 

In Linux, the files are organized in a tree structure. A directory may contain directories and files. Operations like creation, modification, deletion can be performed on a file. Files can be readable, writable and executable. For instance, if a user types his bio-data in a file, we say that the file is readable. A file can be executable, certain commands and programs are stored as executable files. Certain files in Linux are read-only files, such files are managed by the system and prevents the user from making accidental changes.

 

The partitions in hard disk are viewed different by Windows OS and Linux OS. As shown in figure 1, the windows OS sees partitions as C:, D:, etc. while the Linux OS view them as “/” (root) partition and its sub-directories like “/bin”, “/boot” etc. Within each directory, there can be sub-directories. The directories and sub-directories may contain file(s). A file system is a data structure that stores index of each and every file. As we know, files reside in physical form of data blocks in the hard disk. The filesystem is responsible to map the physical location to its logical location in directory structure. The way Linux and Windows maintain files are entirely different, so they have distinct filesystems.

Figure 1: Partitions of Hard Disk

 

Linux Directory Structure

 

Linux organizes the files in tree structure. As you can see in the figure 2, the “/” directory is at the top level and other directories branch out from the root. Files are within these directories. This gives us a hierarchical structure. The root directory is not the same as the root user.

 

The hierarchical filesystem also contains other elements in the path (known as directory names), which are separated by forward slashes (/), as in /var/log/messages, where the last element is the actual file name (messages).

Linux classifies the files into 3 main categories and accordingly they are placed in different directories. The classification is as follows:

  •  User Files – Files created and being accessed by users of the system
  • System Files – Executable files, binary files, configuration files, etc. that are part of any program
  • Device Files – Files corresponding to devices like sound card, graphics card, NIC, etc.

Figure 3: Linux Directory and Files Organization

 

Some of the important directories and their corresponding files are shown in figure 3. We can observe that “/” is at the top level, its sub-directories are /bin, /etc, /sbin, /usr, /var, etc. Within these directories there exists sub-directories and files.

Figure 4: Listing of Linux files

 

When we issue the “ls –l” command on command prompt, it lists the files and directories as seen in figure 4. Each line is either a file or a directory. If the line starts with ‘d’, it is implied as a directory. Files and directories have attributes like size, creator, owner, date of modification etc. Each file or a directory has a path.

 

There are two ways to identify paths:

 

Absolute pathname: An absolute pathname identifies the path of a file or directory. It begins with the root directory and follows the tree, branch by branch, until it reaches the desired directory or file. Absolute paths always start with “ /”.

 

Example: /home/Akash/Document/biodata.pdf

Relative pathname: A relative pathname starts from the current working directory. That is why, relative paths never start with” /”.

Example: ../../home/Akash

 

Mount Point

 

A mount point is a directory in a file system where additional information is logically connected from a storage location outside the operating system’s root drive and partition. Suppose when we insert pen drive or any usb drive to a system, it is said to be mounted. The filesystem of the pendrive attaches itself to the filesystem of the host computer. Similary, different directories can reside on separate partitions of hard disk.

 

The mount command is used to attach a filesystem (which can be local to the computer or on a network) somewhere within the filesystem tree.

For example,

  • The above command will attach the filesystem contained in the disk partition associated with the /dev/sda6 device node, into the filesystem tree at the /home mount point.
  • To unmount the partition, the command would be:

 

Directories of Linux

 

The /bin directory contains executable binaries, essential commands used to boot the system or in single-user mode, and essential commands required by all system users.

The /sbin directory contains executable binaries required by super user(administrator) like shutdown, fsck, etc.

The /boot directory contains files related to booting of Linux OS. The Linux kernel (vmlinuxz), boot loader (GRUB)

The /dev directory contains device nodes, a type of pseudo-file used by most hardware and software devices, except for network devices.

The /etc directory contains system configuration files. For example, the file resolv.conf is a DNS resolver which is used to resolve the IP address for a given domain name.

Files like passwd, shadow and group that are used for for managing user accounts are found in the /etc directory.

The /etc is for system-wide configuration files and only the superuser(root) can modify files there.

User-specific configuration files are always found under their home directory that is part of /home.

Let us summarize the key concepts covered in this module

•       Concept of Linux filesystem.

•       Linux filesystem hierarchy.

•       Mounting of files.

  • Organization of files in various directories.
you can view video on Overview of GNU/Linux filesystem

References:

  • Mike McGrath. 2008. Linux in easy steps, In easy steps/Computer Step.
  • Michael. Kofler. 2000. LINUX : installation, configuration, and use, Addison-Wesley.
  • K.L. James. Linux : learning the essentials,
  • Emmett. Dulaney. 2010. Linux all-in-one for dummies, John Wiley & Sons.
  • Nick. Petreley and Jono. Bacon. 2005. Linux desktop hacks, O’Reilly Media, Inc.
  • David. Brickner. 2005. Linux desktop pocket guide, O’Reilly.
  • Desktop Environment – Wikipedia Page, https://en.wikipedia.org/wiki/Desktop_environment