Mike Slinn
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 blog post 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