This is an old revision of the document!
Simlinks
A symlink is a soft or hard link to a directory location to another directory location or file. I am only interested in the soft link. It effectivily allows a directory tree to be made for different non-structured directory locations, even across partitions.
Simple use is: ln -s "path/directory or file" "path/symlink name"
, where option -s
is to create a symlink. See ln –help
or man ln
for more information.
- To remove symlink
rm "path/symlink name"
- To list symlink
ls "path/symlink name"
- To list symlink directory contents
ls "path/symlink name/"
- Use
-f
flag to force - Use
-s
flag for soft link, default is hard link
Comparison Parameters | Hard link | Soft link |
---|---|---|
Inode number* | Files that are hard linked take the same inode number | Files that are soft linked take a different inode number |
Directories | Hard links are not allowed for directories (Only a superuser* can do it) | Soft links can be used for linking directories |
File system | It cannot be used across file systems | It can be used across file systems |
Data | Data present in the original file will still be available in the hard links | Soft links only point to the file name, it does not retain data of the file |
Original file’s deletion | If the original file is removed, the link will still work as it accesses the data the original was having access to. | If the original file is removed, the link will not work as it doesn’t access the original file’s data. |
Speed | Hard links are comparatively faster | Soft links are comparatively slower |
Soft symlink ownership is not particularly important as it has full permissions (777) and file access is determined by real file permissions.
References
- Linux Soft and Hard Link Guide (10 ln Command Examples)