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
ln -s
ln -s
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 option | Use |
|---|---|
ln -s target linkname | Create a symbolic link |
ln target linkname | Create a hard link |
ls -la | See links (shown with -> arrow) |
readlink -f linkname | Show what a symlink points to |
unlink linkname | Remove 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.
| Distribution | Package manager / base | Equivalent command | Difference 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