How to create a link xxx
to /home/jake/doc/test/2000/something/
?
Assume the xxx
is created under /home/jake
and you're currently in /home/jake
. When you do cd xxx
, you directly go to /home/jake/doc/test/2000/something/
.
Use the -s option to create a soft (symbolic) link. The -f option will force the command to overwrite a file that already exists. Source is the file or directory being linked to. Destination is the location to save the link – if this is left blank, the symlink is stored in the current working directory.
Soft links are similar to shortcuts, and can point to another file or directory in any file system. Hard links are also shortcuts for files and folders, but a hard link cannot be created for a folder or file in a different file system.
Symbolic links allow you to access specific files or directories from your current location, which is similar to how we use desktop shortcuts.
Symbolic or soft link (files or directories, more flexible and self documenting)
# Source Link ln -s /home/jake/doc/test/2000/something /home/jake/xxx
Hard link (files only, less flexible and not self documenting)
# Source Link ln /home/jake/doc/test/2000/something /home/jake/xxx
More information: man ln
/home/jake/xxx
is like a new directory. To avoid "is not a directory: No such file or directory" error, as @trlkly comment, use relative path in the target, that is, using the example:
cd /home/jake/
ln -s /home/jake/doc/test/2000/something xxx
you should use :
ln -s /home/jake/doc/test/2000/something xxx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With