Bash - create symbolic link in Linux

6 points
Created by:

In this short article we would like to show how to create symbolic link in Linux using Bash (or any line command).

Quick solution:

ln -s /path/to/file/or/directory link_name

Where -s parameter means symbolic link creation.

Note: /path/to/file/or/directory can be changed to anything (other link, device, etc.).

Practical example

In this section we will show how to create symbolic link to directory.

ln -s /opt/redmine/redmine-4.1.1/public/ redmine


root@debian:/var/www/html# ls -al
total 16
drwxr-xr-x  4 root root 4096 Sep 12 21:30 .
drwxr-xr-x  3 root root 4096 Jun  3 22:13 ..
-rw-r--r--  1 root root    0 Sep  9 23:38 index.html
lrwxrwxrwx  1 root root   34 Sep 12 21:30 redmine -> /opt/redmine/redmine-4.1.1/public/

Conclusion: we can see redmine links to /opt/redmine/redmine-4.1.1/public/ directory.

Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.