ln
Updated: September 28, 2024
Links come in several forms. Target must exist when the link is made.
USE CASES
ln "~/megadot/mac/.zshrc ~ # hard link
ln -sv “~/.dotfiles/runcom/.bash_profile” ~ # soft link (symlink)
-s # create a symbolic link
-v # show files as they are created (verbose)
-f # If the target file already exists, then unlink it so that the link may occur.
-r # relative symbolic link
Hard Link
- direct link to a file
- shares the same inode as original
- remains intact even when original is deleted or moved
- keeps permissions of original and changes on it will affect original
Soft Link
- reference to a file (shortcut)
- separate inode from original
- link breaks if original is deleted or moved
- has its own permissions and does not affect original in amy way
Bind Mount
- mounts filesystem to a different location
- preserves structure, permissions and attributes
- helps to bypass chroot issues