Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Parent-Child Relationship of Files

Lesson 9 of 32 in the free Design of Unix Operating System notes on Siksha Sarovar, written by Rohit Jangra.

Introduction

In UNIX, the file system is organized as an inverted tree structure (also called a hierarchical structure). Every file and directory has a parent, and directories can contain children (files or subdirectories). This parent-child relationship is fundamental to how UNIX organizes and accesses data.

The Root Directory

  • The topmost directory is called the root directory, denoted by /.
  • Every file and directory in the system is a descendant of root.
  • Root is its own parent (i.e., / is the parent of /).

Directory Hierarchy

/                       (Root)
├── bin/                (Essential user binaries)
├── etc/                (Configuration files)
├── home/               (User home directories)
│   ├── user1/          (Home of user1)
│   │   ├── file1.txt
│   │   └── docs/
│   │       └── report.pdf
│   └── user2/          (Home of user2)
├── tmp/                (Temporary files)
├── usr/                (User programs)
│   ├── bin/
│   ├── lib/
│   └── local/
├── var/                (Variable data - logs, mail)
└── dev/                (Device files)

Key Concepts

1. Parent Directory:

  • Every directory (except root) has a parent directory.
  • Referred to as .. (dot-dot).
  • Example: The parent of /home/user1/docs is /home/user1.

2. Current Directory:

  • The directory you are currently working in.
  • Referred to as . (single dot).

3. Absolute Path:

  • Full path from the root directory.
  • Example: /home/user1/docs/report.pdf
  • Always starts with /.

4. Relative Path:

  • Path relative to the current working directory.
  • Example: If you are in /home/user1, then docs/report.pdf is a relative path.
  • Uses .. to go up: ../../etc/passwd

Relationship Between Files and Directories

  • A directory is a special file that contains a list of (filename, inode number) pairs.
  • When you create a file inside a directory, a new entry is added to the parent directory mapping the filename to the file's inode.
  • Multiple filenames can point to the same inode — this is called a hard link.
  • Deleting a file removes the directory entry, not the inode itself (the inode is freed only when its link count reaches 0).

Important Standard Directories

DirectoryPurpose
/Root directory (topmost)
/binEssential command binaries (ls, cp, mv)
/sbinSystem binaries (for admin use)
/etcSystem configuration files
/homeUser home directories
/tmpTemporary files (cleared on reboot)
/usrUser programs and libraries
/varVariable data (logs, mail spools)
/devDevice files
/procVirtual filesystem for process info
/bootBoot loader files and kernel
/libShared libraries
/mntMount point for temporary mounts

Summary

  • UNIX uses an inverted tree structure with / (root) at the top.
  • Each directory entry maps a filename to an inode number.
  • Absolute paths start from root; relative paths start from the current directory.
  • The .. entry refers to the parent directory, and . refers to the current directory.