Skip to content

Linux ln Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

Linux ln Guide

Complete beginner-friendly guide to ln on Linux, covering Arch Linux, CachyOS, and other distributions including creating symbolic links, hard links, and link management.


Table of Contents

  1. Understanding ln
  2. Symbolic Links
  3. Hard Links
  4. Link Management
  5. Troubleshooting

Understanding ln

What is ln?

ln (link) creates links to files.

Link types:

  • Symbolic links: Point to file path
  • Hard links: Direct file reference

Uses:

  • Shortcuts: Create file shortcuts
  • Organization: Organize files
  • Multiple access: Access file from multiple locations
  • System management: Manage system links

Symbolic Links

Create Symlink

Basic usage:

# Create symbolic link
ln -s target.txt link.txt

# -s = symbolic

Absolute vs Relative

Path types:

# Absolute path
ln -s /absolute/path/target.txt link.txt

# Relative path
ln -s ../target.txt link.txt

Hard Links

Create Hard Link

Basic usage:

# Create hard link
ln target.txt link.txt

# No -s flag = hard link

Hard Link Properties

Characteristics:

  • Same inode: Shares inode with original
  • No distinction: Original and link are equal
  • File system: Must be on same filesystem
  • Directory: Cannot hard link directories

Link Management

List Links

Find symlinks:

# Find symbolic links
find . -type l

# Or
ls -la | grep "^l"

Remove Links

Delete link:

# Remove link
rm link.txt

# Only removes link, not target

Troubleshooting

Broken Links

Fix broken symlinks:

# Find broken links
find . -type l ! -exec test -e {} \; -print

# Remove broken links
find . -type l ! -exec test -e {} \; -delete

Summary

This guide covered ln usage, symbolic/hard links, and link management for Arch Linux, CachyOS, and other distributions.


Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally