SYNOPSIS
ln
[
ln
[
DESCRIPTION
- Note:
-
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
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.
-
If you have specified
-i , ln writes a prompt to standard error to ask if you want to remove the conflicting path name. If you answer affirmatively, ln attempts to remove it. -
If you have specified
-f , ln attempts to remove the conflict silently. - Otherwise, ln prints a diagnostic message.
- If it is going to get rid of the conflicting path name, ln attempts to do so in the same way that rm does. ln deletes the file associated with the path name if this path name is the last link to the file. If ln can't get rid of the conflicting path name, it does not attempt to establish the new link; it simply prints an error message on the standard error and goes on to process any other files.
- If ln successfully removes the conflicting path name, it then establishes the link.
Options
-f -
removes conflicting path names without asking for confirmation.
-i -
checks with you before getting rid of conflicting path names. (Note that the
-f option overrides the-i option.) -q -
suppresses warning messages. Error messages are still displayed.
-R -
links files recursively; that is, you can link an entire hierarchy of subdirectories at once.
-r -
is identical to
-R . -s -
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 8.1/2012R2/10/2016/2019/11/2022, 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.
- Note:
-
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.
- Note:
-
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.
-v -
shows file names as they are processed.
ENVIRONMENT VARIABLES
- TK_UNIX_FILESYSTEM
-
When this variable is set, the Enhanced UNIX Compatibility Mode is on and the virtual file system is in use.
On Windows Windows 8.1/2012R2/10/2016/2019/11/2022, 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 8.1/2012R2/10/2016/2019/11/2022, 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.
DIAGNOSTICS
Possible exit status values are:
- 0
-
All requested links were established successfully.
- 1
-
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
- 2
-
Failure due to any of the following:
PORTABILITY
POSIX.2. x/OPEN Portability Guide 4.0. All UNIX systems. Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022.
Only the
AVAILABILITY
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 Windchill Requirements and Validation
SEE ALSO
PTC MKS Toolkit 10.4 Documentation Build 39.