How to create symlink in Linux

In this article, we will see how to create symlink in Linux.

Symlink or Symbolic link or Soft Link: are similar to shortcuts, and can point to another file or directory in any file system.

we can create soft(sym) link using command ln with -s option.
If we delete original file, then soft link will become useless.

How to create symlink in Linux

ln -s (path-to-file) (symbolic-link-to-file)

Create symlink in Linux examples:

ln -s r2schools.txt r2file

Where r2schools filename
r2file is the name name of symlink.

To verify, run the command ‘ls -ltrh’ by going to symlink path as shown below.

How to create symlink in Linux

How to remove symlink:

Syntax to remove symlink or symblic link:

unlink symlink_name_with_path

Examples:

unlink r2file

Verify we have successfully removed symlink or not: