lnコマンド

UNIXサーバ構築 OnTheVMware

unixコマンドについて使用例を用いて解説
HOME > 基本操作コマンド >

lnコマンド

lnコマンド


スポンサードリンク


【説明】
ファイルへのリンクを作成する際に使用します。

コマンドはファイルへのリンクを作成する。特に指定がないとハードリンクを作成 する。 -s オプションを指定するとシンボリック リンクを作成する。 Unix には通常ハードリンクとソフトリンクと呼ばれる、 2 つの「リンク」の概念がある。ハードリンクは単にファイルの名前である。 (ファイルは複数の名前を持つことができる。その最後の名前が削除された場合にのみディスク上から実体が消去される。シンボリックリンクというのはまったく違った種類のものである: 実体はパス名を含んだ小さくて特殊なファイルである。従って、異なるファイルシステム上 (たぶん他のマシンからマウントされた NFS) のファイルを指すことができる。

【構文】
ln [オプション] [ターゲット] [リンク名]

例 test.txtファイルのハードリンクを作成する。
[root@localhost test]# ls -l
合計 4
-rw-r--r-- 1 root root 27 6月 18 08:56 test.txt
[root@localhost test]# ln test.txt test1
[root@localhost test]# ls -l
合計 8
-rw-r--r-- 2 root root 27 6月 18 08:56 test.txt
-rw-r--r-- 2 root root 27 6月 18 08:56 test1


例 test.txtファイルのシンボリックリンクを作成する。
[root@localhost test]# ls -l
合計 8
-rw-r--r-- 2 root root 27 6月 18 08:56 test.txt
-rw-r--r-- 2 root root 27 6月 18 08:56 test1
[root@localhost test]# ln -s test.txt test2
[root@localhost test]# ls -l
合計 8
-rw-r--r-- 2 root root 27 6月 18 08:56 test.txt
-rw-r--r-- 2 root root 27 6月 18 08:56 test1
lrwxrwxrwx 1 root root 8 6月 18 09:23 test2 -> test.txt

スポンサードリンク
 HOME / 免責事項 / サイトマップ /  問い合わせ
Copyright (C) 2008  UNIXサーバ構築 OnTheVMware  All rights reserved





スポンサードリンク