Loose-Info.com
Last Update 2014/03/11
TOP - Unix系OS - Linux - mkdir(1)

ディレクトリを作成します。

mkdir オプション1 ディレクトリ ... オプション1(任意) -m 値1 作成するディレクトリのパーミッションを値1で指定する。8進数もしくはシンボルにて指定。 -p 途中のディレクトリ等、必要な場合にディレクトリを作成する -v ディレクトリを作成する度に内容を表示する ディレクトリ(必須) 作成するディレクトリ

※ オプションなどは個人的に重要と考えられるものを記述しており、記載の無いものは、manページや関連書籍などを参照願います。
※ 実行例の記述は、不要と考えられる部分の削除などの修正を行ったものを掲載しています。
※ 実行例の実行環境はUbuntu 12.10です。

(例) オプション無し
$ mkdir testdir

実行前
$ ls -l total 0

実行後
$ ls -l total 4 drwxr-xr-x 2 ******* ******* 4096 Dec 25 19:25 testdir

(例) -m オプション 8進数指定
$ mkdir -m 0444 testdir

実行前
$ ls -l total 0

実行後
$ ls -l total 4 dr--r--r-- 2 ******* ******* 4096 Dec 25 19:35 testdir ← 読み取りのみで作成

(例) -m オプション シンボル指定(1)
$ mkdir -m ugo=r testdir

実行前
$ ls -l total 0

実行後
$ ls -l total 4 dr--r--r-- 2 ******* ******* 4096 Dec 25 19:41 testdir

(例) -m オプション シンボル指定(2)
$ mkdir -m ugo-wx testdir

実行前
$ ls -l total 0

実行後
$ ls -l total 4 dr--r--r-- 2 ******* ******* 4096 Dec 25 19:42 testdir

(例) -p オプション
$ mkdir -p testdir1/testdir2/testdir3

実行前
$ ls -l total 0

実行後
$ ls -Rl .: total 4 drwxr-xr-x 3 ******* ******* 4096 Dec 25 20:07 testdir1 ./testdir1: total 4 drwxr-xr-x 3 ******* ******* 4096 Dec 25 20:07 testdir2 ./testdir1/testdir2: total 4 drwxr-xr-x 2 ******* ******* 4096 Dec 25 20:07 testdir3 ./testdir1/testdir2/testdir3: total 0

(例) -v オプション
$ mkdir -pv testdir1/testdir2/testdir3

表示メッセージ
$ mkdir -pv testdir1/testdir2/testdir3 mkdir: created directory `testdir1' mkdir: created directory `testdir1/testdir2' mkdir: created directory `testdir1/testdir2/testdir3'