Quick Tip: Using du

11 June, 2024

Need to find out how much disk space that the files and directories on your computer use? While you can turn to graphical tools like GNOME Disk Usage Analyzer to do that, there’s also a lighter weight option: running the du command in a terminal window.

Short for disk usage, du shows you how much space your files and directories take up. It’s a useful tool for managing storage and identifying space-consuming files.

Here’s a quick look at the basics of using du.

Let’s start by getting the disk usage of a specific file or directory. To do that, run this command:

du [file/directory]

For example, to check the disk usage of the Documents folder, type this at the command line:

du Documents

The command displays the disk usage in kilobytes (KB) for each file and subdirectory within the Documents folder.

du also has several options. For example, to display the sizes in a format that you can easily read — like KB, MB, GB — use the -h option like this:

du -h Documents

You can also sort the output of the command to see the largest files or directories first by combining the -h and -s options like this:

du -sh *

Scott Nesbitt