In the next article we are going to take a look at Duc. This is one collection of tools that we can use to index, inspect and visualize disk usage on Unix-like operating systems. Duc has been tested on systems consisting of a few million files and several petabytes of storage with good performance.
Duc stores disk usage in an optimized database. With this set of tools we are going to quickly find where the bytes of our disk are and what are dedicated. In addition, it comes with several user interfaces and back-ends with which we can access the database and draw the graphs.
Currently the supported user interfaces they are: the command line interface (ls),
Ncurses interface console (ui), X11GUI (duke gui) and OpenGL GUI (duke gui). Refering to list of supported database back ends, we are going to have Tokyocabinet, Leveldb and Sqlite3. Duc uses Tokyocabinet as the default database.
Install Duc on Ubuntu
Duc is available in the default repositories of Debian and its derivatives, such as Ubuntu. For this reason we can install it in this type of system by opening a terminal (Ctrl + Alt + T) and in it by typing:
sudo apt install duc
Using Duc
Typical use is:
duc subcomando opciones
We can see the list of general options and subcommands by running help in terminal (Ctrl + Alt + T):
duc help
Para ver the complete list of all commands and their options run:
duc help --all
In case we are interested know the use of a specific subcommand, we can consult it in the following way:
duc help subcomando
Create the index (database) by duc
Before we start, first we must create a filesystem index. We will only have to use the following command to create an index of the user's / home directory:
duc index /home
The above command will save the .duc.db file in the / home folder. If you have added new files or directories in the folder on which we created the index, the above command will have to be run again at any time to rebuild it.
Use the query index
Using the subcommands, we will be able to consult and explore the index that we have created previously:
duc info
In case of wanting list all files and directories in the current working directory, we can write:
duc ls
We can also use the -R option to see the disk usage result with the tree structure:
duc ls -R /home/usuario
View disk usage on a graph from the terminal
We will also be able to view file sizes in a chart. In case you are interested in seeing the graph of a certain route, you can use the command 'duc ls' as it's shown in the following:
duc ls -Fg /home/usuario
The above command queries the duc database and lists the size of all files and directories in the path. If a path is not provided, the current working directory will be scanned.
We will also be able to execute the seven command to open a console user interface based on ncurses. With it we can explore the use of the file system:
duc ui
If you are interested open an Ncurses-based console UI to explore a particular path, there will be no more than use subcommand 'ui' as follows:
duc ui /home/usuario/carpeta
Use a graphical interface (X11)
If you prefer use a graphical interface (X11) to explore the file system, the command that can be used is the following:
duc gui
In this case, we will also be able to use the subcommand 'gui' to query the duc database with a graphical interface (X11) to explore the disk usage of the given path:
duc gui /home/usuario/carpeta
Help
What we have just seen are only the most basic steps that can be taken with 'duke'. For more information, visit the project website or check the man pages in terminal (Ctrl + Alt + T):
man duc
If you give it a try, you will see that it is a simple but useful disk usage viewer. Provides users with a quick way to know which files or directories are taking up too much.