{
  "slug": "unlink",
  "term": "Unlink",
  "aliases": [
    "unlink()"
  ],
  "definition": "Unlink is the removal of a directory entry naming a file; POSIX semantics preserve existing open references, while network-filesystem behavior requires additional qualification.",
  "note": "Linux unlink() removes a name; if that was the last hard link, existing open references can keep the file usable after its pathname disappears. Reclamation depends on releasing the remaining references, not merely removing one pathname. A symbolic-link argument removes the symbolic link itself, not its target. Plain unlink() does not remove directories; unlinkat() with AT_REMOVEDIR requests directory removal instead. Namespace removal is not secure erasure or proof of crash-persistent deletion. On ext4, orphan recovery completes pending reclamation after a crash; it does not establish whether an application's namespace change was durably synchronized. [linux-v6-12-ext4-orphan] [linux-fsync-2] Removing and recreating a coordination-file name can let participants lock different files; a persistent name is part of the locking protocol, not disposable cleanup. [hesela-locks] NFS requires a separate scope check: the Linux unlink manual documents active silly-renamed files as a possible EBUSY cause and warns about loss of access to files still in use. [linux-unlink-2] See the NFS records for conditional server preservation. [hesela-unlink]",
  "advantages": [
    "Allows a name to be removed without interrupting existing users of the open file."
  ],
  "limitations": [
    "Other hard links and open references can preserve the file after the name is removed.",
    "Does not promise physical erasure or persistent deletion after a crash.",
    "Do not assume all NFS clients and servers preserve every remote open reference when a name is removed."
  ],
  "related": [
    "inode",
    "hard-link",
    "atomic-rename",
    "open-file-description",
    "directory-fsync",
    "ext4-orphan-inode",
    "ext4-orphan-file",
    "advisory-file-lock",
    "nfs-silly-rename",
    "nfs-preserve-unlinked",
    "whiteout",
    "link-count",
    "sticky-bit"
  ],
  "status": "shipping",
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-15",
  "citations": [
    {
      "id": "linux-unlink-2",
      "title": "Linux man-pages 6.19: unlink(2)",
      "url": "https://man7.org/linux/man-pages/man2/unlink.2.html",
      "accessed": "2026-10-15"
    },
    {
      "id": "linux-open-2",
      "title": "Linux man-pages 6.19: open(2)",
      "url": "https://man7.org/linux/man-pages/man2/open.2.html",
      "accessed": "2026-10-15"
    },
    {
      "id": "linux-fsync-2",
      "title": "Linux man-pages 6.19: fsync(2)",
      "url": "https://man7.org/linux/man-pages/man2/fsync.2.html",
      "accessed": "2026-10-15"
    },
    {
      "id": "hesela-namespace",
      "title": "Hesela: The name changes; existing readers do not",
      "url": "https://hesela.com/analyses/atomic-rename-directory-durability/#namespace-identity",
      "accessed": "2026-10-15"
    },
    {
      "id": "linux-v6-12-ext4-orphan",
      "title": "Linux v6.12: ext4 orphan inode handling",
      "url": "https://github.com/torvalds/linux/blob/adc218676eef25575469234709c2d87185ca223a/fs/ext4/orphan.c",
      "accessed": "2026-10-15"
    },
    {
      "id": "hesela-locks",
      "title": "Hesela: A lock follows the opened file, not the replacement name",
      "url": "https://hesela.com/analyses/atomic-rename-directory-durability/#lock-identity",
      "accessed": "2026-10-16"
    },
    {
      "id": "hesela-unlink",
      "title": "Why deleted NFS files become .nfs files",
      "url": "https://hesela.com/analyses/nfs-silly-rename-open-unlink/",
      "accessed": "2026-10-16"
    }
  ]
}
