Symbolic links in Linux systems

Symbolic link, also know as a Symlink or soft link. Is a kind of shortcut that point to a specific file or directory.

There are two types of links in Linux/UNIX systems:

How to Use the ln Command

*ln* is a command-line utility for creating links between files. By default, the ln command creates hard links. To create a symbolic link use, the -s (--symbolic) option.

The *ln* command syntax for creating symbolic links is as follows:

ln -s [OPTIONS] FILE LINK

To create a symbolic link to a given file, run:

The symbolic_link parameter is optional. If you do not specify the symbolic link, the ln command will create a new link in your current directory:

To create a symbolic link to a directory is the same as when creating a symbolic link to a file, run:

If you try to create a symbolic link that already exists, the ln command will print an error message.

To overwrite the destination path of the symlink, use the -f (--force) option.

To verify that the symlink was successfully created, use the *ls* command:

The output will look something like this:

To delete/remove symbolic links use either the unlink or rm command. The syntax is simple:

Removing a symbolic link using the rm command:

No matter which command you use, when removing a symbolic link not append the / trailing slash at the end of its name.

If you delete or move the source file to a different location, the symbolic file will be left broken and should be removed.

----------

Home

Linux

Notes

MicroLog

----------

© DarknessCode