How to use the command 'duc' (with examples)
- Linux
- December 25, 2023
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:
⠀
⠀⠄⠀⠄⢰⡿⡿⡿⡿⣿⠿⢻⡷⠚⠛⠛⠛⠛⢷⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣀⣀⡀
⠀⠄⠀⠀⣿⣿⡿⡿⡿⣿⣿⣿⠂⠀⠀⠀⠀⣀⣤⣬⣉⡉⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⢻⣷
⠀⠄⠀⠀⣿⣿⣿⡇⠀⢸⣿⡿⡆⠀⠀⠀⣀⡼⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢷
⠀⠄⠀⠀⣿⣿⣿⡇⠀⣸⣷⣿⠃⠀⠀⠀⠙⢁⡀⠀⠀⠀⠀⠀⢀⣤⣶⣄⡀⠀⠀⣄⣀⣠⣿
⠀⠄⠀⢀⣿⣿⣿⣿⡄⢸⣿⡿⠁⣠⣐⣠⣾⠃⠀⠀⠀⠀⣾⣿⣿⣿⣿⣿⣿⣿⡆⠈⠙⢿
⠀⠄⠠⣿⡿⢻⣿⣿⣿⠀⢸⣿⣧⠀⣿⡿⠁⠀⠀⠀⠀⠀⠈⠿⢿⣿⣿⣿⣿⡿⠁⠀⡄⠀
⠀⠄⢀⣿⣿⣶⡉⠉⠉⠀⠈⠉⠁⠀⠇⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⢿⣿⡿⠛⠀⠁⠀⠐⡄
⣠⣾⣿⣿⡿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀