How to use the command 'duc' (with examples)

How to use the command 'duc' (with examples)

The ‘duc’ command is a collection of tools for indexing, inspecting, and visualizing disk usage. It helps maintain a database of accumulated sizes of directories in the file system, allowing users to query this database and create graphical representations of disk usage. This article provides examples of various use cases for the ‘duc’ command.

Use case 1: Indexing a directory

Code:

duc index /usr

Motivation: This use case allows the user to index the ‘/usr’ directory, writing the index to the default database location at ‘~/.duc.db’.

Explanation:

  • index: Specifies the operation to index a directory.
  • /usr: The directory to be indexed.

Example output:

Indexed: 17742 files, 220078013 bytes, 292710456 blocks

Use case 2: Listing files and directories with relative file sizes

Code:

duc ls --classify --graph /usr/local

Motivation: This use case lists all files and directories under the ‘/usr/local’ directory and displays their relative file sizes in a graph, allowing for easy visualization of disk usage.

Explanation:

  • ls: Specifies the operation to list files and directories.
  • --classify: Adds classification symbols to the output.
  • --graph: Displays the output as a graph.
  • /usr/local: The directory to be listed.

Example output:

  ⠀
  ⠀ ⠀⠀⠀⠀⢀⣠⠤⠤⠴⠒⠒⠒⠒⠒⠒⠒⠒⠒⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠒⠤⠄
  ⠀⠀⠀⠀⠀⠈⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉
  ⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⠉⠉⠉⠉⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  ⠀⠀⠀⠀⠀⠀⣿⡿⡿⡿⡿⣿⣷⣤⡀⡠⢤⣤⣀⡀⠀⠀⣀⣀⣀⣠⣼⡿⡍⠀⠈⢷⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀
  ⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⠀⠀⢻⣿⡿⠟⠀⠈⠉⠉⠉⠛⠛⠛⠉⠁⠀⠀⣸⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀
  ⠀⠀⠀⠀⠀⠀⣿⡿⡿⡿⡿⣿⣏⠙⢻⡿⡕⠀⠀⣀⡀⠀⠀⠤⠴⠏⠀⠀⠀⠀⢿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀
  ⠀⣀⣀ ⠀⠀⠀⠉⠉⠻⠿⠿⠿⠓⠀⠀⠀⠀⠀⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀
  ⣿⡿⣿⡏ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  ⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
  ⠉⠉⠉⠁
Size: 4.3 GB

Use case 3: Listing files and directories in tree view recursively

Code:

duc ls --classify --graph --recursive /usr/local

Motivation: This use case lists all files and directories under the ‘/usr/local’ directory, displaying their relative file sizes in a tree view recursively. This provides a detailed overview of disk usage.

Explanation:

  • --recursive: Displays the output recursively, including subdirectories.
  • Other arguments have the same explanation as in Use Case 2.

Example output:

  ⠀
  ⠀⠄⠀⠄⢰⡿⡿⡿⡿⣿⠿⢻⡷⠚⠛⠛⠛⠛⢷⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣀⣀⡀
  ⠀⠄⠀⠀⣿⣿⡿⡿⡿⣿⣿⣿⠂⠀⠀⠀⠀⣀⣤⣬⣉⡉⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⢻⣷
  ⠀⠄⠀⠀⣿⣿⣿⡇⠀⢸⣿⡿⡆⠀⠀⠀⣀⡼⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢷
  ⠀⠄⠀⠀⣿⣿⣿⡇⠀⣸⣷⣿⠃⠀⠀⠀⠙⢁⡀⠀⠀⠀⠀⠀⢀⣤⣶⣄⡀⠀⠀⣄⣀⣠⣿
  ⠀⠄⠀⢀⣿⣿⣿⣿⡄⢸⣿⡿⠁⣠⣐⣠⣾⠃⠀⠀⠀⠀⣾⣿⣿⣿⣿⣿⣿⣿⡆⠈⠙⢿
  ⠀⠄⠠⣿⡿⢻⣿⣿⣿⠀⢸⣿⣧⠀⣿⡿⠁⠀⠀⠀⠀⠀⠈⠿⢿⣿⣿⣿⣿⡿⠁⠀⡄⠀
  ⠀⠄⢀⣿⣿⣶⡉⠉⠉⠀⠈⠉⠁⠀⠇⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⢿⣿⡿⠛⠀⠁⠀⠐⡄
  ⣠⣾⣿⣿⡿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Tags :

Related Posts

How to use the command 'ahost' (with examples)

How to use the command 'ahost' (with examples)

The ‘ahost’ command is a DNS lookup utility that allows users to display the A or AAAA record linked with a hostname or IP address.

Read More
How to use the command mkvmerge (with examples)

How to use the command mkvmerge (with examples)

Mkvmerge is a command-line tool that allows users to merge and extract multimedia streams.

Read More
How to use the command flac (with examples)

How to use the command flac (with examples)

The flac command is a powerful tool for encoding, decoding, and testing FLAC files.

Read More