LoginSignup
1
1

More than 5 years have passed since last update.

duコマンドについて

Posted at

今まで du コマンドの出力が理解できていなかった。
適当に検索すると以下のような説明が散見できる。

ディレクトリ内のファイル容量を表示する

間違っていないのかもしれないが、このおかげで長らく使い方が分からなかった。
なぜなら単純に du コマンドを叩くとよくわからない数値が出てくる。

[root@host test]# ls -al
合計 12
drwxrwxr-x.  2 root root 4096 11月  1 23:55 2015 .
drwx------. 11 root root 4096 11月  1 23:54 2015 ..
-rw-rw-r--.  1 root root    2 11月  1 23:55 2015 file
[root@host test]# du
8       .
[root@host test]#

この 8 は、4096byte のブロックを 2 つ占有しているということだそうだ。
4098 (byte)とかが出て来るという先入観があった。

ちなみにブロックを無視して 4098byte を出力させるには -b オプションを使用する。

[root@host test]# du -b
4098    .
[root@host test]#
1
1
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
1
1