The command ln for linking files has never been well understood and depressing. But now I don't want to spend too much time on Linux commands, so I will first talk about what I know, and then I will understand it in practice.
The result of the ln command is similar to the shortcut in windows. You can access the same file from different paths. However, it is similar to shortcuts.
There are two types of file links: hard link and symbolic link. The descriptions are as follows:
Hard link: a hard link registers an object in multiple directories. For example, the file file1 was originally in directory A, and then added a hard link to file 1 in directory B. Then, the file can be seen in both directory A and directory B. The number of hard links in this file is 2.
Hard links have a few restrictions:
(1) The directory file cannot be hard linked.
(2) hard links cannot be made between different file systems. That is to say, to establish a hard link, it must be built on the same file system.
Symbolic Link: the symbolic link actually links a file in B, and then the file in B points to.
The ln command format is as follows: ln [Option] source file [target file], where-s option indicates that a symbolic link is added, and hard links are added by default.
The following is an example I used a few days ago. I have a folder on the mounted disk and often need to access it, but it looks awkward. So I want to create a link on the desktop. Assume that I am under my directory, and the current folder contains the Desktop Folder, enter the following command to create a link: ln-S/Windows/hdc7/ebook. /desktop/allebook, OK. A folder already exists on the desktop.
In addition, what I want to talk about is just my understanding. Because of the short schedule, I simply read it. An incorrect understanding may occur. Do not mislead anyone who can see this word.