Skip to content
Linux Basics: Creating Symbolic Links

Linux Basics: Creating Symbolic Links

October 6, 2026

A symbolic link is a separate filesystem entry that stores a path to another file or directory. It gives you another name for reaching the target without copying its contents.

These examples use GNU tools on Debian and Ubuntu. Run mktemp -d, then use cd to enter the temporary directory it prints.

Create a link

mkdir notes
printf 'Read the documentation\n' > notes/todo.txt
ln -s notes/todo.txt todo-link.txt

With ln -s, the first path is the target and the second is the new link’s name. The -s option requests a symbolic link; leaving it out creates a hard link, which behaves differently.

Choose a new name for the link. You do not need a force option for this example.

Inspect and read it

ls -l todo-link.txt
readlink todo-link.txt
cat todo-link.txt

ls -l shows the link and its target path. readlink prints the path stored in the link. cat follows the link and reads the target’s contents.

Here, notes/todo.txt is a relative target. It is resolved from the directory containing the link, not from whichever directory you happen to be working in. Moving the link alone can therefore break it.

Change the target’s contents

printf 'Review the examples\n' >> notes/todo.txt
cat todo-link.txt
Read the documentation
Review the examples

The link leads to the updated content. It is not an independent backup. If the target is moved or deleted, the link can remain in place while pointing to a path that no longer exists.

Reference

Debian ln manual

Acknowledgements

This post was created with assistance from AI.

Linux Basics — lesson 13 of 25. Series index

Previous: Using Bash Exit Status · Next: Creating and Extracting tar Archives

Last updated on