Exploring Disk Usage with Duc (with examples)
- Linux
- December 17, 2024
Duc is a sophisticated collection of tools designed to help users index, inspect, and visualize disk usage effectively. It maintains a database of classified directory sizes within your file system, allowing for easy querying and visualization. This makes it an invaluable resource for anyone looking to understand where and how disk space is being used on their system. The following sections provide practical examples of using Duc to manage disk space efficiently.
Index the /usr
directory using Duc
Code:
duc index /usr
Motivation:
Indexing a directory allows Duc to analyze the disk usage within that directory and store this data in a database. This is crucial for later querying and visualizations. By indexing the /usr
directory, users often aim to identify which subdirectories or files consume the most space, helping them to make informed decisions about file management or cleanup.
Explanation:
duc index
: This initiates the indexing process using Duc./usr
: Specifies that the/usr
directory, a common location for installed software and system libraries, is the target for indexing.
Example Output:
The command does not produce direct console output but updates Duc’s database. Subsequent exploration commands, like duc ls
or duc gui
, will reflect this indexed data.
List all files and directories under /usr/local
, showing relative file sizes in a graph
Code:
duc ls --classify --graph /usr/local
Motivation:
This function is used to get a clear vision of disk space usage by showing files and directories under /usr/local
in a hierarchical structure, relative to their sizes. It helps users easily identify large files or directories that may need attention, especially in systems where the /usr/local
directory is heavily utilized for custom or user-installed software.
Explanation:
duc ls
: Command to list files and directories.--classify
: Adds a type indicator for entities (such as directories ‘/’, executables ‘*’).--graph
: Enables the graphical representation option for showing space usage./usr/local
: The directory to analyze and visualize, often a place for locally compiled software.
Example Output:
[==== ] 20% TenGB.bin*
[==== ] 20% FiftyGB_folder/
[============ ] 50% Apps/
List all files and directories under /usr/local
using treeview recursively
Code:
duc ls --classify --graph --recursive /usr/local
Motivation:
Using the treeview is particularly helpful in understanding the hierarchy and distribution of files and directories throughout the /usr/local
path. Recursive listing gives deeper insight into nested directories, facilitating a more thorough understanding of space usage.
Explanation:
duc ls
: The command to list directory contents.--classify
: Appends indicators to file listings to classify them.--graph
: Displays relative sizes graphically.--recursive
: Ensures all subdirectories are included in the listing./usr/local
: The target directory for this operation.
Example Output:
/usr/local/
├── [==== ] 20% folder1/
│ ├── [== ] 5% file1.txt
│ └── [== ] 5% file2.txt
└── [======== ] 50% bigApp/
Start the graphical interface to explore the file system using sunburst graphs
Code:
duc gui /usr
Motivation:
The graphical user interface (GUI) of Duc facilitates an intuitive way to explore disk usage along paths, offering interactive sunburst diagrams. These visuals are particularly useful for users who prefer graphically navigating their file system rather than through text-based outputs.
Explanation:
duc gui
: Launches the graphical interface for exploring disk usage./usr
: The entry point directory for the GUI exploration.
Example Output:
The GUI will present a sunburst diagram of disk usage under the /usr
directory, helping visualize data allocation seamlessly.
Run the ncurses console interface to explore the file system
Code:
duc ui /usr
Motivation:
Using the ncurses-based interface provides a text-based graphical interaction that is lightweight and can be used in environments without a full graphical desktop environment. It’s ideal for terminal-based users needing efficient navigation.
Explanation:
duc ui
: Starts the ncurses interface for exploring./usr
: Specifies that the exploration should start under the/usr
directory.
Example Output:
Users will see an interactive console display for disk usage, much like a visual file manager in a terminal, with navigable elements and detailed size summaries.
Dump database info
Code:
duc info
Motivation:
Dumping the database information allows users to see the metadata around what Duc has indexed. This is crucial for verifying what datasets are being worked with or diagnosing potential issues with the database.
Explanation:
duc info
: Retrieves and displays information about the current state of the Duc database.
Example Output:
Database: ~/.duc.db
Index Date: 2023-10-01
Dirs Indexed: 1032
Total Size Indexed: 350GB
Conclusion:
Duc is a versatile tool that simplifies the process of understanding disk usage across the system. By indexing directories and allowing for both command line and graphical exploration, it offers solutions tailored to different user preferences and environments. With capabilities such as recursive listing and graphical visualization, Duc stands as an essential utility for effective disk space management.