8/08/2008

Symlink Functionality on Windows (NTFS) With Junction Points

Junction Points in NTFS 3.0+ allow you to make one or more links to a folder that acts like the folder itself.

As I must use Microsoft Windows at work, I have greatly missed the joys of a UNIX platform. Until I started my present job, I was able to have a Linux or Solaris computer as my main computer for work, (and home!).

Since I joined an enormous corporate environment, I must comply with the corporate standards. Surprising to some of you, I can be compliant. Stop laughing! It just means I need to sanity hack[1] at home.

One feature that was dear to me on UNIX was the symlink, (symbolic link). Similar to windows shortcut, but virtually indistinguishable from an actual file or directory. You can still tell it is a link, but you can copy, rename and change directory (cd) into as if it was a normal directory. In reality, a symlink is a pointer to another file or directory. When you access the symlink, the computer knows to look at the actual location it points to. Read the wikipedia entry for more info.

I use a symlink to the current Groovy directory on my Mac. It looks like the following on MacOSX.
jmac:~ jalex$ls -ld /opt/groovy*
lrwxr-xr-x 1 root wheel 12 Jun 21 19:08 /opt/groovy@ -> groovy-1.5.6
drwxr-xr-x 9 root wheel 306 Feb 1 2008 /opt/groovy-1.5.4/
drwxr-xr-x 9 root wheel 306 Apr 25 16:00 /opt/groovy-1.5.6/
jmac:~ jalex$ cd /opt/groovy
jmac:/opt/groovy jalex$ pwd
/opt/groovy
jmac:/opt/groovy jalex$ ls
ASM-LICENSE.txt NOTICE.txt conf/ lib/
LICENSE.txt bin/ embeddable/
Junction Points!
This week, I found out that Microsoft indeed has similar functionality to the symlink, which Microsoft calls a junction. Here is a knowledgebase note from Microsoft on how to use it. You can actually mount shared drives to a junction point, but you should read the Microsoft Help and Support link above if you are crazy like that.

Two basic commands to deal with junction points:
  • linkd - You can create the junction point.
linkd \mydesktop %user profile%\desktop
  • delrp - to delete the junction point. The folder it points to remains intact.
delrp \mydesktop
Now you may treat \mydesktop as any other directory, (unless you want to delete it).
dir \mydesktop
cd \mydesktop
copy \temp\file.txt \mydesktop
Try it out.

Tangents
I abandoned Linux, after 11 years, for my main home computer and bought a Mac, which hides a BSD-based UNIX environment behind the pretty interface. I am an Apple fanboy now, with a little part of me still attached to Linux. I never really had windows as my primary home environment, because I depend on things it does not have. I used a text-based email client, elm or mutt, until only a couple of years ago when I experienced gmail (Google Mail).

If the cost is not outside of your budget, consider a Mac. Especially if you automate tasks with scripts or batch files. The Macs are more than just fashionable. They are more simple, reliable and flexible than windows. But if you have to use windows, there is VMWare and VirtualBox to help you install a nice copy of Xubuntu on it for the Linux fun you really want. MacOS X doesn't easily run on non-Apple hardware.

References:
Junction, UNIX, Xubuntu, VMWare, Mac, Solaris, Microsoft Windows, Google Mail,

[1] Sanity Hacking: to work on technology-related side-projects just to stay sane. I couldn't find an online reference, but Jared Richardson talked about it in his 2008 NoFluffJustStuff keynote titled "Career 2.0". I have a blog entry on this.

No comments: