The Scrap Heap is a wasteland of discarded objects β broken swords, empty potion bottles, shattered mirrors. But hidden among the junk are portal mirrors, and learning ln -s lets you build instant teleportation.
ln -sls -l (look for ->)readlinkls -F, ls -l, and cd| Command | What It Does |
|---|---|
ln -s target link_name |
Create a symbolic link pointing to target |
ls -l |
Long listing β symlinks show link -> target |
ls -F |
Symlinks show with @ marker |
readlink link_name |
Print the target of a symlink |
readlink -f link_name |
Print the fully-resolved absolute path |
realpath path |
Same as readlink -f (more modern) |
| Property | Hard Link | Symbolic Link |
|---|---|---|
| Points to | Inode (data) | Path (name) |
| Works across filesystems | No | Yes |
| Target deleted | Link still works | Broken link (dangling) |
ls -F marker |
none | @ |
ls -F
# broken_sword empty_bottle portal_mirror@ scrap_pile/ crystal_hint
ls -l portal_mirror
# lrwxrwxrwx 1 user group 12 Jan 01 portal_mirror -> /vault/lab
portal_mirror is already a symlink β it points to the vaultβs lab. You can cd portal_mirror and you will land directly in the lab.
cd portal_mirror
pwd
# .../vault/lab β teleported!
cd - # Return to previous directory (the scrap heap)
pwd
# .../scrap
cd - takes you back to wherever you were last. Very useful.
cat crystal_hint
# "Create a shortcut named 'quick_entrance' pointing to ../../ENTRANCE"
ln -s ../../ENTRANCE quick_entrance
ls -l quick_entrance
# lrwxrwxrwx 1 user group 20 Jan 01 quick_entrance -> ../../ENTRANCE
ls -F quick_entrance/
# scroll cellar/ β entrance contents, via symlink
readlink quick_entrance
# ../../ENTRANCE
readlink -f quick_entrance
# /home/user/bashcrawl/ENTRANCE β absolute, resolved path
cat crystal_hint
inventory
# portal crystal β
| Problem | Cause | Fix |
|---|---|---|
| Symlink shows broken (red in terminal) | Target path does not exist | Check relative path with readlink |
ln -s with no arguments |
Wrong order | Syntax: ln -s TARGET LINK_NAME |
cd symlink goes somewhere unexpected |
Relative path off | Use absolute path or readlink -f |
| Cannot delete directory via symlink | Symlink vs directory | rm symlink removes the link; rm -r removes the target |
Danger:
rm -r symlink_to_dirmay behave unexpectedly depending on your shell version. Preferunlink symlink_nameto safely remove only the link.
ls -F @ and a real directoryquick_entrance and successfully cdβd through itreadlink -fContinue your terminal adventure with these resources:
Portals created. The dungeonβs geography bends to your will. ποΈ