Monitoring disk usage in Linux

2016-10-20

When one of your directories is approaching the quota limit, it is reasonable to check which files or folders take up most space. To list the files in your current directory ordered by size, give command:
ls -lSrh

Note however, that this command does not tell how much disk space the files in the subdirectories use. Thus it is often more useful to use the command du (disk usage) instead. You can, for example, try command:

du -sh ./*
This command returns the size of each file or the total disk usage of each subdirectory in your current directory. You can also combine du with sort to see what file or directory is the largest item in your current directory:
du -s ./* | sort -n
Note that as the du command checks all the files in your current directory and running the command may in some cases take several minutes.

本网站由阿里云提供云计算及安全服务