Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a link to a directory [closed]

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/.

like image 287
read Read Avatar asked Mar 06 '12 16:03

read Read


People also ask

How do I create a symbolic link to a folder?

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.

Can a soft link link to a 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.

Can symbolic links link directories?

Symbolic links allow you to access specific files or directories from your current location, which is similar to how we use desktop shortcuts.


2 Answers

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:

  1. cd /home/jake/
  2. ln -s /home/jake/doc/test/2000/something xxx
like image 77
theglauber Avatar answered Sep 28 '22 01:09

theglauber


you should use :

ln -s /home/jake/doc/test/2000/something xxx 
like image 44
WiseTechi Avatar answered Sep 28 '22 02:09

WiseTechi