【Linuxコマンド】 ls コマンド オプション 一覧 【初学者必見】
まとめ
Linuxコマンド一覧
ls コマンドとは
ファイルやディレクトリの情報を表示するためのコマンドです。
"ls" は "list directory contents"の略です。
lsコマンドの使い方
/home/hoge
$ ls
test hoge.txt test2
lsコマンドのオプション一覧
| オプション | 説明 |
|---|---|
| -a | 全て表示 |
| -l | 詳細表示 |
| -1 | リストを縦に並べる |
| -r | 逆順表示 |
| -t | 更新時間順に表示 |
| -S | ファイルサイズ順でソートする |
| -X | 拡張子順(ごと)に並べる |
| -R | ディレクトリ内容を再帰的に表示 |
| --full-time | タイムスタンプの詳細を表示する |
| -h | 単位を読みやすい形式で表示する |
| -k | KB単位で表示する |
| -F | ディレクトリ名の後に ' / ', 実行可能なファイル名の後に ' * ' をつける |
-aオプション
ファイル名の先頭にピリオドがつく隠しファイルも表示。
/home/hoge
$ ls -a
test hoge.txt test2 .hidden
-lオプション
ファイルの詳細を表示。
/home/hoge
$ ls -l
-rw-r--r-- 1 root root 11 Feb 24 17:11 hoge.txt
drwxr-xr-x 2 root root 4096 Feb 24 17:14 test
drwxr-xr-x 2 root root 4096 Feb 24 17:15 test2
詳細の見方ですが、一行目で説明すると
| 項目 | 説明 |
|---|---|
| -rw-r--r-- | ファイルの種類(左1文字)+パーミッション |
| 1 | ハードリンクの数 |
| root | 所有者 |
| root | 所有グループ |
| 11 | ファイルのサイズ |
| Feb 24 17:11 | 作成日時 |
| hoge.txt | ファイル名 |
-Rオプション
ディレクトリ内容を再帰的に表示。
/home/hoge
$ ls -R
hoge.txt test test2
./test
test.txt ex.txt test.log
./test2
test2.txt ex2.txt test2.log
-hオプション
ファイルサイズの単位をいい感じによろしくやってくれます。
/home/hoge
$ ls -lh
-rw-r--r-- 1 root root 11B Feb 24 17:11 hoge.txt
drwxr-xr-x 2 root root 4.0K Feb 24 17:14 test
drwxr-xr-x 2 root root 4.0K Feb 24 17:15 test2
その他のLinuxコマンドのオプション一覧
pwd, mkdir, cd, cat, cp, ls, touch, less, mv, rm, ssh, man, 随時追加中
広告欄
各種開発や構築の請負や初学者向けのメンター業務してます。
ご興味お持ちいただけた方は**こちら**へどうぞ