How to Use the ln Command in Linux

Category: Advanced – Command Line • Est. reading time: 1 minute

The ln command creates a link, basically a shortcut, to a file. The most common use is a symbolic link with -s. Order matters: you name the real file first, then the shortcut you want to create.

Create a symbolic link

ln -s /path/to/real/file /path/to/shortcut

Here /path/to/real/file is the existing target, and /path/to/shortcut is the new link being created.

Be warned before overwriting, and confirm each link

The -i option prompts you before replacing an existing destination, and -v prints each link as it is made.

ln -si /path/to/real/file /path/to/shortcut
ln -siv /path/to/real/file /path/to/shortcut

Running your own dedicated or self-managed server? We are glad to help. Reach us at support@allydrez.com or 1-321-209-2004.