Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
home_server:home_server_setup:other_services:symlinks [2019-12-08 Sun wk49 16:43] baumkphome_server:home_server_setup:other_services:symlinks [2024-12-01 Sun wk48 16:53] (current) – [Link Tools] baumkp
Line 1: Line 1:
-{{tag>simlinks linux setup command}}+{{tag>simlinks ln linux setup command}}
 =====Simlinks===== =====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.+A symlink is a soft or hard link to a directory location to another directory location or file.  It effectively allows a directory tree (soft link only) to be made for different non-structured directory locations, even across partitions.  It allows configuration file control by having current configuration file pointing to different version or use type configuration files, depending on use case.
  
-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. Another good reference is The Geek Stuff The Ultimate [[http://www.thegeekstuff.com/2010/10/linux-ln-command-examples/|Linux Soft and Hard Link Guide]] (10 Ln Command Examples+Simple use is:  
-  *To remove symlink ''rm "path/symlink name"'' +  *''%%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 list symlink ''ls "path/symlink name"'' +  *''%%ln "path/file" "path/symlink name"%%'', which creates a hard link to a file. (Where: hard links to directories are not allowed and hard links to files must be on same devices) 
-  *To list symlink directory contents ''ls "path/symlink name/"''+Where: 
 +  *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 ''-i'' flag for interactive, it will ask to overwrite where existing link or file exists 
 +  *Use ''-s'' flag for soft link, default is hard link
  
-Symlink ownership is not particularly important as it has full permissions (777) and file access is determined by real file permissions.+|<65em>
 +^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* |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 | 
 +Notes: 
 +    *Inode number – Index node number is a unique number assigned to all files in a Linux/Unix system. 
 +    *Hard links on directories can cause fundamental problems.  Original Unix command had flags to allow (''-d'' and ''-F''), however most modern operating systems do not allow hard links on directories. See [[https://askubuntu.com/questions/210741/why-are-hard-links-not-allowed-for-directories|Why are hard links not allowed for directories?]]. <fc #ff0000>Hard links to directories should not be used even if possible.</fc> 
 + 
 +Soft symlink ownership is not particularly important as it has full permissions (777) and file access is determined by real file permissions
 + 
 +In general soft links are more flexible, however hard links on files do have specific use cases.  Some examples include: 
 +  *Incremental back-ups, use of hard links saves duplicating file data 
 +  *Virtual File systems where source soft link directions do not resolve.  E.g. Docker configuration files.
  
 ---- ----
-===Home Server Index=== +====Link Tools==== 
-++++Home Server Index|<pagelist&header> +  *Use the ''stat'' command on a file/directory/symlink/device/pipe to get the statistics of the file.  Remember in link all these are stored as files. 
-*[[home_server:home_server_setup:summary]] +  *''find dir  -xdev \! -type d -links +1  -printf '%20D %20i %p\n' | sort -n | uniq -w 42 --all-repeated=separate''  will find and list files that have common inode numbers in the nominated ''dir''
-*[[home_server:home_server_setup:home_it_setup]] +
-*[[home_server:home_server_setup:Network_setup]] +
-*[[home_server:home_server_setup:kvm]] +
-*[[home_server:home_server_setup:vnc_setup]] +
-*[[home_server:home_server_setup:disk_check]] +
-*[[home_server:home_server_setup:other_services]] +
-</pagelist>+++++
  
-===Home Server Other Index=== +---- 
-++++Home Server Other Index|<pagelist&header> + 
-*[[home_server:home_server_setup:other_services:index]] +====References==== 
-*[[home_server:home_server_setup:other_services:timedate]] +  *[[http://www.thegeekstuff.com/2010/10/linux-ln-command-examples/|Linux Soft and Hard Link Guide]] (10 ln Command Examples from The geek stuff) 
-*[[home_server:home_server_setup:other_services:aptcache]] +  *[[https://www.geeksforgeeks.org/difference-between-hard-link-and-soft-link/|Difference between Hard Link and Soft Link]] (Geeks for Geeks) 
-*[[home_server:home_server_setup:other_services:swap]] +  *Linux Handbook [[https://linuxhandbook.com/ln-command/|ln Command Examples]] 
-*[[home_server:home_server_setup:other_services:bash]] +    *[[https://linuxhandbook.com/hard-link/|Everything Important You Need to Know About Hard Link in Linux]] 
-*[[home_server:home_server_setup:other_services:vim]] +    *[[https://linuxhandbook.com/symbolic-link-linux/|What is Symbolic Links in Linux? How to Create Symbolic Links?]] 
-*[[home_server:home_server_setup:other_services:symlinks]] +  *[[https://www.baeldung.com/linux/soft-links-to-directories|How to Create Soft Links to Directories]] (Baeldung) 
-*[[home_server:home_server_setup:other_services:fail2ban]] +  *[[https://www.theunixschool.com/|The Unix School]] 
-*[[home_server:home_server_setup:other_services:monit]] +    *[[https://www.theunixschool.com/2011/06/inode-all-about-inodes.html| Inode - All about inodes]] 
-*[[home_server:home_server_setup:other_services:tripwire]] +    *[[https://www.theunixschool.com/2012/03/soft-links-hard-links-all-about-inodes.html||Soft Links & Hard Links - All about Inodes - Part 2]] 
-*[[home_server:home_server_setup:other_services:misc]] +    *[[https://www.theunixschool.com/2012/08/move-files-and-directories-inodes-part-3.html|Move files and directories Inodes Part 3]] 
-</pagelist>+++++ 
 + 
 +----
  
-<- home_server:home_server_setup:other_services:vim|Prev ^ home_server:home_server_setup:other_services:index|Start page ^ home_server:home_server_setup:other_services:fail2ban|Next ->+<- home_server:home_server_setup:other_services:systemd|Prev ^ home_server:home_server_setup:other_services:index|Start page ^ home_server:home_server_setup:other_services:fail2ban|Next ->