disk usage

How to show the largest files under a directory on Mac OS X (Unix) alvin December 23, 2017 - 1:00pm

Here’s an example that shows how to find the largest files under a directory on MacOS and Linux/Unix systems.

A du/sort command to show the largest files under a directory on Mac OS X

The Unix/Linux command that worked for me on my MacOS system is this:

$ du -a * | sort -r -n | head -10

du is the disk usage command, and the -a flag says, “Display an entry for each file in a file hierarchy.” Then I use the sort command to sort the du output numerically and in reverse. After that, head -10 shows only the first ten lines of output. In the Music folder on my Mac the command and output look like this:

How do I show Linux disk space information?

Linux FAQ: How do I show Linux disk space information? (Also stated as, "What is the Linux disk space command?")

Answer: You show Linux disk space information with the Linux df command. I have a more detailed Linux df command example, but in short, I typically use the Linux df command like this, with the -h option:

df -h

The -h option stands for "human readable", and I almost always use that option instead of using the df command by itself.

Linux df command man page

This page shows the contents of the Linux df comamnd man page. This df command output was created on a CentOS Linux system.

You can see this same df command man page output by entering this command on your own Linux system:

Use the Linux df command to show free disk space

Linux free disk space FAQ: How do I show free disk space on a Unix or Linux system?

The Linux df command stands for "disk free". It is meant to show Linux disk space information, including disk space that is used, disk space remaining, and how filesystems are mounted on your Linux (or Unix) system. The Linux df command not only shows the free disk space on your local computer, it also shows the free disk space on all networked filesystems that are mounted by your Linux system.

Linux ‘du’ (disk usage) command examples

Linux disk usage FAQ: How do I show disk usage information on a Unix or Linux system, such as how large a directory is?

The Unix and Linux du command shows information about "disk usage". Whereas the df command ("disk free") shows information about Linux filesystems, the du command shows disk usage information about only the files and directories you specify.