linux_wiki:create_hard_and_soft_links

Differences

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

Link to this comparison view

linux_wiki:create_hard_and_soft_links [2016/02/29 22:58]
billdozor
linux_wiki:create_hard_and_soft_links [2019/05/25 23:50]
Line 1: Line 1:
-====== Create Hard And Soft Links ====== 
- 
-**General Information** 
- 
-Creating "short cuts" to files/directories.  
- 
----- 
- 
-===== Types of Links ===== 
- 
-Soft link 
-  * Link to a specific file location (can cross file systems) 
-  * Also known as symbolic link or symlink. 
-  * Like a simple shortcut; deleting a symlink does not remove original file. 
-  * Deleting original file breaks the symlink and data is gone. 
- 
-Hard link 
-  * Link to specific inode (cannot cross filesystems) 
-  * Data not gone until all hard links have been deleted 
- 
----- 
- 
-===== Symlinks ===== 
- 
-Example listing of a symbolic link 
-<code bash> 
-ls -l /etc/systemd/system/ 
-lrwxrwxrwx. 1 root root   37 Oct 17  2014 default.target -> /lib/systemd/system/multi-user.target 
-</code> 
- 
-Create symlink 
-<code bash> 
-ln -s /etc/motd motd-local 
-</code> 
-  * Creates a symlink to "/etc/motd" in the current directory, called "motd-local" 
- 
-===== Hard Links ===== 
- 
-Create hardlink 
-<code bash> 
-touch file1 
-ln file1 file2 
-</code> 
- 
-List the files 
-<code bash> 
-ll 
--rw-------. 1 root root       9227 Oct 17  2014 anaconda-ks.cfg 
--rw-r--r--. 2 root root          0 Jun 20 15:11 file1 
--rw-r--r--. 2 root root          0 Jun 20 15:11 file2 
-</code> 
-  * Notice the column with "2", meaning 2 links to the inode) 
- 
-List with inode (-i) information 
-<code bash> 
-ls -li 
-  8419076 -rw-------. 1 root root       9227 Oct 17  2014 anaconda-ks.cfg 
-  8442605 -rw-r--r--. 2 root root          0 Jun 20 15:11 file1 
-  8442605 -rw-r--r--. 2 root root          0 Jun 20 15:11 file2 
-</code> 
-  * Notice the first column shows the same inode for file1 and file2. 
- 
----- 
  
  • linux_wiki/create_hard_and_soft_links.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)