create a link to a file or directory 



ln [-fiqRrv] old new

ln [-fiqRrsv] old old ... dir



The ln utility only works on NTFS file systems.

ln creates links to one or more files or directories. A normal hard link is a new directory entry that refers to the same file, either in the directory that currently contains the file or in a different directory. The result is a new path name that refers to the file. You can access the file using either the old path name or the new one; both path names are of equal importance. If you rm either name, the other one remains and the file contents are still available under that name. The contents of the file do not disappear until you remove the last link.

A file may have any number of links to it. Thus you can establish any number of different path names for any file.

A symbolic link is similar to a normal hard link but it can only be created for directories. See the description of the -s option below for more information on symbolic links.

In the first form given in the synopsis, new becomes a new path name for the file old. In the second form, ln creates entries for all the old files under the directory dir. For example,

ln yourdir/* mydir

creates links under mydir to all the files under yourdir. The files have the same names under mydir that they had under yourdir. ln always assumes this directory form when the last operand on the command line is the name of a directory. In this case, none of the old names may be a directory.

In some cases a file may have the same name as the link you are trying to set up. This file is referred to as the conflicting path name. To deal with a conflicting path name, ln follows these steps.



removes conflicting path names without asking for confirmation.


checks with you before getting rid of conflicting path names. (Note that the -f option overrides the -i option.)


suppresses warning messages. Error messages are still displayed.


links files recursively; that is, you can link an entire hierarchy of subdirectories at once.


is identical to -R.


creates a symbolic link. You can only create symbolic links on systems using the NTFS file system.

On Windows XP/Server 2003, symbolic links can only be created for directories on local drives; you cannot create a symbolic link for a file.

On Windows 7/2008R2/8/2012/10/2016, you can create symbolic links to both directories and files. However, to do so, the user must have the SeCreateSymbolicLinkPrivilege privilege. By default, this privilege is only assigned to administrators; however it can be assigned to any user through the use of standard Windows tools or the MKS Toolkit priv command. The target file or directory need not exist. It is perfectly legal (as it is on UNIX) to create a symblic link to a target that does not yet exist. However Windows (unlike UNIX) needs to know if the target will file or a directory. By default a file symbolic link will be created, but setting the environmant variable TK_MISSING_SYMLINK_TARGET_TYPE=D, a directory symbolkc link can be created.


The -s option does not work with drives which use removable media (for example, CD drives and tape drives).

A symbolic link is a pointer to the directory to which it is linked. Like a normal hard link, you can refer to the directory by either its original name or the name of the symbolic link. Unlike a normal hard link, deleting the original directory leaves a link pointing nowhere and the contents of the directory are gone.


When using Explorer, selecting a symbolic link and dragging it to the Recycle Bin (or hitting the DELETE key) deletes just the symbolic link. Using the Windows command line del command to delete a symbolic link deletes the symbolic link and the contents (excluding subdirectories and their contents) of the original directory, but not the original directory itself.


shows file names as they are processed.



When this variable is set, the Enhanced UNIX Compatibility Mode is on and the virtual file system is in use.

On Windows Windows 7/2008R2/8/2012/10/2016, when the Enhanced UNIX Compatibility Mode is on, the command:

ln -s target link

stores a relative path name only if that relative path name is valid when the Enhanced UNIX Compatibility Mode is off. If the relative path name is only valid when the Enhanced UNIX Compatibility Mode is off (that is, it refers to a virtual UNIX directory such as /home, /mnt, /usr/bin, /usr/tmp, /tmp, and so on), the absolute path name is stored in the link so that the link works the Enhanced UNIX Compatibility Mode is off.

On Windows Windows 7/2008R2/8/2012/10/2016, when the Enhanced UNIX Compatibility Mode is off, the command:

ln -s target link

allows target to be a relative path name. This path name is stored in link but ls -l and file -h will show the absolute path name of target. If you want to see the path name actually store in link, use ls -XA.

For more information, see the EUCM reference page.


Possible exit status values are:


All requested links were established successfully.


Failure due to any of the following:

— an argument had a trailing / but was not the name of a directory
— a file could not be found
— an input file could not be opened for reading
— an output file could not be created or opened for output
— the new link file already exists
— a link could not be established
— a read error occurred on an input file
— a write error occurred on an output file
— the input and output files were the same file
— inability to access a file when using -r
— inability to read a directory when using -r
— inability to create a directory when using -r
— a target is not a directory when using -r
— source and destination directory are the same when using -r

Failure due to any of the following:

— invalid command line option
— too few arguments on the command line
— a target that should be a directory but isn't
— no space left on target device
— out of memory to hold the data to be copied
— unable to create a directory to hold a target file


POSIX.2. x/OPEN Portability Guide 4.0. All UNIX systems. Windows 7. Windows Server 2008 R2. Windows 8. Windows Server 2012. Windows 10. Windows Server 2016.

Only the -f option is part of the POSIX standard.


PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
PTC Integrity


cp, mv, rm

PTC MKS Toolkit 10.1 Documentation Build 15.