Directory-Symbolic-Link

发布 : 2020-12-18 分类 : 笔记 浏览 :

In the context of NTFS:

MKLINK [[/D] | [/H] | [/J]] Link Target

    /D      创建目录符号链接。默认为文件
            符号链接。
    /H      创建硬链接而非符号链接。
    /J      创建目录联接。
    Link    指定新的符号链接名称。
    Target  指定新链接引用的路径
            (相对或绝对)。
  1. Isn’t a directory junction the exact same thing as a directory symbolic link?

    What’s the difference between mklink /D f1 f2 and mklink /J f1 f2 ?

  2. Since a “directory” is actually just a file, what would be the difference between a directory symbolic link and a file symbolic link?

A junction is definitely not the same thing as a directory symbolic link, although they behave similarly. The main difference is that, if you are looking at a remote server, junctions are processed at the server and directory symbolic links are processed at the client. Also see Matthew’s comment on the fact that this means symbolic links on the local file system can point to remote file systems.

Suppose that on a machine named Alice you were to put a junction point c:\myjp and a directory symbolic link c:\mysymlink, both pointing to c:\targetfolder. While you’re using Alice you won’t notice much difference between them. But if you’re using another machine named Bob, then the junction point

1
\\Alice\c$\myjp` will point to `\\Alice\c$\targetfolder

but the symbolic link

1
\\Alice\c$\mysymlink` will point to `\\Bob\c$\targetfolder

(Caveat: by default, the system doesn’t follow symlinks on remote volumes, so in most cases the second example will actually result in either “File Not Found” or “The symbolic link cannot be followed because its type is disabled.”)

The difference between a directory symbolic link and a file symbolic link is simply that one represents a directory and one represents a file. Since the target of the link doesn’t need to exist when the link is created, the file system needs to know whether to tell applications that it is a directory or not.

It should also be noted that creating a symbolic link requires special privilege (by default, only available to elevated processes) whereas creating a junction only requires access to the file system.

source

本文作者 : preccrep
原文链接 : https://preccrep.github.io/2020/12/18/Directory-Symbolic-Link/
版权声明 : 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!
留下足迹

博客已萌萌哒运行(●'◡'●)ノ♥
Theme - BMW | Made With 💗 | Powered by GodBMW