Knowledgebase

Understanding Symbolic and Hard Links Print

  • 0

Files in more than one place.

WHAT A SYMBOLIC LINK IS

A file pointing at another path.

WHAT A HARD LINK IS

Another name for the same data on disk.

WHAT THE PRACTICAL DIFFERENCE IS

A symbolic link breaks if the target moves; a hard link does not, because there is no target, only names.

WHAT HARD LINKS CANNOT DO

Span file systems, or point at directories.

HOW TO CREATE A SYMBOLIC LINK

The link command with the symbolic option, target first, then the link name.

WHY THE ORDER CATCHES PEOPLE

Reversing it creates a link in the wrong place, pointing at nothing.

HOW TO SEE WHERE A LINK POINTS

A long listing shows it, or use readlink.

WHERE LINKS ARE USED

Pointing a current directory at a versioned release Sharing configuration between locations Placing large data outside a directory that must stay small

WHAT A BROKEN LINK IS

One whose target no longer exists.

HOW TO FIND THEM

find, with the appropriate test.

WHAT TO BE CAREFUL WITH

Copying links without preserving them, which copies the target instead Deleting a directory through a link Web servers configured to follow links, which can expose files outside the document root

WHY THAT LAST POINT MATTERS ON SHARED HOSTING

It is a route to reading other accounts.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot