+1 vote
in Operating Systems by (56.8k points)
I am using Debian 12 on my machine. Suddenly the disk usage increased on my system. I want to know which files and folders are very large. Is there any command that I can use?

1 Answer

+2 votes
by (351k points)
selected by
 
Best answer

To find out which files and folders are taking up the most space on your Ubuntu or Debian system, you can use the du command in combination with the sort and head commands.
Open the terminal and type in the following command:

# du -ah / | sort -rh | head -n 10

  • du -ah /: This command will calculate the disk usage of each file and directory in the root directory (/). The "-h" option will display the sizes in human-readable formats, such as kilobytes, megabytes, and gigabytes. The "-a" option includes all files and directories.
  • sort -rh: This command will sort the output in reverse numerical order so the largest files appear at the top.
  • head -n 10: This command will display only the top 10 largest files and directories.


Here is the result of the execution of the above command on my system:

4.6G    /
2.5G    /usr
1.6G    /var
1.4G    /usr/lib
986M    /var/lib
788M    /usr/lib/modules
549M    /usr/share
457M    /var/lib/mysql
394M    /usr/lib/modules/6.1.0-18-amd64
394M    /usr/lib/modules/6.1.0-17-amd64
 


...