Experiment No. - 05 :- Dealing with Files and Indexes in Linux OS

1. Aim of the Experiment

To demonstrate practical skills in Linux file management and index manipulation: creating, copying, moving, and searching files, managing file permissions and timestamps, understanding index nodes (Inodes), and generating hard/soft (symbolic) link pointers.

2. System & Tool Requirements

  • Operating System: Linux Distribution (Ubuntu / Debian / RHEL / Fedora)
  • Terminal: Command Line Interface (CLI)
  • Core Utilities: touch, ls, cp, mv, ln, find, stat

3. Step-by-Step Procedure & Commands

SECTION A: File Creation, Copying & Manipulation

# Create working directory and navigate into it
mkdir -p ~/file_lab && cd ~/file_lab

# Create sample files using touch command
touch sample1.txt sample2.txt

# Write text into file using redirection
echo "ICTSM Linux Indexing Practical" > sample1.txt

# Copy and rename files
cp sample1.txt backup_sample.txt
mv sample2.txt data_record.txt

SECTION B: Inspecting Inodes (Indexes) & System Links

# Check Inode number of created files (-i flag)
ls -li

# Inspect detailed file metadata and index information
stat sample1.txt

# Create a Hard Link (shares identical Inode index)
ln sample1.txt hardlink_sample.txt

# Create a Soft/Symbolic Link (pointer to path)
ln -s sample1.txt softlink_sample.txt

# Verify Inodes and link counts
ls -li

SECTION C: Index Search & File Locating Operations

# Search files by name starting from root directory
find . -name "*.txt"

# Locate files by specific Inode index number
find . -inum 1234567

# Quickly search indexed system database
locate sample1.txt

4. Observation & Practical Log

S.No Task Objective Command Executed Status / Output Observation
1 Create Files touch sample1.txt sample2.txt Empty files initialized
2 Copy & Rename cp sample1.txt backup_sample.txt Duplicate file generated
3 View Inode Index ls -li Unique index numbers displayed
4 Detailed Inode Info stat sample1.txt Access, Modify, Change status shown
5 Create Hard Link ln sample1.txt hardlink_sample.txt Same Inode number assigned
6 Create Soft Link ln -s sample1.txt softlink_sample.txt New Inode pointing to path created
7 Search by Inode find . -inum [Inodenumber] Linked files retrieved by index

5. Viva-Voce / Oral Examination Preparation

Q1. What is an Inode in Linux File System?

Ans: An Inode (Index Node) is a data structure on a Linux file system that stores all metadata about a file (file size, permissions, owner, timestamps, block pointers) except its actual filename and content.

Q2. What is the key difference between a Hard Link and a Soft Link?

Ans: A Hard Link points directly to the underlying Inode index of the original file and shares the same Inode number. A Soft Link (Symbolic Link) creates a new Inode that acts as a shortcut pointing to the file path of the original file.

Q3. What happens to a Hard Link if the original file is deleted?

Ans: The data remains intact and accessible via the Hard Link because the underlying Inode is only removed when all hard links referencing that Inode are deleted (link count reaches 0).

6. Practical Result & Conclusion

Result: All operations related to creating, moving, and managing files and inspecting system index structures (Inodes and links) in Linux were executed successfully. Inode numbers were verified and logged.

Post a Comment

0 Comments