Differences
This shows you the differences between two versions of the page.
linux_wiki:create_hard_and_soft_links [2016/02/28 22:57] billdozor created |
linux_wiki:create_hard_and_soft_links [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Create Hard And Soft Links ====== | ||
- | **General Information** | ||
- | |||
- | About this page/ | ||
- | |||
- | ---- | ||
- | |||
- | 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 | ||
- | |||
- | Example listing of a symbolic link | ||
- | <code bash> | ||
- | ls -l / | ||
- | lrwxrwxrwx. 1 root root 37 Oct 17 2014 default.target -> / | ||
- | </ | ||
- | |||
- | Create symlink | ||
- | <code bash> | ||
- | ln -s /etc/motd motd-local | ||
- | </ | ||
- | * Creates a symlink to "/ | ||
- | |||
- | Create hardlink | ||
- | <code bash> | ||
- | touch file1 | ||
- | ln file1 file2 | ||
- | </ | ||
- | |||
- | 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 | ||
- | </ | ||
- | * Notice the column with " | ||
- | |||
- | 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 | ||
- | </ | ||
- | * Notice the first column shows the same inode for file1 and file2. | ||
- | |||
- | ---- |