There are 2 types of links: Hard links and Symbolic links.
Hard Links | Symbolic Links |
Each hard link is a reference to the same i-node number (a key in the i-node table - inode entry for a file can be viewed using stat<<filename>>). | Each symbolic link contains the pathname of the source file. |
Source cannot be a directory | Source can be a directory |
Source & destination must be in the same file systems (because inode numbers are unique only within one file system) | Source and destination can reside anywhere |
e.g.:
~/temp$ ls --inode source.txt # List file with inode number
2131296 source.txt
~/temp$ cp --link source.txt link-copied.txt # a hard link
~/temp$ cp --symbolic-link source.txt symbolic-link-copied.txt # a symbolic link
~/temp$ ls --inode source.txt link-copied.txt symbolic-link-copied.txt
2131296 link-copied.txt
2131296 source.txt # hard link: i-node numbers of source and destination files are same
2133544 symbolic-link-copied.txt # symbolic link: i-node numbers differ
No comments:
Post a Comment