Introduction
In this challenge, you will explore the concept of hard links in a Linux file system. You'll create hard links and modify file content, observing how these actions affect file attributes.
Environment
LabEx uses Red Hat Universal Base Image 9 (UBI9) to simulate the exam environment. It may not be identical to the actual RHCSA exam environment, but it provides a good representation of the tasks you'll encounter.
There are two users in the environment:
labex: A standard user with sudo privileges, password:labex.root: The system administrator, password:redhat.
The challenge features real exam questions, along with explanations, requirements, and automated verification scripts to help you confirm task completion. It effectively simulates the knowledge areas covered in the RHCSA exam.
Creating and Manipulating Hard Links
Tasks
- Create an empty file named
hard1 - Create two hard links to
hard1:hard2andhard3 - Add content to
hard2
Requirements
- All files must be created in the
/home/labexdirectory - Create
hard1using thetouchcommand - Create
hard2andhard3using thelncommand - Add the content "Redhat" to
/home/labex/hard2 - Use
ls -lito display file attributes of all three files
Example
After completing the tasks, you should see output similar to this:
$ ls -li /home/labex/hard1 /home/labex/hard2 /home/labex/hard3
1234567 -rw-r--r-- 3 labex labex 7 Aug 28 10:00 /home/labex/hard1
1234567 -rw-r--r-- 3 labex labex 7 Aug 28 10:00 /home/labex/hard2
1234567 -rw-r--r-- 3 labex labex 7 Aug 28 10:00 /home/labex/hard3
The number at the beginning is the inode number, which will be the same for all hard links to the same file. Note that the link count is 3 for all files.
Summary
In this challenge, you explored hard links in a Linux file system. You created multiple hard links to the same file, observed how they share the same inode number, and how modifying one link affects all others. This exercise demonstrated the relationship between inodes, hard links, and file content in a Linux file system. Understanding these concepts is crucial for effective file management and storage in Linux environments, especially when dealing with file systems, backups, and data organization.



