Windows 7 Forums


Reply
Thread Tools

Useful command-line: MKLINK (NTFS symbolic links)

 
 
Yousuf Khan
Guest
Posts: n/a
Thanked:
 
      09-14-2011
NTFS symbolic link - Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/NTFS_symbolic_link

For those of you familiar with Unix/Linux this is exactly the same thing
as the "ln" command in those operating systems, which creates hard and
soft symbolic links. Mklink is POSIX-compliant too.

For those you not familiar with that Unix command, then you can consider
this to be an aliasing command for files and folders. It lets you create
an alias name for any files or folders without actually having to make a
new copy of those files or folders. This is different than the familiar
Windows shortcuts, as shortcuts are not transparent to applications.
This means that you can access a file inside an application with its
original name, or its alias name, and the program will not be aware of a
difference. If you tried this with the old Shortcuts, the program would
need to know that it's a shortcut, and then it would need to read inside
the shortcut to find the original file. A symbolic link on the other
hand is just another entry in the file system for the same file.

This command is only available in Vista and Win7, it wasn't available in
XP. There might be a separate command available in XP though.

There is also a GUI available for this, if you don't want to mess with
the command line, called symlinker. It's just a frontend for the mklink
command.

symlinker - Symbolic Link Creator. GUI for mklink, Microsoft Windows
symlink utility - Google Project Hosting
http://code.google.com/p/symlinker/

Yousuf Khan
 
Reply With Quote
 
 
 
 
Gene E. Bloch
Guest
Posts: n/a
Thanked:
 
      09-14-2011
On Wed, 14 Sep 2011 09:49:22 -0400, Yousuf Khan wrote:

> NTFS symbolic link - Wikipedia, the free encyclopedia
> http://en.wikipedia.org/wiki/NTFS_symbolic_link
>
> For those of you familiar with Unix/Linux this is exactly the same thing
> as the "ln" command in those operating systems, which creates hard and
> soft symbolic links. Mklink is POSIX-compliant too.
>
> For those you not familiar with that Unix command, then you can consider
> this to be an aliasing command for files and folders. It lets you create
> an alias name for any files or folders without actually having to make a
> new copy of those files or folders. This is different than the familiar
> Windows shortcuts, as shortcuts are not transparent to applications.
> This means that you can access a file inside an application with its
> original name, or its alias name, and the program will not be aware of a
> difference. If you tried this with the old Shortcuts, the program would
> need to know that it's a shortcut, and then it would need to read inside
> the shortcut to find the original file. A symbolic link on the other
> hand is just another entry in the file system for the same file.
>
> This command is only available in Vista and Win7, it wasn't available in
> XP. There might be a separate command available in XP though.
>
> There is also a GUI available for this, if you don't want to mess with
> the command line, called symlinker. It's just a frontend for the mklink
> command.
>
> symlinker - Symbolic Link Creator. GUI for mklink, Microsoft Windows
> symlink utility - Google Project Hosting
> http://code.google.com/p/symlinker/
>
> Yousuf Khan


Thanks. It seems worth at least a look, so I grabbed the link.

--
Gene E. Bloch (Stumbling Bloch)
 
Reply With Quote
 
Char Jackson
Guest
Posts: n/a
Thanked:
 
      09-15-2011
On Wed, 14 Sep 2011 15:25:04 -0700, "Gene E. Bloch"
<not-> wrote:

>On Wed, 14 Sep 2011 09:49:22 -0400, Yousuf Khan wrote:
>
>> symlinker - Symbolic Link Creator. GUI for mklink, Microsoft Windows
>> symlink utility - Google Project Hosting
>> http://code.google.com/p/symlinker/

>
>Thanks. It seems worth at least a look, so I grabbed the link.


Put it back when you're done. Someone else may want to use it.

--

Char Jackson
 
Reply With Quote
 
Yousuf Khan
Guest
Posts: n/a
Thanked:
 
      09-15-2011
On 14/09/2011 6:25 PM, Gene E. Bloch wrote:
>> There is also a GUI available for this, if you don't want to mess with
>> the command line, called symlinker. It's just a frontend for the mklink
>> command.
>>
>> symlinker - Symbolic Link Creator. GUI for mklink, Microsoft Windows
>> symlink utility - Google Project Hosting
>> http://code.google.com/p/symlinker/
>>
>> Yousuf Khan

>
> Thanks. It seems worth at least a look, so I grabbed the link.


I discovered the symbolic link feature of Windows as I was trying out a
new duplicate file finder program called Duplicate Cleaner. One of its
cleanup options beyond just deleting duplicates is an ability to replace
duplicates with symbolic links instead. This way you can keep all of the
filenames in their original places, but not have them taking up any
additional space on your disk, since all of the filenames point back to
just a single actual file.

Prior to this, I was grumbling about why Windows doesn't have anything
as useful as the Unix symbolic links. Of course, the old Windows
shortcuts were crappy imitations of symbolic links. The Windows "mklink"
command even preserves the feel of the Unix "ln" (link) command. Not
that it matters to anyone not familiar with Unix, but this is
Microsoft's attempt at making Windows POSIX-compliant, so they did a
fairly good job at it.

Yousuf Khan
 
Reply With Quote
 
Gene E. Bloch
Guest
Posts: n/a
Thanked:
 
      09-15-2011
On Wed, 14 Sep 2011 19:53:27 -0500, Char Jackson wrote:

> On Wed, 14 Sep 2011 15:25:04 -0700, "Gene E. Bloch"
> <not-> wrote:
>
>>On Wed, 14 Sep 2011 09:49:22 -0400, Yousuf Khan wrote:
>>
>>> symlinker - Symbolic Link Creator. GUI for mklink, Microsoft Windows
>>> symlink utility - Google Project Hosting
>>> http://code.google.com/p/symlinker/

>>
>>Thanks. It seems worth at least a look, so I grabbed the link.

>
> Put it back when you're done. Someone else may want to use it.


Good point. I'll try to get to it quickly so I don't keep it too long.

Thanks for the moral guidance.

--
Gene E. Bloch (Stumbling Bloch)
 
Reply With Quote
 
Gene E. Bloch
Guest
Posts: n/a
Thanked:
 
      09-15-2011
On Wed, 14 Sep 2011 21:58:03 -0400, Yousuf Khan wrote:

> On 14/09/2011 6:25 PM, Gene E. Bloch wrote:
>>> There is also a GUI available for this, if you don't want to mess with
>>> the command line, called symlinker. It's just a frontend for the mklink
>>> command.
>>>
>>> symlinker - Symbolic Link Creator. GUI for mklink, Microsoft Windows
>>> symlink utility - Google Project Hosting
>>> http://code.google.com/p/symlinker/
>>>
>>> Yousuf Khan

>>
>> Thanks. It seems worth at least a look, so I grabbed the link.

>
> I discovered the symbolic link feature of Windows as I was trying out a
> new duplicate file finder program called Duplicate Cleaner. One of its
> cleanup options beyond just deleting duplicates is an ability to replace
> duplicates with symbolic links instead. This way you can keep all of the
> filenames in their original places, but not have them taking up any
> additional space on your disk, since all of the filenames point back to
> just a single actual file.
>
> Prior to this, I was grumbling about why Windows doesn't have anything
> as useful as the Unix symbolic links. Of course, the old Windows
> shortcuts were crappy imitations of symbolic links. The Windows "mklink"
> command even preserves the feel of the Unix "ln" (link) command. Not
> that it matters to anyone not familiar with Unix, but this is
> Microsoft's attempt at making Windows POSIX-compliant, so they did a
> fairly good job at it.
>
> Yousuf Khan


I will assume (read: hope) that Windows does the right thing when links
are deleted, i.e., not put the link into the recycle bin, and of course
delete the underlying file if and only if the last symbolic link goes
away.

And it's easy to test the above.

And I have to go look at the site now - I promised Char.

--
Gene E. Bloch (Stumbling Bloch)
 
Reply With Quote
 
Gene E. Bloch
Guest
Posts: n/a
Thanked:
 
      09-15-2011
On Wed, 14 Sep 2011 20:01:33 -0700, Gene E. Bloch wrote:

> On Wed, 14 Sep 2011 21:58:03 -0400, Yousuf Khan wrote:
>
>> On 14/09/2011 6:25 PM, Gene E. Bloch wrote:
>>>> There is also a GUI available for this, if you don't want to mess with
>>>> the command line, called symlinker. It's just a frontend for the mklink
>>>> command.
>>>>
>>>> symlinker - Symbolic Link Creator. GUI for mklink, Microsoft Windows
>>>> symlink utility - Google Project Hosting
>>>> http://code.google.com/p/symlinker/
>>>>
>>>> Yousuf Khan
>>>
>>> Thanks. It seems worth at least a look, so I grabbed the link.

>>
>> I discovered the symbolic link feature of Windows as I was trying out a
>> new duplicate file finder program called Duplicate Cleaner. One of its
>> cleanup options beyond just deleting duplicates is an ability to replace
>> duplicates with symbolic links instead. This way you can keep all of the
>> filenames in their original places, but not have them taking up any
>> additional space on your disk, since all of the filenames point back to
>> just a single actual file.
>>
>> Prior to this, I was grumbling about why Windows doesn't have anything
>> as useful as the Unix symbolic links. Of course, the old Windows
>> shortcuts were crappy imitations of symbolic links. The Windows "mklink"
>> command even preserves the feel of the Unix "ln" (link) command. Not
>> that it matters to anyone not familiar with Unix, but this is
>> Microsoft's attempt at making Windows POSIX-compliant, so they did a
>> fairly good job at it.
>>
>> Yousuf Khan

>
> I will assume (read: hope) that Windows does the right thing when links
> are deleted, i.e., not put the link into the recycle bin, and of course
> delete the underlying file if and only if the last symbolic link goes
> away.
>
> And it's easy to test the above.
>
> And I have to go look at the site now - I promised Char.


Fils in tow ways...

One is that the links do go to the recycle bin on deletion - but that is
just my opinion as to what is right, and really shouldn't count.

The other is more serious and is *not* Unix-like[1]. True enough, if you
delete the existing symbolic links, the file itself is not deleted. But
if you delete the file, the symbolic links point to nothing.

[1] Or maybe in the dozen years since I did anything Unix, I forgot the
distinctions between the different link types. So I'll do another
experiment before clicking on Send...

This is better. This time I made *hard* links and deleted the original
file, but the links I made still pointed to the right contents. I
couldn't really test whether the file still existed after I deleted both
hard links (sort of like Captain Kirk floating outside the Enterprise
after a transporter malfunction), because I don't know, and am too lazy
to find out at the moment, how to browse the file system appropriately.

Delete still uses the recycle bin, however, but as I said...

--
Gene E. Bloch (Stumbling Bloch)
 
Reply With Quote
 
Gene E. Bloch
Guest
Posts: n/a
Thanked:
 
      09-15-2011
On Wed, 14 Sep 2011 20:30:43 -0700, Gene E. Bloch wrote:

> Fils in tow ways...


I meant "Fails in two ways..." :-)

--
Gene E. Bloch (Stumbling Bloch)
 
Reply With Quote
 
Char Jackson
Guest
Posts: n/a
Thanked:
 
      09-15-2011
On Wed, 14 Sep 2011 20:01:33 -0700, "Gene E. Bloch"
<not-> wrote:

>I will assume (read: hope) that Windows does the right thing when links
>are deleted, i.e., not put the link into the recycle bin, and of course
>delete the underlying file if and only if the last symbolic link goes
>away.
>
>And it's easy to test the above.
>
>And I have to go look at the site now - I promised Char.


:-)

--

Char Jackson
 
Reply With Quote
 
Yousuf Khan
Guest
Posts: n/a
Thanked:
 
      09-15-2011
On 14/09/2011 11:30 PM, Gene E. Bloch wrote:
> Fils in tow ways...
>
> One is that the links do go to the recycle bin on deletion - but that is
> just my opinion as to what is right, and really shouldn't count.
>
> The other is more serious and is *not* Unix-like[1]. True enough, if you
> delete the existing symbolic links, the file itself is not deleted. But
> if you delete the file, the symbolic links point to nothing.


I'll just point out some terminology that I use so there's no confusion,
I know terminology is a little ambiguous sometimes. I use the term
"symbolic link" as a generic term for both types of links, and I use the
terms "hard link" and "soft link" more specifically. I know often some
people equate "symbolic link" to "soft link", but I don't.

> [1] Or maybe in the dozen years since I did anything Unix, I forgot the
> distinctions between the different link types. So I'll do another
> experiment before clicking on Send...


That'll happen in Unix too, when you're using soft links rather than
hard links. The main advantage to soft links over hard links is that you
can use them to point to files in other file systems, even over network
file systems. The main disadvantage is as you said, that if the original
file goes missing, then soft links remain as orphans. Hard links can
never be orphaned, as each link is just as legitimate a pointer to file
as all of the other links, but they can't cross file system boundaries.

> This is better. This time I made *hard* links and deleted the original
> file, but the links I made still pointed to the right contents. I
> couldn't really test whether the file still existed after I deleted both
> hard links (sort of like Captain Kirk floating outside the Enterprise
> after a transporter malfunction), because I don't know, and am too lazy
> to find out at the moment, how to browse the file system appropriately.


In computerese, hard links maintain coherency, but soft links don't. But
you give up flexibility with hard links.

Yousuf Khan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT +1. The time now is 11:51 AM.
W7Forums is an independent website and is not affiliated with Microsoft Corporation.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33