disk space

Scala code to find (and move or remove) duplicate files

My MacBook recently told me I was running out of disk space. I knew that the way I was backing up my iPhone was resulting in me having multiple copies of photos and videos, so I finally decided to fix that problem by getting rid of all of the duplicate copies of those files.

So I wrote a little Scala program to find all the duplicates and move them to another location, where I could check them before deleting them. The short story is that I started with over 28,000 photos and videos, and the code shown below helped me find nearly 5,000 duplicate photos and videos under my ~/Pictures directory that were taking up over 18GB of storage space. (Put another way, deleting those files saved me 18GB of storage.)

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.