Bird
0
0

Given the commands:

medium📝 Command Output Q13 of 15
Linux CLI - File and Directory Operations
Given the commands:
echo "Hello" > file1
ln file1 file2
ln -s file1 file3
rm file1

What will be the output of cat file2 and cat file3?
Afile2: Hello<br>file3: Hello
Bfile2: cat: file2: No such file or directory<br>file3: cat: file3: No such file or directory
Cfile2: cat: file2: No such file or directory<br>file3: Hello
Dfile2: Hello<br>file3: cat: file3: No such file or directory
Step-by-Step Solution
Solution:
  1. Step 1: Understand hard link behavior after deleting original

    Hard link file2 points to the same inode as file1. Removing file1 does not delete the data because file2 still references it. So cat file2 outputs "Hello".
  2. Step 2: Understand symbolic link behavior after deleting original

    Symbolic link file3 points to the name file1. After deleting file1, file3 points to a non-existent file, so cat file3 gives an error.
  3. Final Answer:

    file2: Hello
    file3: cat: file3: No such file or directory
    -> Option D
  4. Quick Check:

    Hard link survives deletion; symbolic link breaks [OK]
Quick Trick: Hard links keep data after original deleted; symbolic links break [OK]
Common Mistakes:
MISTAKES
  • Assuming symbolic link still works after target deletion
  • Thinking hard link deletes data with original
  • Confusing link types' behavior on file removal

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes