
mdu Command in Linux
Managing disk space is a day-to-day task for Linux system administrators and users. It's essential to keep track of how disk space is used in different directories and files. For this purpose, Linux provides a useful command named mdu. This command helps us check disk usage in a specific directory or file path, enabling us to optimize storage and avoid running out of space.
Table of Contents
Here is a comprehensive guide to the options available with the mdu command −
- What is mdu Command in Linux?
- Syntax of mdu Command
- mdu Command Options
- Key Features of mdu Command
- Examples of mdu Command in Linux
- Modern Alternatives to mdu Command
What is mdu Command in Linux?
The mdu command is a Linux tool used to analyze disk usage. It helps us evaluate the space used by files and directories. It returns the disk usage information in an easy-to-understand format. This makes it ideal for identifying large files or directories that may be consuming excessive space. Therefore, system administrators commonly use this tool to track storage use, avoid disk overflow, and optimize the allocation of available space.
Note: In modern Linux Systems, the mdu command is replaced by the du command.
Syntax of mdu Command
The mdu command is used to measure disk usage in a directory or file. Its basic syntax is as follows −
mdu [options] [directory]
The mdu command is used to check disk usage, where options represent optional flags that modify the command's behavior, and the directory specifies the path to the directory or file being analyzed.
Before proceeding, make sure mdu is installed on your system. For this purpose, you can check the mdu version by executing the following command −
mdu --version

This confirms that mdu is successfully installed on our system, and we can proceed with using it.
mdu Command Options
Some common options for the mdu command include −
- -h − It shows the disk usage in a human-readable format (e.g., KB, MB, GB).
- -s − It displays the total size of the directory rather than the size of individual files.
- -x − It excludes directories that are on different file systems.
- -a − It includes all files, including hidden ones (those with a leading dot).
To learn more about the mdu command simply access the General commands manual by running the following command −
man mdu

Key Features of mdu Command
The mdu command offers a wide range of features. Some of them are listed below −
- The mdu command shows disk usage in simple terms like KB, MB, or GB. This makes it easier to understand how much space is being used.
- mdu shows the total size of a directory instead of listing the size of each file. This makes it quicker to check space usage.
- mdu can ignore directories on different file systems, which helps us focus on specific partitions or mount points.
- mdu provides hidden file support (those starting with a dot) in the disk usage calculation.
- mdu is fast and accurate, making it a good choice for scanning large file systems where speed matters.
Examples of mdu Command in Linux
The mdu command can be used with or without options depending on your needs. Running it without options usually provides a default output while adding options helps us customize the output.
Check Disk Usage of a Directory
Let's execute the mdu command without any option to get the default output −
mdu dirName
This command will retrieve the total disk usage for the specified directory or file. If we do not specify the directory, then this command retrieves the disk usage information of the current directory.
Show Disk Usage in Human-readable Format
We can use the mdu command with the -h option to get the output in a human-readable format −
mdu -h dirName
It returns the output in units like kilobytes (KB), megabytes (MB), or gigabytes (GB).
Summarize Directory Size
We can use the -s option to get the total size of a directory without listing the sizes of individual files or subdirectories −
mdu -s dirName
Exclude Other File Systems
The mdu command can be executed with the -x option to calculate disk usage of a specific directory while excluding other mounted file systems −
mdu -x dirName
Include Hidden Files
Use the -a option to include hidden files in the disk usage calculation −
mdu -a dirName
Detailed Output
You can use the -v flag to display a more detailed view of the disk usage −
mdu -v dirName
Combining Multiple Options
We can execute the mdu command with multiple options combined to get a more customized output. For example, we can calculate disk usage in a human-readable format while excluding other mounted file systems and displaying the total size of a directory without listing individual files −
mdu -shx /path/to/directory
In this command, the -s option shows the total size of the directory, -h makes the output human-readable, and -x excludes other mounted file systems from the calculation.
Modern Alternatives to mdu Command
The mdu command, which was once used to check disk usage in Linux, is now mostly replaced by newer tools like the du (Disk Usage) command. Here are some modern alternatives to the Linux mdu command −
- du command checks how much space files and directories are using. It provides options to display the size in a more readable format and analyze directories and subdirectories.
- Another Linux command named df shows information about the free and used space on mounted drives. For a more interactive way to explore disk usage, ncdu offers an easy-to-use, navigable interface.
- For advanced users managing newer storage systems, tools like lsblk or commands for specific file systems like Btrfs and ZFS are helpful.
That's all about the Linux mdu command.
Conclusion
Managing disk space is important for both Linux system administrators and users. The mdu command was once a helpful tool for checking disk usage in files and directories. By using different options, we could customize the output to better understand storage use and manage space effectively.
While mdu is still useful, newer tools like the du command have mostly replaced it. The du command offers more flexibility and better features for analyzing disk usage. In this article, we discussed how to manage disk space using mdu command.