0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Linux] ハードリンクとシンボリックリンク_コマンド_ln

Last updated at Posted at 2025-02-03

ハードリンクとシンボリックリンクの違い

項目 ハードリンク シンボリックリンク
指し示す対象 元のファイルのデータブロック 元のファイルのパス
元ファイル削除時の影響 データは残る リンクは残るが無効
異なるファイルシステム間で作成可能か 不可
ディレクトリへの適用 不可
作成方法 ln <元ファイル> <リンク名> ln -s <元ファイル> <リンク名>
ファイルのinode番号 同じ 異なる
ls コマンドでの表示 同じ inode 番号を持つ パーミッションの先頭に「l」が表示

lnコマンド

ln
$ ln [オプション] リンク元(実体) リンクファイル
オプション 由来 説明
default link ハードリンクの作成
-s symbolic link シンボリックリンクの作成

ハードリンクの例

sh
$ echo "Hello" > original.txt
$ ln original.txt hardlink.txt
$ ls -li
123456 -rw-r--r-- 2 user user 6 Feb 2 12:00 original.txt  
123456 -rw-r--r-- 2 user user 6 Feb 2 12:00 hardlink.txt  

シンボリックリンクの例

sh
$ ln -s original.txt symlink.txt
$ ls -li
123456 -rw-r--r-- 1 user user 6 Feb 2 12:00 original.txt  
654321 lrwxrwxrwx 1 user user 12 Feb 2 12:01 symlink.txt -> original.txt  

Ping-t

全般

ハードリンク

シンボリックリンク

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?