Thursday, March 5, 2009

NTFS symbolic link

An NTFS symbolic link (symlink) is a file-system object in the NTFS filesystem that points to another file system object. The object being pointed to is called the target. Symbolic links should be transparent to users; the links appear as normal files or directories, and can be acted upon by the user or application in exactly the same manner. Symbolic links are designed to aid in migration and application compatibility with POSIX operating systems, and were introduced with the modifications made to the NTFS file system with Windows Vista.

Unlike a NTFS junction point (available since Windows 2000), a symbolic link can also point to a file or remote SMB network path. Additionally, the NTFS symbolic link implementation provides full support for cross-filesystem links. However, the functionality enabling cross-host symbolic links requires that the remote system also support them, which effectively limits their support to Windows Vista and later Windows operating systems.

Symbolic links can point to non existent targets because operating system does not check to see if the target exists.

Restrictions:
The default security settings in Windows Vista disallow non-elevated administrators and all non-administrators from creating symbolic links. This behavior can be changed in the Local Security Policy management console (under: Security Settings\Local Policies\User Rights Assignment\Create symbolic links). It can be worked around by starting cmd.exe with Run as administrator option or the runas command.

Since Windows Vista Home does not have the Local Security Policy Management Console, the command line utility ntrights.exe from the Windows Server 2003 Resource Kit Tools can be used to grant rights to symbolic link creation.

Syntax:
The mklink command is used to create a symbolic link. It has the following command line syntax:

mklink [[/D] | [/H] | [/J]] link target

/D – Creates a directory symbolic link. Default is a file symbolic link.
/H – Creates a hard link instead of a symbolic link.
/J – Creates a Directory Junction.
link – Specifies the new symbolic link name.
target – Specifies the path (relative or absolute) that the new link refers to.
Just like ordinary files and folders, del and rmdir can be used to delete the symbolic links to files and directories respectively.

To delete symbolic link to a file, the following command line syntax can be used:

del filename

filename – Specifies the name of the file/symbolic link to be deleted
To delete symbolic link to a folder, the following command line syntax can be used:

rmdir directoryname

directoryname – Specifies the name of the folder/symbolic link to be deleted

No comments:

Post a Comment