Working with Links in EXT4
Creating Links
To create a hard link:
ln /path/to/target /new/path/to/link_name
To create a soft (symbolic) link:
ln -s /path/to/target /new/path/to/link_name
ln --symbolic /path/to/target /new/path/to/link_name
- By default, each destination (name of new link) should not already exist.
- When creating hard links, each TARGET must exist.
- You can not use hard links with directories
- If you really need to create a hard link to a directory, use
mount
mount -t bind /path/to/directory /new/path/to/directory_name
Finding links
To find soft (symbolic) links
find . -type l
or use -maxdepth 1
to limit the recursive search to only the current directory
find /path/ -maxdepth 1 -type l
To find hard links
find /path/ -links +1 -type f
To find other hardlinks of a file
find /path/ -samefile /path/to/file