Mklink in Windows

Mklink is a MS Windows command line utility that you can use to create symbolic links or symlinks and hard links in MS Windows. Mklink is a nice tool for troubleshooting file system problems. Mklink requires administrative privileges.

This page relates to explaining the difference between symbolic links and hard links on the Difference between symbolic link and hard link page.

First, let's introduce the mklink command. You can see it in the following print screen:

201204261733406074

It is pretty self-explanatory. Now, let's take a look at an example.

Mklink example

The print screen shown below demonstrates creating symbolic links, hard links, and shortcuts in MS Windows and how they differ.

Symbolic link:

  • Created as mklink link_name target_name

  • The icon next to the link is the same like that of a shortcut

  • Occupies zero space in the system

  • It is not a separate file in the file system

  • Interpreted at the operating system level

  • If the original file is deleted, the link is useless

  • Removing the original file does not remove the symbolic link

  • Removing the symbolic link does not remove the original file

Hard link:

  • Created as mklink /H link_name target_name

  • The space it occupies equals the size of the original file, but refers to the same object in the system (not a copy)

  • Interpreted at the operating system level

  • The icon next to the hard link is different from the other objects

  • Removing the original file does not remove the hard link

  • Removing the hard link does not remove the original file

  • If the original file is deleted, its content is still available through the hard link

  • Making a change to the hard link propagates all changes to the original file

Shortcut:

  • Created by right clicking the original file and selecting action from the drop down menu

  • A file in the system that is completely separate from the original file

  • Only those programs that know the concept of shortcuts understand them

  • If the original file is deleted, the link is useless

  • Removing the original file does not remove the shortcut

  • Removing the shortcut does not remove the original file

The print screen below shows these concepts.

20120426173418942

Linux uses a similar command called ln.

Mklink in Windows versus Ln in Linux

Note, the mklink syntax is a bit different from the Linux ln syntax (ln is used in Linux to create links).

Mklink: The name of the link is followed by the name of the target in the mklink command syntax. If you do not specify any flag, the mklink utility creates a symbolic link by default.

Ln: The name of the target is followed by the name of the link. If you want to create a symlink, you have to specifically include the -s flag.

转载于:https://my.oschina.net/jacobin/blog/300909

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值