Cheatsheet: Difference between revisions
Content added Content deleted
Line 670: | Line 670: | ||
== Sort links vs Hard link == |
== Sort links vs Hard link == |
||
;Links and index number in Linux |
|||
* In the output of ls -l, the column following the permissions and before owner is the link count. |
|||
drwxr-xr-x '''6''' aman aman 4096 Mar 30 11:50 Documents |
|||
drwxr-xr-x '''3''' aman aman 4096 Sep 15 19:11 Downloads |
|||
^ |
|||
* Link count is the number of Hard Links to a file. |
|||
* A link is a pointer to another file. |
|||
* There are two types of links: |
|||
;Symbolic links (or Soft Links) |
|||
* A separate file whose contents point to the linked-to file. |
|||
* When creating a Sym link, first refer to the name of the original file and then to the name of the link: |
|||
ln -s /home/bob/sync.sh filesync |
|||
* Editing Sym link is like directly edit the original file. |
|||
* If we delete or move the original file, the link will be broken and our filesync file will not be longer available. |
|||
* The ls -l command shows that the resulting file is a symbolic link: |
|||
ls -l filesync |
|||
lrwxrwxrwx 1 root root 20 Apr 7 06:08 filesync -> /home/bobbin/sync.sh |
|||
* The contents of a symbolic link are the name of target file only. |
|||
* The permissions on the symbolic link are completely open. |
|||
* This is because the permissions are not managed |
|||
* The original file is just a name that is connected directly to the inode, and the symbolic link refers to the name. |
|||
* The size of the symbolic link is the number of bytes in the name of the file it refers to, because no other information is available in the symbolic link. |
|||
;Hard links |
|||
== Hosts file == |
== Hosts file == |