Most of my friends may know that UNIX provides the link function for creating files, there may not be so many friends who have used the link function supported by the Windows NTFS file system (note that I am not talking about the shortcut function ). Today, I studied the relevant content for work reasons and shared it out. This article briefly introduces how to use the functions provided by the NTFS file system in Windows to create a link. NTFS supports two types of links: Junction Point and hard link.
Junction Point
Junction Point is a type of reparse point in the NTFS file system. It supports links to folder.
You can create a junction pointusing the junction.exe tool specified by sysinternals. the command format is as follows:
(Sysinternals tools can be downloaded from the http://www.microsoft.com/technet/sysinternals/default.mspx)
For example, we can create a link for C:/temp named C:/link_temp:
C:/> junction C:/link_temp C:/temp Junction v1.03-Win2k junction creator and reparse point Viewer Copyright (c) 2000-2002 mark russinovich Systems internals-http://www.sysinternals.com Created: C:/link_temp Targetted at: C:/temp |
Then, you can perform link_temp operations like normal folder:
C:/> dir C:/link_temp Volume in drive C is vista Volume serial number is 0c8f-86e1 Directory of C:/link_temp 07/15/2007 11: 48 am <dir>. 07/15/2007 11: 48 am <dir> .. |
Obviously, the shortcut cannot do this.
If you do not need this link, you can enter rmdir C:/link_temp at any time to delete it, even if C:/temp is not empty.
For details about the conjunction point, see: http://en.wikipedia.org/wiki/NTFS_junction_point
Windows 2000 resource kit also provides a similar tool for creating a conjunction point. You can refer to the following article:
Http://msdn2.microsoft.com/en-us/library/aa363878.aspx
Windows Vista provides more powerful symbolic link functions, which can be used for files. For details, see:
Http://msdn2.microsoft.com/en-us/library/aa363878.aspx
Hard Link
The difference between hard link and conjunction point is that hard link is similar to a reference to the actual file content. There are several different file names that reference the actual file content, so there are several references. When all references are deleted, the object content is deleted. Generally, the file name is considered as a special form of hard link, that is, only one file name references the actual file content. Any operation on all Referenced File Names changes the file content.
You can create a hard link through fsutil (exists on XP/2003/Vista) in the following format:
Fsutil hardlink create <link> <target> |
C:/> fsutil hardlink create test_1.txt test.txt Hardlink created for C:/test_1.txt <<==> C:/test.txt C:/> fsutil hardlink create test_2.txt test.txt Hardlink created for C:/test_2.txt <<==> C:/test.txt |
C:/> fsutil hardlink create test_1.txt test.txt Hardlink created for C:/test_1.txt <<==> C:/test.txt C:/> fsutil hardlink create test_2.txt test.txt Hardlink created for C:/test_2.txt <<==> C:/test.txt |
After deleting the original file test.txt, check whether test_1.txtand test_2.txt still exist and whether the content still exists. The answer is yes.
For details about hard link, see: http://en.wikipedia.org/wiki/Hard_link