硬鏈接(英語:hard link)是計算機文件系統中的多個文件平等地共享同一個文件存儲單元(如MFT條目inode)。硬鏈接必須在同一個文件系統中;一般用戶權限下的硬鏈接只能用於文件,不能用於目錄,因為其父目錄就有歧義了。刪除一個文件名字後,還可以用其它名字繼續訪問該文件。硬鏈接只能用於同一個文件系統(對於NTFS是限制於同一個分區)。不能用於不存在的文件。[1]

Thumb
硬鏈接概念圖示

POSIX兼容的操作系統,文件或目錄的硬鏈接的引用計數可以用stat()英語stat (system call)或fstat()系統調用返回的struct stat中的st_nlink字段。

NTFS的硬鏈接

Windows NT 3.1及後續版本支持NTFS硬鏈接。[2] Windows 2000引入了CreateHardLink()函數以創建硬鏈接,但僅能用於文件,不能用於目錄。[3]DeleteFile()函數可刪除硬鏈接。

Windows終端用戶創建硬鏈接的方法:

終端用戶查看文件的硬鏈接的方法:

  • fsutil 工具[4]
  • Get-ItemGet-ChildItem,PowerShell命令[7]

WinSxS使用硬鏈接跟蹤硬盤上部件的不同版本。

類Unix系統的硬鏈接

用戶創建硬鏈接的方法:

終端用戶查看文件的硬鏈接:

  • stat方法
  • ls -l方法
  • Get-ItemGet-ChildItem,PowerShell命令[7]

參見

參考文獻

Wikiwand in your browser!

Seamless Wikipedia browsing. On steroids.

Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.

Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.