0
0
Linux CLIscripting~5 mins

ln (hard and symbolic links) in Linux CLI - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a hard link in Linux?
A hard link is a directory entry that associates a name with a file on the same filesystem. It points directly to the file's data (inode), so multiple names can refer to the same content.
Click to reveal answer
beginner
What is a symbolic (soft) link in Linux?
A symbolic link is a special file that points to another file or directory by name. It acts like a shortcut and can cross filesystem boundaries.
Click to reveal answer
beginner
Command to create a hard link named 'linkfile' to 'originalfile'?
Use: ln originalfile linkfile. This creates a hard link named 'linkfile' pointing to the same data as 'originalfile'.
Click to reveal answer
beginner
Command to create a symbolic link named 'symlink' to 'targetfile'?
Use: ln -s targetfile symlink. This creates a symbolic link named 'symlink' pointing to 'targetfile'.
Click to reveal answer
intermediate
Difference between hard and symbolic links?
Hard links point directly to file data and must be on the same filesystem. Symbolic links point to file names and can cross filesystems. Deleting the original file breaks symbolic links but not hard links.
Click to reveal answer
Which command creates a symbolic link?
Aln -s target link
Bln target link
Clink -s target link
Dln -h target link
What happens if you delete the original file of a hard link?
AThe hard link still works and data remains accessible
BThe hard link breaks and data is lost
CThe hard link becomes a symbolic link
DThe system deletes all hard links automatically
Can hard links point to directories?
AOnly symbolic links can point to directories
BNo, usually hard links to directories are not allowed
CYes, always
DOnly if you use the -d option
Which type of link can cross filesystem boundaries?
AHard links
BBoth hard and symbolic links
CSymbolic links
DNeither
What does the command 'ls -l' show for a symbolic link?
ANothing special, same as a regular file
BOnly the link name
CThe size of the target file
DThe link name followed by '->' and the target file name
Explain how hard links and symbolic links differ in Linux.
Think about what each link points to and what happens if the original file is removed.
You got /5 concepts.
    Describe the commands to create hard and symbolic links and when you would use each.
    Recall the syntax and practical use cases for each link type.
    You got /5 concepts.