0%

检查Linux 磁盘空间

How to check disk space

Start by tracking down where the excess usage is being stored. If you have no idea, start from the mountpoint for /dev/sda1:

1
mount | grep sda1

Use the du command. If /dev/sda1 is mounted on / (“root”):

1
du --max-depth=1 --human-readable / | sort --human-numeric-sort

This will list the first level of directories contained in the specified path, in order from smallest to largest. You can increase the depth past 1 to get details of the subdirectories, or change the path to specify a single directory. You can also use the short flags.

For instance, if your username is ubuntu and you want to inspect your home directory:

1
du -d1 -h /home/ubuntu | sort -h