du
ファイルとディレクトリ
書き方
du -sh [path]ファイルが実際に占めるディスク容量を足します。割り当てブロックで数えるので、ファイルサイズの合計や df の値とはずれます。
よく使うオプション
| オプション | 意味 |
|---|---|
| -s | One total per argument instead of every subdirectory |
| -h | Readable sizes such as 1.2G |
| -a | Include files, not only directories |
| -d | Limit the depth; GNU also spells it --max-depth |
| -x | Stay on one filesystem |
| -c | Print a grand total at the end |
例
du -sh *Size of every item in this directory.
du -h -d 1 / | sort -hTop-level directories, smallest to biggest.
du -shx /varSize of /var without crossing into other mounts.
移したり消したり探したりするものです。聞き返してくれない命令が混ざっているので、-i を付ける癖が手を守ります。
読み方
- 角括弧 [ ] は省いてよい部分です。
- 三点 … は複数並べられるという意味です。
- オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。
よくある質問
Q. du は何をしますか。
ファイルが実際に占めるディスク容量を足します。割り当てブロックで数えるので、ファイルサイズの合計や df の値とはずれます。
Q. どう打ちますか。
du -sh [path] — 角括弧は省いてよい部分です。
Q. よく使うオプションはいくつですか。
ここにまとめたのは6個です。全部は man du にあります。このコマンドはファイルとディレクトリの仲間です。
関連するコマンド
man ページ: man du