mdu

system informationLinux/Unix
The mdu command is one of the most frequently used commands in Linux/Unix-like operating systems. mdu Display disk usage in megabytes

Quick Reference

Command Name:

mdu

Category:

system information

Platform:

Linux/Unix

Basic Usage:

mdu [options] [arguments]

Common Use Cases

    Syntax

    mdu [options] [file...]

    Options

    Option Description
    -a, --all Write counts for all files, not just directories
    -b, --bytes Display size in bytes
    -c, --total Produce a grand total
    -d, --max-depth=N Print the total for directories only N or fewer levels deep
    -h, --human-readable Print sizes in human readable format (e.g., 1M, 3.7G)
    --si Like -h, but use powers of 1000 not 1024
    -k, --kilobytes Display size in kilobytes
    -m, --megabytes Display size in megabytes (default)
    -s, --summarize Display only a total for each argument
    -S, --separate-dirs Do not include size of subdirectories
    -t, --threshold=SIZE Exclude entries smaller than SIZE
    -x, --one-file-system Skip directories on different file systems
    --exclude=PATTERN Exclude files that match PATTERN
    -0, --null End each output line with NUL, not newline

    Examples

    How to Use These Examples

    The examples below show common ways to use the mdu command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    Basic Examples:

    mdu file.txt
    Display the size of file.txt in megabytes.
    mdu directory/
    Display the total size of directory/ in megabytes.

    Advanced Examples:

    mdu -s directory/
    Display only the total size of directory/ without subdirectories.
    mdu -h directory/ Display sizes in human-readable format (e.g., 1.2M, 3.7G). mdu -c directory1/ directory2/ Display a grand total of all listed directories. mdu -a directory/ Display sizes for all files, not just directories. mdu -d 2 directory/ Display entries up to a maximum depth of 2 directories. mdu -t 5M directory/ Display only entries larger than 5 megabytes. mdu --exclude="*.log" directory/ Exclude all .log files from the calculation. mdu -0 directory/ | sort -rn Output sizes terminated by null character for sorting by size.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The 'mdu' command is a variant of the standard 'du' (disk usage) command that displays file and directory sizes in megabytes by default. It's essentially a shorthand or wrapper around 'du -m', making it more convenient to get disk usage information in megabyte units. Key features of the mdu command: 1. Megabyte Display: By default, mdu shows file and directory sizes in megabytes, which provides a more readable output for modern systems with large storage capacities. 2. Directory Traversal: Like du, mdu recursively traverses directory structures, calculating the total disk space used by each directory and its subdirectories. 3. Filtering Options: The command supports various options to filter the output, such as showing only files above a certain size threshold or excluding specific file patterns. 4. Depth Control: Users can limit how deep mdu will traverse into directory hierarchies, which is useful for examining specific levels of a file system. 5. Output Formatting: mdu can display sizes in various formats, including human-readable formats with appropriate unit suffixes (KB, MB, GB, etc.). 6. Grand Totals: The command can provide a cumulative total of all the files and directories specified, helping to understand overall disk usage. 7. File System Boundaries: mdu can be instructed to stay within a single file system, which is useful when examining disk usage without crossing mount points. Common use cases for mdu include: - Quickly identifying which directories are consuming the most space - Finding large files that may be candidates for archiving or deletion - Monitoring disk usage over time - Planning for storage needs based on current usage patterns - Troubleshooting disk space issues - Creating reports on storage utilization It's worth noting that on many systems, 'mdu' might not be a built-in command, but rather an alias or script created by system administrators to simplify the use of 'du -m'. The functionality described here reflects how such a command would typically behave, based on the standard 'du' command with a focus on megabyte output. For systems without an 'mdu' command, users can typically achieve the same functionality by using 'du -m' or by creating their own alias or script.

    Related Commands

    These commands are frequently used alongside mdu or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the mdu command works in different scenarios.

    $ mdu
    View All Commands