Distinguish the difference between Linux soft link hard link connected linux soft and hard links

The difference between Linux soft link hard links

 

     ln the linux is another very important command, its function is to establish a link synchronization at another location for a certain file. When we need a different directory, use the same file, we do not need every need are put in a directory must be the same file, as long as we have a fixed directory, put the file, and then use the ln command links (link) it can, without having to repeat the disk space occupied in other directories.

1. Format:
 LN [parameters] [source file or directory] [destination file or directory]

2. Function:
Linux file system, the so-called link (link), we can be regarded as an alias files, and links can be divided into two types: hard link (hard link) with a soft link (symbolic link), hard link means that a file can have multiple names, and soft link is the way to produce a special file, the contents of the file that points to another file location. A hard link is the presence of the same file system, but it can be a soft link across different file systems.

Soft Link:
1. soft link, in the form of the path. Similar to the Windows operating system shortcuts
2. soft links can span file systems, hard links can not
3. soft link to the file name can be a non-existent link
4. soft link to the directory link

Hard Links:
1. hard link, in the form of a copy of the file. But do not take up physical space.
2. The directory is not allowed to create a hard link
3. hard links only with a file system can be created
where there are two points to note:
First, ln command will keep every link file synchronization, that is, whether you have changed what, the same changes in other documents occurs;
second, ln link is divided into two kinds of soft links and hard links, soft links ln -s source file is the target file, it will only be selected in you generate a file location on the mirror, do not take up disk space, hard links ln source destination file, no argument -s, it will generate the same source file and a file size of your selected position, whether it is soft link or hard link files are synchronized change.
ln link instruction is used in a file or directory, such as specifying two or more files or directories, and the final destination is a directory already exists, it will copy all files or directories to the previously specified directory. If specify multiple files or directories, and not the final destination is an existing directory, an error message appears.

3. Command parameters:
the necessary parameters:
-b delete, covering previously established links
-d allows super users to create hard links to directories
-f enforce
-i interactive mode, the user is prompted whether the file exists covering
-n generally regarded as the symbolic link directory
-s soft links (symlinks)
-v displays detailed process

Selection parameters:
-S "-S <backup suffix string>" or "--suffix = <backup suffix string>"
-V "-V <backup>" or "--version-control = <backup way> "
--help display this help
--version show version information

4. Example:
Example 1: Create a soft link to the file
in order to explain the relative path to create a soft link issues more carefully, we create a few folders deep point

 1 mkdir -p /app/a{1..3}/b{c..f} 

Probably the hierarchy may have a look, app directory and the etc directory is under the root directory

Suppose we give app / a1 / bc root directory to make a soft link pointing to /magedu/ZD/2g/login.bat this position under the root directory, so it should be written like a soft link

 1 ln -s ../../../magedu/ZD/2g/login.bat /app/a1/bc/softlink1 

How many students will be confused this target path relative path to write the relative path to the file or folder that you want to file a soft link to the folder where the starting point , relative to the file system how to specify the path he walked.

This case is a soft link to the directory app / a1 / bc in the root directory, then this is the point bc Folder folder, returning from the floor up here to a1, grammar is ../, then a layer up to the app file ../ a clip again, because magedu in the root directory, so it needs to return to the root level that is three ../ root directory know how to express, the next is the order posted to the source file's absolute path the address. Will establish a multi-layer directory, then shallow directory would not have said.

 How to view links established themselves there is no problem, into the soft link directory ls view, if the name of the file is a soft link light blue.

     ln the linux is another very important command, its function is to establish a link synchronization at another location for a certain file. When we need a different directory, use the same file, we do not need every need are put in a directory must be the same file, as long as we have a fixed directory, put the file, and then use the ln command links (link) it can, without having to repeat the disk space occupied in other directories.

1. Format:
 LN [parameters] [source file or directory] [destination file or directory]

2. Function:
Linux file system, the so-called link (link), we can be regarded as an alias files, and links can be divided into two types: hard link (hard link) with a soft link (symbolic link), hard link means that a file can have multiple names, and soft link is the way to produce a special file, the contents of the file that points to another file location. A hard link is the presence of the same file system, but it can be a soft link across different file systems.

Soft Link:
1. soft link, in the form of the path. Similar to the Windows operating system shortcuts
2. soft links can span file systems, hard links can not
3. soft link to the file name can be a non-existent link
4. soft link to the directory link

Hard Links:
1. hard link, in the form of a copy of the file. But do not take up physical space.
2. The directory is not allowed to create a hard link
3. hard links only with a file system can be created
where there are two points to note:
First, ln command will keep every link file synchronization, that is, whether you have changed what, the same changes in other documents occurs;
second, ln link is divided into two kinds of soft links and hard links, soft links ln -s source file is the target file, it will only be selected in you generate a file location on the mirror, do not take up disk space, hard links ln source destination file, no argument -s, it will generate the same source file and a file size of your selected position, whether it is soft link or hard link files are synchronized change.
ln link instruction is used in a file or directory, such as specifying two or more files or directories, and the final destination is a directory already exists, it will copy all files or directories to the previously specified directory. If specify multiple files or directories, and not the final destination is an existing directory, an error message appears.

3. Command parameters:
the necessary parameters:
-b delete, covering previously established links
-d allows super users to create hard links to directories
-f enforce
-i interactive mode, the user is prompted whether the file exists covering
-n generally regarded as the symbolic link directory
-s soft links (symlinks)
-v displays detailed process

Selection parameters:
-S "-S <backup suffix string>" or "--suffix = <backup suffix string>"
-V "-V <backup>" or "--version-control = <backup way> "
--help display this help
--version show version information

4. Example:
Example 1: Create a soft link to the file
in order to explain the relative path to create a soft link issues more carefully, we create a few folders deep point

 1 mkdir -p /app/a{1..3}/b{c..f} 

Probably the hierarchy may have a look, app directory and the etc directory is under the root directory

Suppose we give app / a1 / bc root directory to make a soft link pointing to /magedu/ZD/2g/login.bat this position under the root directory, so it should be written like a soft link

 1 ln -s ../../../magedu/ZD/2g/login.bat /app/a1/bc/softlink1 

How many students will be confused this target path relative path to write the relative path to the file or folder that you want to file a soft link to the folder where the starting point , relative to the file system how to specify the path he walked.

这个例子里软链接所在目录为根目录下的app/a1/bc,那么这个bc文件夹就是基点文件夹,从这里向上一层返回到a1,语法就是../,再向上一层到app文件夹再来一个../,因为magedu在根目录下,所以还需要一层返回到根目录 那也就是三个../,根目录知道如何表达了,接下来就是顺序贴指向源文件的绝对路径地址了。多层目录建立会了,那么浅层目录就不用说了。

 如何查看自己建立的链接有没有问题,就进入到软链接目录里ls查看,软链接名字的文件是否为浅蓝色。

Guess you like

Origin www.cnblogs.com/chengege/p/11124296.html