The difference between soft link, hard link and copy file (cp) in Linux

Copying a file (cp) will recreate a file and copy the same content, occupying a new space, a new inode, these are two files.

For hard links, the hard links will be updated synchronously after the source file is changed.
It is equivalent to copying cp -p + synchronous update
. The hard link can still be opened after the source file is deleted.
Hard links can only be used for files, not directories.
Hard links cannot span partitions.
The i-node and the source file are the same.

As for the soft link, the soft link cannot be opened after the source file is deleted.
It is equivalent to that the target pointed to by the shortcut under Windows does not exist,
and a link can be created for the directory for the soft link.
The permission of the soft link is rwx, and the arrow points to the source file.
The file size is only the size of the symbolic link
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_43811879/article/details/113828519