2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

どのディレクトリが容量を食っているかを調査するためのコマンド

Last updated at Posted at 2024-06-01

ディスクの容量を表示するコマンド。-hオプションをうけることでいい感じの単位にしてくれる。

df -h

ディスク使用量が分かってもどのファイルが容量を食っているか分からない。
そこで、ディレクトリことのディスク使用量を調べるコマンドを使う。同じく-hオプションをつけることでいい感じの単位にしてくれる。

du -h

さらに、直下のディレクトリの容量を調べてソートするコマンドを使うと便利。

sudo du -h --max-depth=1 <ディレクトリパス> | sort -rh

例)ルートディレクトリ直下にあるディレクトリの容量を調べる

xxx@xxx:~$ sudo du -h --max-depth=1 / | sort -rh
41G     /
26G     /var
7.7G    /large
3.7G    /usr
968M    /snap
843M    /home
299M    /boot
143M    /opt
7.2M    /etc
2.2M    /run
392K    /root
100K    /tmp
16K     /lost+found
4.0K    /srv
4.0K    /mnt
4.0K    /media
4.0K    /fast
0       /sys
0       /proc
0       /dev
2
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?