Linux system link summary

Summary of Links to Documents

  1. Deleting soft link files has no effect on source files and hard link files.
  2. Deleting hard-linked files has no effect on source files and soft-linked files.
  3. Deleting the source file has no effect on the hard link file, but it will cause the soft link file to fail, and white characters on a red background will flash.
  4. Delete the source file and hard link file at the same time, and the entire file will be deleted.
  5. The snapshot function in many hardware devices uses the principle of hard links.
  6. Source files and hard-linked files have the same inode number and can be considered to be the same file or multiple entries of a file.
  7. The source file and the soft link file have different inode numbers and are different files. The soft link is equivalent to the shortcut of the source file, containing the shortcut of the source file, and the location of the source file.

Summary of Directory Links

  1. For directories, you cannot create hard links, but you can create soft links.
  2. Soft links to directories are common techniques for operation and maintenance in production scenarios.
  3. Hard links to directories cannot span filesystems.
  4. There is a hard link "." under each directory, and a hard link ".." corresponding to the parent directory.
  5. Create a subdirectory in the parent directory, add 1 to the number of links in the parent directory (all subdirectories have .. pointing to the parent directory). But if you create a file in the parent directory, the number of links in the parent directory will not increase.

interview questions

Describe the difference between soft links and hard links under linux.

answer:

In the Linux system, there are two types of links: one is called a hard link (Hard Link), and the other is called a symbolic link or a soft link (Symbolic Link).

  1. Without parameters by default, the ln command creates a hard link, and the ln command with the -s parameter creates a soft link.
  2. A hard link has the same inode number as the original file, while a soft link file has a different inode number than the source file.
  3. The ln command cannot create hard links to directories, but it can create soft links. Soft links to directories are often used.
  4. Deleting soft link files has no effect on source files and hard link files.
  5. Deleting hard link files has no effect on source files and soft link files.
  6. Deleting the source file of the linked file has no effect on the hard linked file, and will cause its soft link to fail (white text on a red background flashes).
  7. Delete the source file and hard link file at the same time, and the entire file will be truly deleted.
  8. The snapshot function in many hardware devices uses the principle of a hard link.

  1. Soft links can cross file systems, but hard links cannot.

Reprinted to https://blog.csdn.net/codetz/article/details/52425213

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325700346&siteId=291194637