Difference between revisions of "cmd/ln"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< cmd
Jump to navigation Jump to search
Line 5: Line 5:
 
  ln -r --symbolic ./{{arg|existing file}} {{arg|name for link}}
 
  ln -r --symbolic ./{{arg|existing file}} {{arg|name for link}}
 
Relative links will still work even if the folder containing both files (the original and the link) is moved or copied.
 
Relative links will still work even if the folder containing both files (the original and the link) is moved or copied.
 +
==Example==
 +
I pretty much always get confused as to which is the link and which is the target, so here's an example. You're inside {{fmt/code|/git/futilities/human/ff}} and you want to create a link called "lib" to the "lib" folder at {{fmt/code|/git/futilities/lib}}:
 +
ln -r --symbolic ../../lib/ ./lib
 +
 +
..or, in other words:
 +
 +
ln -r --symbolic {{arg|actual file}} {{arg|link-to-file}}
 
==Notes==
 
==Notes==
 
* [http://stackoverflow.com/questions/1347105/linux-link-all-files-from-one-to-another-directory LINUX: Link all files from one to another directory]
 
* [http://stackoverflow.com/questions/1347105/linux-link-all-files-from-one-to-another-directory LINUX: Link all files from one to another directory]

Revision as of 20:47, 2 January 2023

ln is the Linux command for creating a link to a file or folder.

To create a relative link:

ln -r --symbolic ./<existing file> <name for link>

Relative links will still work even if the folder containing both files (the original and the link) is moved or copied.

Example

I pretty much always get confused as to which is the link and which is the target, so here's an example. You're inside «/git/futilities/human/ff» and you want to create a link called "lib" to the "lib" folder at «/git/futilities/lib»:

ln -r --symbolic ../../lib/ ./lib

..or, in other words:

ln -r --symbolic <actual file> <link-to-file>

Notes