Links: Shortcuts to Files
Ln -s.
Sometimes a folder is buried deep, and you visit it all the time. Typing the long path again and again is annoying. Linux lets you make a shortcut, called a symbolic link.

- A folder buried deep
- Typing the long path again?
- Make a shortcut instead
Making a symbolic link
LN dash S makes a symbolic link. First the real target, then the name of the shortcut. Here, a shortcut called site, pointing at projects slash website. LS dash L shows the link, with an arrow, pointing to where it leads. And the first letter is L, for link.
ln -s projects/website site ls -l site lrwxrwxrwx 1 sam sam 16 Jan 5 09:00 site -> projects/website
Using the link
You can use the link just like the real folder. LS site lists the website files. CD site takes you there. It's just a pointer. The files only exist once, in the real folder.
ls site css index.html cd site ls css index.html
Links that break
If you delete or move the real folder, the link still exists, but it points to nothing. That's called a broken link, and using it gives, no such file or directory. Deleting a link with RM only removes the shortcut, never the real files. Linux itself uses links everywhere, for example, to point slash bin into slash user slash bin.
| key | value |
|---|---|
| Target moved | the link breaks |
| rm link | removes only the shortcut |
| Real files | stay safe |
| Linux uses them | e.g. /bin -> usr/bin |
Summary
LN dash S makes a shortcut to a file or folder. Removing the link never touches the real files. Next, checking how much disk space things use.
Key takeaways- ln -s target name
- ls -l shows the arrow
- rm only removes the link