0Pricing
Linux Command Line Mastery · Lesson

Creating and Following Symbolic Links

Learn to create, inspect, and manage symbolic and hard links to organize files flexibly without copying data.

Creating and Following Symbolic Links is a free Linux Command Line Mastery lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Linux Command Line Mastery learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What Is a Link

A link is a filesystem entry that points to another file. Links let one file appear in multiple places without duplicating its data, saving space and easing organization.

Linux has two kinds: symbolic links and hard links.

Creating a Symbolic Link

A symbolic link (symlink) is a small file holding a path to its target. Create one with ln -s: the target first, then the link name.

ln -s /var/log/app.log current.log

Inspecting Links

ls -l shows symlinks with an arrow pointing to their target, and the type character l at the start of the permissions.

ls -l current.log
# lrwxrwxrwx 1 user user 16 ... current.log -> /var/log/app.log

Following a Link

Reading or writing through a symlink transparently affects the target. Editing current.log edits /var/log/app.log.

cat current.log   # reads the target file's contents

Hard Links

A hard link is a second name for the exact same data on disk. Both names are equal; deleting one leaves the data until the last link is gone.

ln original.txt backup.txt   # no -s means hard link

Symbolic vs Hard

Key differences:

  • Symlinks can cross filesystems and link directories; hard links cannot.
  • A symlink breaks if its target moves; a hard link keeps the data alive.
  • Symlinks store a path; hard links share an inode.

Broken Links

If a symlink's target is deleted or moved, the link becomes dangling. Accessing it fails. ls often shows broken links in red.

rm /var/log/app.log
cat current.log   # error: No such file or directory

Finding the Target

Use readlink to print where a symlink points, and readlink -f to resolve the full real path through chained links.

readlink current.log
readlink -f current.log

Updating and Removing Links

To repoint a symlink, use ln -sf to force-replace it. To remove a link, rm deletes the link itself, never the target file.

ln -sf /var/log/new.log current.log   # repoint
rm current.log                        # remove the link only

Practical Uses

Symlinks shine for:

  • A stable current path pointing at the latest versioned release.
  • Putting config files in a dotfiles repo, linked into $HOME.
  • Sharing a dataset across projects without copies.

Listing All Links in a Directory

To audit existing links, combine ls with a filter. The find command can list every symlink under a path, helping you spot broken or stray ones.

find . -type l

Quick Check

Test your understanding of links.

Recap

You learned to work with links: create symlinks with ln -s, inspect them with ls -l and readlink, understand hard vs symbolic differences, recognize broken links, repoint with ln -sf, and apply them to releases, dotfiles, and shared data.

Frequently asked questions

Is the “Creating and Following Symbolic Links” lesson free?

Yes — the full text of “Creating and Following Symbolic Links” is free to read here on the web, and the Linux Command Line Mastery course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Linux Command Line Mastery course, upgrade to CoddyKit PRO.

What will I learn in “Creating and Following Symbolic Links”?

Learn to create, inspect, and manage symbolic and hard links to organize files flexibly without copying data. You practise Linux Command Line Mastery with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Linux Command Line Mastery?

No prior experience is required. Linux Command Line Mastery on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Creating and Following Symbolic Links” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Linux Command Line Mastery lesson?

Yes. Every Linux Command Line Mastery lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Viewing File Content: `cat`, `less`, `more`
  2. Searching Files: `find` and `locate`
  3. Permissions and Ownership: `chmod`, `chown`
  4. Creating and Following Symbolic Links
← Back to Linux Command Line Mastery