About

A symbolic link is a file that merely contains a text string which is a path to another file or directory. A symlink file does not depend on the target file and can exist even if the target is moved or deleted. Moving or removing the target does not effect the symbolic link file, it will still have the same path although the path will now be invalid.

The following command is used to create symbolic links from command linke

ln -s source destination

In this command, source is the name(if the file is in current director) or path(relative or absolute) of the file that you want the symlink to point to and destination is the name of the symbolic link.

So for example if your current directory contains a file named test.sh, you can create a symlink to it using command:

ln -s test.sh testlink

A new file named testlink will be created in the current directory and it will link to test.sh
You can also use absolute path to test.sh as source as follows

ln -s /path/to/test.sh testlink

This will also create a symlink to test.sh. The different between the two approaches is that in the first case the symlink will contain a relative path i.e relative to current directory. This means that if you move this symbolic link file to anyother location in the file system, the link will become invalid as the path in the symlink will no longer be valid. But if you move the symbolic link file created using absolute path, the link will still be valid.

history | show excerpt | excerpt history