Mike Slinn

Working With Volumes and Directories Under Ubuntu

Published 2022-12-01.
Time to read: 1 minutes.

This page is part of the posts collection, categorized under Ubuntu.

I've been reorganizing directories across several volumes on an Ubuntu server. This article documents how I used the commands I found to be most useful: rsync, ncdu, and fdupes. The latter two programs are not installed by default. You can install them this way:

Shell
$ yes | sudo apt install fdupes ncdu

Display Directory Sizes

Shell
$ ncdu /directory

Find Duplicate Files

This displays duplicate files and interactively asks which duplicate files to delete.

Shell
$ fdupes -r1Sd /directory

Compare Two Folders For Missing Files

This tip was inspired by an answer on unix.stackexchange.com.

Dry Run

The -n option displays the names of missing files in the destination directory, but makes no changes to the destination file system. If that option is not specified, then the missing files are copied.

Shell
$ sync -ri --ignore-existing -n /srcDir/ /destDir

There are a few things to note:

  • The first directory is the source, and it must end with a slash (/).
  • The second directory is the target, and it must NOT end with a slash.

Copy Missing Files

Simply do not provide the -n (dry run) option:

Shell
$ rsync -ri --ignore-existing /srcDir/ /destDir


* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.