File Manipulation in Unix: Overview of Unix File System

Overview of Unix File System:

In this tutorial, we will dive deep into Unix File System. The file system is central to how Unix organizes information, and all the information that needs to be stored and retrieved uses the file system.

In this tutorial, we cover Unix file structure, types of files, along with different file permissions for files and directories. 

This tutorial is divided into 5 parts.

Unix File Manipulations Tutorials:

Unix Video #6:

File Manipulations

The information is organized in files and directories. A directory is a collection of files and other directories.  Information about these files and directories are stored in a tree of inodes.  The inode contains information about where to access the file, the access permissions for the file, and an inode number.

The inodes are structured as a hierarchical tree with a single root directory (“/”) at the top.

Multiple disk drives and other devices can be ‘mounted’ at a directory along with the tree (E.g. the first disk drive may be mounted to the root directory – “/”). These devices will have their own physical file system for organizing the contained information (E.g. ext4 – the fourth extended filesystem is a filesystem that is used in Linux).

It is also possible to mount virtual filesystems along the tree (E.g. the /proc directory is used to access the information about processes).

In order to enable all types of information to be stored as files, Unix supports a number of file types:

#1) Ordinary Files

These files contain binary or text information and are stored in a directory on a disk drive.

#2) Directory Files

These are used to organize a group of files – the contained files may be of any type.

#3) Special Files

Special files, also known as device files, are used to represent physical devices such as a printer, a disk drive, or a remote terminal.

#4) Named Pipes

Named pipes are used to allow one process to send information to another.  These are temporary files that hold information from one process until it is read by another process.

#5) Symbolic Links

These are the files that reference some other file or directory with an absolute or relative path.

The ‘ls’ command is used to list filenames and other associated data.  With the option ‘ls -il’, this command lists out a long format of file details along with its inode number.

Example:

inode-numflagslinksownergroup sizeaccess-datename
  2drwxr-xr-x24   root root4096Mar 15 06:21.
  2drwxr-xr-x 24   root root4096Mar 15 06:21..
262147     drwxr-xr-x2root root4096Feb 10 18:30bin
393218     drwxr-xr-x3root root4096Mar 15 06:22boot
302031     drwxrwxr-x2root root4096Feb 7 00:24cdrom
2     drwxr-xr-x18root root3940Mar 14 22:17dev
262145     drwxr-xr-x130root root12288Mar 17 06:15etc

Hope you enjoyed the video!!

PREV Tutorial | NEXT Tutorial


Further Reading