# Shortcuts to Files: ln -s

ln -s makes a symbolic link, a short name that points to a file or folder somewhere else, and the link works until the real thing moves or is deleted.

Apprentice · Unix · Linux · Updated November 10, 2026

## After this lesson you can

- Make a symbolic link with ln -s and recognize one in ls -l
- Tell when a symbolic link is broken, and fix or remove it

## Key takeaways

- A symbolic link is a signpost. It holds the address of a file or folder somewhere else, and opening it opens that.
- ln -s takes the real thing first and the new name second, the same order as cp: ln -s documents/2026/summer-trip/tickets tickets.
- In ls -l, a link's line starts with l, and an arrow (->) shows the address it points to.
- When the real file or folder moves or is deleted, the link breaks. Putting the real thing back, or making a new link, fixes it.
- rm and the link's name, with no / at the end, deletes only the link, never the real thing.

Your boarding passes are four folders down, in `documents/2026/summer-trip/tickets`, and you'll want them often this week. Typing that path every time gets old fast. On a Windows desktop you'd make a shortcut, and on a Mac an alias. The terminal has the same idea, and people use it every day at work: a web server's `current` folder that leads to the newest version of a website, or one settings file that several programs share.

These examples use the packing folder from *What's Filling My Disk? du and df*; its setup lines make it in a few seconds. Then go into it with `cd ~/terminal-practice/packing`.

## A signpost to the real thing

A shortcut works like a signpost: it isn't the place, it tells you where the place is. In the terminal it's called a **symbolic link**, or *symlink*. `ln -s` makes one (read it "L N dash S": `ln` for *link*, `-s` for *symbolic*). The real thing comes first and the link's new name second, the same order as `cp`: from, then to.

```bash
ln -s documents/2026/summer-trip/tickets tickets
ls
```

```text
documents  music  packing-list.txt  photos  tickets  videos
```

`ln -s` prints nothing when it works. There's a new name, `tickets`, right in the packing folder.

## Spotting a link: ls -l

```bash
ls -l
```

```text
total 20
drwxr-xr-x 3 sam sam 4096 Nov  9 04:01 documents
drwxr-xr-x 2 sam sam 4096 Nov  9 04:01 music
-rw-r--r-- 1 sam sam   44 Nov  9 04:01 packing-list.txt
drwxr-xr-x 4 sam sam 4096 Nov  9 04:01 photos
lrwxrwxrwx 1 sam sam   34 Nov  9 04:01 tickets -> documents/2026/summer-trip/tickets
drwxr-xr-x 2 sam sam 4096 Nov  9 04:01 videos
```

In *Looking Around: ls*, the first character was `d` for a folder or `-` for a file. A link gets `l`, and the arrow `->` (read "points to") shows the address it holds. Its size, 34, is the length of that address in characters, not the size of the tickets. Many terminals also give links a color of their own.

## Use it like the real thing

Commands go through the link to the real folder, as if you'd typed the long path:

```bash
ls tickets
cat tickets/flight.txt
```

```text
flight.txt  train.txt
Flight to Lisbon, June 12, seat 14C
```

`cd` works too. `pwd` then shows the short way you came, and `pwd -P` (for *physical*) shows where you really are:

```bash
cd tickets
pwd
pwd -P
cd ..
```

```text
/home/sam/terminal-practice/packing/tickets
/home/sam/terminal-practice/packing/documents/2026/summer-trip/tickets
```

## When the real folder moves

A link holds an address, not the folder itself. Rename the trip's folder, the way you might once you know where you're going, and try the link again:

```bash
mv documents/2026/summer-trip documents/2026/lisbon-trip
cat tickets/flight.txt
ls -l tickets
```

```text
cat: tickets/flight.txt: No such file or directory
lrwxrwxrwx 1 sam sam 34 Nov  9 04:01 tickets -> documents/2026/summer-trip/tickets
```

The signpost still points to `documents/2026/summer-trip/tickets`, and nothing is there anymore. This is a **broken link** (some people say *dangling*), and many terminals show one in red. Deleting the real folder breaks a link the same way.

![Two signposts named tickets, before and after. Before: the signpost points along the path documents, 2026, summer-trip to the real tickets folder with flight.txt and train.txt. After summer-trip is renamed lisbon-trip: the same signpost still points to documents/2026/summer-trip/tickets, where there is now nothing, marked as a broken link](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/da38361d5b55443aba4ac941c0b25a14.webp)

There are two fixes: put the real thing back where the link points, or delete the link and make a new one that points to the new place. Move the folder back, and the same link works again:

```bash
mv documents/2026/lisbon-trip documents/2026/summer-trip
cat tickets/flight.txt
```

```text
Flight to Lisbon, June 12, seat 14C
```

The error messages in this lesson come from Ubuntu 26.04. Other systems word them a little differently, but they mean the same thing.

## Removing a link

`rm` and the link's name deletes the signpost and leaves the real folder alone. Type the name with no `/` at the end. With a slash, `rm` looks through the link at the real folder, and refuses:

```bash
rm tickets/
rm tickets
ls
ls documents/2026/summer-trip/tickets
```

```text
rm: cannot remove 'tickets/': Is a directory
documents  music  packing-list.txt  photos  videos
flight.txt  train.txt
```

The link is gone, and the tickets are still there. One more surprise: `ln -s` doesn't replace a link that's already there. When the name already leads into a folder, it quietly makes the new link *inside* that folder instead. So remove the old link first, then make the new one. On a Mac, `ln -s` works the same way.

## Check yourself

2 questions to try on the lesson page.

## So what

A link gives a long path a short name, anywhere you like. Once you know it holds an address and not the thing itself, a broken link is a quick fix instead of a mystery.

## Key terms

- [Symbolic Link](https://www.ask-codey.com/glossary/symbolic-link)
- [ln](https://www.ask-codey.com/glossary/ln)
- [Broken Symbolic Link](https://www.ask-codey.com/glossary/broken-symbolic-link)

## Cheat sheets

- [Shortcuts to Files: ln -s](https://www.ask-codey.com/cheat-sheets/bash-symbolic-links-cheat-sheet)

## Related

- [What's Filling My Disk? du and df](https://www.ask-codey.com/lessons/bash-disk-space)
- [Copy, Move and Rename: cp and mv](https://www.ask-codey.com/lessons/bash-copy-move-rename)
- [Deleting Safely: rm and rmdir](https://www.ask-codey.com/lessons/bash-deleting-safely)

Source: https://www.ask-codey.com/lessons/bash-symbolic-links
