-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux ln Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to ln on Linux, covering Arch Linux, CachyOS, and other distributions including creating symbolic links, hard links, and link management.
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
Basic usage:
# Create symbolic link
ln -s target.txt link.txt
# -s = symbolicPath types:
# Absolute path
ln -s /absolute/path/target.txt link.txt
# Relative path
ln -s ../target.txt link.txtBasic usage:
# Create hard link
ln target.txt link.txt
# No -s flag = hard linkCharacteristics:
- 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
Find symlinks:
# Find symbolic links
find . -type l
# Or
ls -la | grep "^l"Delete link:
# Remove link
rm link.txt
# Only removes link, not targetFix broken symlinks:
# Find broken links
find . -type l ! -exec test -e {} \; -print
# Remove broken links
find . -type l ! -exec test -e {} \; -deleteThis guide covered ln usage, symbolic/hard links, and link management for Arch Linux, CachyOS, and other distributions.
- ls Guide - List files and links
- readlink Guide - Read link targets
- File Management - Filesystem management
-
ln Documentation:
man ln
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.