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】シンボリックリンク(Symbolic Link)入門

Posted at

シンボリックリンクの基本トピック

シンボリックリンクの概要

シンボリックリンク(Symbolic Link)はディレクトリやファイルまでのパスを含んだファイルのことを指します。シンボリックリンクを作成することで、カレントディレクトリから遠いファイルへのアクセスもスムーズに行うことが可能になります。

シンボリックリンクの貼り方

.
├── other files
└── test
    └── sample

CLI(コマンドライン)で$tree$を実行した際に上記のようなディレクトリ構成が得られるとします。この際にシンボリックリンクを用いることで、test/sampleディレクトリをsampleだけで指定が可能になります。

$ ln -s test/sample sample

たとえば上記のようにlnコマンドを実行することで、sampleを指定するだけでtest/sampleを取り扱うことが可能です。lnコマンドが正常に動作した場合treeを実行すると下記のような結果が得られます。

.
├── other files
├── sample -> test/sample
└── test
    └── sample

上記のsample -> test/sampleが作成したシンボリックリンク(symbolic link)に対応します。このシンボリックリンクの動作確認にあたっては、たとえば下記のようなコマンドを実行すると良いです。

$ echo xxx > sample/test.txt
$ tree

・実行結果

.
├── other files
├── sample -> test/sample
└── test
    └── sample
        └── test.txt
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?