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

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

The ‘duf’ command is a disk usage/free utility that provides information about disk usage. It is a convenient tool to get insights into disk space utilization and identify files or directories that are taking up the most space. With various options and arguments, ‘duf’ can be customized to suit different needs.

Use case 1: List accessible devices

Code:

duf

Motivation: Sometimes, it is essential to know the disk space usage on all accessible devices. This can help in identifying any devices that are running out of space or are overloaded with data.

Explanation: Running ‘duf’ without any arguments or options will list the disk usage information for all accessible devices. It provides details such as filesystem, total size, used space, available space, and percentage of utilization.

Example output:

DEVICE FILESYSTEM   TOTAL   USED   FREE  USAGE
sda    /dev/sda1   250GB   100GB  150GB  40%
nvme0  /dev/nvme0n1 500GB  300GB  200GB  60%

Use case 2: List everything

Code:

duf --all

Motivation: It is sometimes necessary to list all filesystems, including pseudo, duplicate, or inaccessible ones. This can be useful for system administrators or advanced users to analyze and troubleshoot disk usage issues.

Explanation: Adding the ‘–all’ option to the ‘duf’ command will display all the filesystems, including ones that are typically excluded from standard disk usage reports. This includes special filesystems like ‘/proc’ or inaccessible devices.

Example output:

DEVICE FILESYSTEM   TOTAL   USED   FREE  USAGE
sda    /dev/sda1   250GB   100GB  150GB  40%
nvme0  /dev/nvme0n1 500GB  300GB  200GB  60%
proc   /proc       0KB     0KB    0KB    -

Use case 3: Only show specified devices or mount points

Code:

duf path/to/directory1 path/to/directory2 ...

Motivation: Sometimes, it is necessary to get disk usage information for specific directories or mount points rather than the entire system. This is useful when you want to focus on specific areas to identify space-hungry files or directories.

Explanation: Providing the path to one or more directories as arguments to the ‘duf’ command will display the disk usage information only for those directories. This narrows down the output and provides focused information about the specified directories.

Example output:

DEVICE FILESYSTEM   TOTAL   USED   FREE  USAGE
sda    /dev/sda1   250GB   100GB  150GB  40%
nvme0  /dev/nvme0n1 500GB  300GB  200GB  60%

Use case 4: Sort the output by a specified criteria

Code:

duf --sort size|used|avail|usage

Motivation: Sorting the disk usage information based on specific criteria can help identify the largest or most utilized files or directories. This allows for easy identification of space-consuming entities.

Explanation: By using the ‘–sort’ option followed by the criteria (size, used, avail, or usage), the ‘duf’ command can sort the output based on the specified criteria. This provides a sorted view of the disk usage, making it easier to identify files or directories with the highest utilization.

Example output:

DEVICE FILESYSTEM   TOTAL   USED   FREE  USAGE
nvme0  /dev/nvme0n1 500GB  300GB  200GB  60%
sda    /dev/sda1   250GB   100GB  150GB  40%

Conclusion:

The ‘duf’ command is a versatile disk usage/free utility that offers insights into disk space utilization. Whether it’s listing all accessible devices, including inaccessible ones, focusing on specific directories, or sorting the output, ‘duf’ provides a powerful toolset for analyzing disk usage. Understanding the different use cases and options enables users to leverage ‘duf’ effectively for their disk management needs.

Related Posts

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

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

The ‘interdiff’ command is a tool that allows users to compare differences between two diff files.

Read More
Using the "vectorize-pixelart" Command (with examples)

Using the "vectorize-pixelart" Command (with examples)

In this article, we will explore different use cases of the “vectorize-pixelart” command, which is a tool that converts raster PNG pixel art graphics into SVG or EPS vector images.

Read More
How to use the command 'topgrade' (with examples)

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

The ’topgrade’ command is a tool used to update all applications on a system.

Read More