Hard link
In computing, a hard link is a directory entry (in a directory-based file system) that associates a name with a file.[src] Thus, each file must have at least one hard link.[src] Creating additional hard links for a file makes the contents of that file accessible via additional paths (i.e., via different names or in different directories).[src] This causes an alias effect: a process can open the file by any one of its paths and change its content.[src] By contrast, a soft link or “shortcut” to a file is not a direct link to the data itself, but rather a reference to a hard link or another soft link.[src] Every directory is itself a special file on many systems, containing a list of file names instead of other data.[src] Hence, multiple hard links to directories are possible, which could create a circular directory structure, rather than a branching structure like a tree.[src] For that reason, some file systems forbid the creation of additional hard links to directories.[src] POSIX-compliant operating systems, such as Linux, Android, macOS, and the non-POSIX-compliant Windows NT family, support multiple hard links to the same file, depending on the file system.[src] For instance, NTFS and ReFS support hard links, while FAT does not.[src]
In computing, a hard link is a directory entry (in a directory-based file system) that associates a name with a file.[src] Thus, each file must have at least one hard link.[src] Creating additional hard links for a file makes the contents of that file accessible via additional paths (i.e., via different names or in different directories).[src] This causes an alias effect: a process can open the file by any one of its paths and change its content.[src] By contrast, a soft link or “shortcut” to a file is not a direct link to the data itself, but rather a reference to a hard link or another soft link.[src] Every directory is itself a special file on many systems, containing a list of file names instead of other data.[src] Hence, multiple hard links to directories are possible, which could create a circular directory structure, rather than a branching structure like a tree.[src] For that reason, some file systems forbid the creation of additional hard links to directories.[src] POSIX-compliant operating systems, such as Linux, Android, macOS, and the non-POSIX-compliant Windows NT family, support multiple hard links to the same file, depending on the file system.[src] For instance, NTFS and ReFS support hard links, while FAT does not.[src] ==Operation== Let two hard links, named "LINK A.TXT" and "LINK B.TXT", point to the same physical data.[src] A text editor opens "LINK A.TXT", modifies it and saves it.[src] When the editor (or any other app) opens "LINK B.TXT", it can see those changes made to "LINK A.TXT", since both file names point to the same data.[src] So from a user's point of view this is one file with several filenames.[src] Editing any filename modifies "all" files, however deleting "any" filename except the last one keeps the file around.[src] However, some editors, such as GNU Emacs, break the hard link concept.[src] When opening a file for editing, e.g., "LINK B.TXT", emacs renames "LINK B.TXT" to "LINK B.TXT~", loads "LINK B.TXT~" into the editor, and saves the modified contents to a newly created "LINK B.TXT".[src] Now, "LINK A.TXT" and "LINK B.TXT" no longer share the same data.[src] (This behavior can be changed using the emacs variable backup-by-copying .) Any number of hard links to the physical data may be created.[src] To access the data, a user only needs to specify the name of any existing link; the operating system will resolve the location of the actual data.[src] Even if the user deletes one of the hard links, the data is still accessible through any other link that remains.[src] Once the user deletes all of the links, if no process has the file open, the operating system frees the disk space that the file once occupied.[src] ==Platform support== Windows NT 3.1 and later support hard links on the NTFS file system.[src] Windows 2000 introduces a CreateHardLink() function to create hard links, but only for files, not directories.[src] The DeleteFile() function can remove them.[src] To create a hard link on Windows, end-users can use: The fsutil utility (introduced in Windows 2000) The mklink internal command of Windows Command Prompt (introduced in Windows Vista and Windows Server 2008) The New-Item cmdlet of PowerShell To interrogate a file for its hard links, end-users can use: The fsutil utility The Get-Item and Get-ChildItem cmdlets of PowerShell.[src] These cmdlets represent each file with an object; PowerShell adds a read-only LinkType property to each of them.[src] This property contains the string if the associated file has multiple hard links.[src] The Windows Component Store uses hard links to keep track of different versions of components stored on the hard disk drive.[src] On Unix-like systems, the system call can create additional hard links to existing files.[src] To create hard links, end-users can use: The ln utility The link utility The New-Item cmdlet of PowerShell To interrogate a file for its hard links, end-users can use: The stat command The ls -l command The Get-Item and Get-ChildItem cmdlets of PowerShell (see above) Unix-like emulation or compatibility software running on Microsoft Windows, such as Cygwin and Subsystem for UNIX-based Applications, allow the use of POSIX interfaces.[src] OpenVMS supports hard links on the ODS-5 file system.[src] Unlike Unix, VMS can create hard links to directories.[src] ==See also== Symbolic link: Points to a hard link, not the file data itself; hence, it works across volumes and file systems.[src] NTFS links: Details the four link types that the NTFS supports—hard links, symbolic links, junction points, and volume mount points Shortcut: A small file that points to another in a local or remote location Alias: macOS implementation of a shortcut Shadow: OS/2 implementation of a shortcut freedup: The freedup command frees-up disk space by replacing duplicate data stores with automatically generated hard links rsync: supports --link-dest=DIR so that a new backup folder will use hardlinks of the previous backup if not changed as a space and time saving feature (incremental backup)[src]
45 sentences · 45 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Hard link." encyclopegia.org, 2026, https://encyclopegia.org/wiki/hard-link. Accessed 28 November 2026.
Chicago
"Hard link." encyclopegia.org. Accessed November 28, 2026. https://encyclopegia.org/wiki/hard-link.
APA
encyclopegia.org. (2026). Hard link. Retrieved November 28, 2026, from https://encyclopegia.org/wiki/hard-link
Accessed November 28, 2026 · CC BY-SA 4.0 · citation page · JSON