0
0
Linux CLIscripting~20 mins

ln (hard and symbolic links) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Link Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this command sequence?
You create a file and then a hard link to it. What does ls -li show for the inode numbers?
Linux CLI
echo 'hello' > file1
ln file1 file2
ls -li file1 file2
ABoth files have the same inode number.
Bfile1 has an inode number, file2 shows 'No such file or directory'.
CBoth files have inode number 0.
Dfile1 and file2 have different inode numbers.
Attempts:
2 left
💡 Hint
Hard links share the same inode because they point to the same file data.
💻 Command Output
intermediate
2:00remaining
What happens when you delete the original file of a symbolic link?
You create a symbolic link to a file, then delete the original file. What does cat symlink output?
Linux CLI
echo 'data' > original
ln -s original symlink
rm original
cat symlink
Acat: original: No such file or directory
Bdata
CEmpty output
Dcat: symlink: No such file or directory
Attempts:
2 left
💡 Hint
Symbolic links point to a path, not the file content directly.
📝 Syntax
advanced
2:00remaining
Which command correctly creates a symbolic link named link to /usr/bin/python3?
Choose the correct syntax to create a symbolic link named link pointing to /usr/bin/python3.
Aln -s link /usr/bin/python3
Bln link /usr/bin/python3 -s
Cln -s /usr/bin/python3 link
Dln /usr/bin/python3 link -s
Attempts:
2 left
💡 Hint
The syntax is: ln -s target link_name
🚀 Application
advanced
2:00remaining
How to create a hard link to a file on a different filesystem?
You want to create a hard link to a file located on a different mounted filesystem. What will happen if you try?
Linux CLI
ln /mnt/usb/file.txt ./file_link
AThe hard link is created successfully.
BThe command fails with 'Invalid cross-device link' error.
CA symbolic link is created instead automatically.
DThe original file is copied to the new location.
Attempts:
2 left
💡 Hint
Hard links cannot span different filesystems.
🧠 Conceptual
expert
3:00remaining
What is the difference in inode link count after creating a symbolic link vs a hard link?
You have a file with inode link count 1. You create a symbolic link and a hard link to it. What are the inode link counts for the original file after each link creation?
AHard link increases inode link count by 1; symbolic link does not affect inode link count.
BBoth hard and symbolic links increase inode link count by 1.
CSymbolic link increases inode link count by 1; hard link does not affect inode link count.
DNeither hard nor symbolic links affect inode link count.
Attempts:
2 left
💡 Hint
Inode link count counts hard links only.