How To Create a Symbolic Link

By | 2019-10-07

To create a symbolic link on a UNIX or Linux system, use the ln command with the -s option. You may see or hear a symbolic link referred to as a soft link or symlink. All three terms mean the same thing. Here is an example:

$ ln -s file_name link_name
$ ls -l
total 0
-rw-r--r-- 1 tyler tyler 0 Oct  7 17:41 file_name
lrwxrwxrwx 1 tyler tyler 1 Oct  7 17:41 link_name -> file_name

The above command will create a symbolic link named file_name. If you omit the -s, you will create a hard link instead of a symbolic link.

If you wish for ln to display what it is doing, use the -v option.

$ ln -sv a b
'b' -> 'a'
$ ls -l
total 0
-rw-r--r-- 1 tyler tyler 0 Oct  7 17:41 a
lrwxrwxrwx 1 tyler tyler 1 Oct  7 17:41 b -> a

See Also