← All commands
Topic hub File Management
Windows Linux File Management File System

Windows mklink equivalent in Linux

Creates symbolic links (shortcuts) or hard links pointing to files or directories.

Windows mklink
Linux equivalents
Debian/Ubuntu same command
ln -s
Fedora same command
ln -s
Arch same command
ln -s

Overview

What this command does

Creates symbolic links (shortcuts) or hard links pointing to files or directories.

Migration tip: A symbolic link (symlink) is like a Windows shortcut. A hard link is a second name for the same file data. Symlinks are far more commonly used and shown with ls -la using an arrow (->).

Practical tasks

Common use cases

Create symbolic and hard links

Creates symbolic links (shortcuts) or hard links pointing to files or directories.

ln -s target linkname

Create a symbolic link

ln target linkname

Create a hard link

ls -la

See links (shown with -> arrow)

Ready to run

Copyable Linux commands

Review paths, device names, package names and permissions before running any command.

ln -s /var/www/html ~/www
ln -s /etc/nginx/nginx.conf ~/nginx.conf
ls -la ~/www

Walkthrough

Examples with explanations

# Windows: mklink link.txt target.txt
ln -s /var/www/html ~/www         # symlink to a directory
ln -s /etc/nginx/nginx.conf ~/nginx.conf  # symlink to a file

# View what it points to:
ls -la ~/www
lrwxrwxrwx ... www -> /var/www/html

Reference

Common options and variations

Command or optionUse
ln -s target linknameCreate a symbolic link
ln target linknameCreate a hard link
ls -laSee links (shown with -> arrow)
readlink -f linknameShow what a symlink points to
unlink linknameRemove a symbolic link

Distro differences

Debian/Ubuntu vs Fedora vs Arch

This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.

DistributionPackage manager / baseEquivalent commandDifference to notice
Debian/Ubuntu same command ln -s Same command on this distribution.
Fedora same command ln -s Same command on this distribution.
Arch same command ln -s Same command on this distribution.

Important

What to watch out for

Use absolute paths when creating symlinks to avoid broken links if the link is moved.

Keep learning

Related File Management commands