57

I was wondering how do you know where the largest files in my system are stored.

For example---

Disk Space Used: 1GB Java: 500MB Java Percentage: 50% maybe represented in a pie chart. Maybe?

I know this maybe a feature overkill. I sometimes forget having stored things and wonder why my disk is so full.

So basically a command that will allow me to run on the file system and provide me with information on disk space used.

Please and thank you.

txwikinger
  • 29,406
myusuf3
  • 35,659

8 Answers8

60

The Disk Usage Analyzer is available under Ubuntu > Accessories > Disk Usage Analyzer. It provides you with a snazzy pie graph showing what files and folders take up the most space:

enter image description here

The documentation on it is a little sparse, but you can find more information on the Ubuntu wiki, and the project page.

If you're interested in using the command line, there's du which is described here.

Erigami
  • 4,536
33

Unless it changed recently, baobab only shows directories; check out kdirstat for an alternative that actually shows files, coloured by type.

A commandline alternative is

du -a | sort -nr | head
UncleZeiv
  • 511
28

The solution that @UncleZeiv proposed is not working when there is really no more space left, since sort is using the /tmp folder when there are multiple lines to sort.

du -a | sort -nr | head
sort: write failed: /tmp/sortuCYq8E: No space left on device

An alternative is a combination of the answer from @UncleZeiv and @Yoav Weiss, plus adding another path for the temporary location:

sudo du -a | sort -nr -T /media/usb-key

Finally, my preferred solution will be a human-readable one that doesn't depend on temp folder and list root directory (/):

sudo du -ah --max-depth=1  / | sort -hr
cmaher
  • 103
10

A useful command to that helps in cases you need to determine that for specific directories from the command line:

du --max-depth=1 -x -h

It gives you a list of the first depth directories and their sizes

-x limits the analysis to one file system

-h shows human readable k/M/Gbytes (this prevents you from sorting the output though)

wjandrea
  • 14,504
3

The other excellent pie-graph disk usage tool is Filelight. It's a KDE app, and it's available in the repositories.

2

Use the Disk Usage Analyser (Applications -> Accessories -> Disk Usage Analyser):

(The command is baobab).

Click Analyser -> Scan Filesystem

dv3500ea
  • 37,734
0

For console/command line (as OP asked) I recommend ncdu (NCurses Disk Usage), available with

sudo apt install ncdu

in Debian compatible distros. When used this way, as an example:

ncdu /var/lib

shows in text mode the main culprits of space usage consumption under /var/lib and allows to navigate easily under its files/directories using arrow and Enter keys. It has a simple online help screen shown when pressing the key ?; press q key to exit.

You can also restrict the analysis to a single device/partition/volume using the -x command-line option like this:

ncdu -xq /

Here ncdu doesn't go into mounted filesystems under the indicated root directory. The -q option increases the updating screen time, so it can be slightly faster.

As always, man ncdu is your friend.

ncdu is mentioned in this answer.

Fjor
  • 314
  • 2
  • 10
0

Another tool for this is jDiskReport (a Java app)

AndrewR
  • 791