To create a soft link (also known as a symbolic link) in Linux or Unix, you can use the ln
command with the -s
option.
A soft link is a file that points to another file or directory, allowing multiple names to be associated with the same file or directory. Unlike hard links, soft links can be created across different file systems and can be used to link to directories as well as files.
Here is the basic syntax for creating a soft link using the ln
command:
ln -s target_file link_name
Replace target_file
with the name of the file or directory that you want to create a link to, and link_name
with the desired name for the soft link.
For example, to create a soft link called link1
to the file file1
, you would use the following command:
ln -s file1 link1
To create a soft link to a directory, you can use the same syntax and specify the name of the directory as the target:
ln -s /path/to/directory link1
You can also create multiple soft links to the same file or directory by specifying multiple link names:
ln -s file1 link1 link2 link3
For more information about the ln
command and its options, you can refer to the ln
man page by running man ln
in the terminal.