My hard disk is full - how can I determine what's taking up space?
du -h -d 1 /
This will display the size for all of the top-level directories in your root directory in 'human readable' format. You can also just do
du -h -d 1 / | grep '[0-9]\+G'
to only see the ones taking a couple GB or more.
For a more granular level of detail, do something like
ls -R -shl / | grep '^[0-9.]\{4,12\}\+[KG]'
which will show all files in and below your root directory that are 1G or over in size.
** note that you might need to prepend sudo
to the commands above.
edit -- just saw you want them sorted by newest or largest
Try this
du -h -d 1 / | grep '[0-9]\+G' | sort -h
Instead of all the manual commands in the other answers, I recommend a tool specifically built for this purpose: ncdu
, install with the package manager of your choice.
It only is a small command line utility, so you should be able to install, when you just make a little bit space.
Then, just run
$ ncdu /
to analyze the entire system.
See https://dev.yorhel.nl/ncdu/scr for screenshots:
My favorite command for this purpose is
du | sort -nr | head -20
du
without options lists all subdirectories and their sizes.
sort
sorts by size. n
asks for a numerical sort. r
reverses the result to largest first.
head -20
limits the output to 20 lines.
By listing directories instead of files, you will find directories that contains a large number of small files.
For sort
to work properly we can't use human-readable output, but the largest is the largest even if you can't quite parse its size.
The output for a directory will include its subdirectories, so you will see .cache
listed before .cache/chromium
(or whatever)