DEV Community

shun
shun

Posted on

Disk Usage Commands in Linux

df: Display Filesystem Disk Space Usage

The df command is used to display the disk space usage of mounted filesystems.

  • Basic Usage:
  $ df
Enter fullscreen mode Exit fullscreen mode
  • Common Options:

    • -h or --human-readable: Display sizes in a human-readable format (K, M, G).
    $ df -h
    
    • -T or --print-type: Display filesystem types.
    $ df -T
    
    • -a or --all: Display all filesystems, including pseudo, duplicate, inaccessible filesystems.
    $ df -a
    
    • -i or --inodes: Display inode information.
    $ df -i
    

du: Estimate File and Directory Space Usage

The du command estimates disk space usage of files and directories.

  • Basic Usage:
  $ du /path/to/directory
Enter fullscreen mode Exit fullscreen mode
  • Common Options:

    • -h or --human-readable: Display sizes in a human-readable format (K, M, G).
    $ du -h /path/to/directory
    
  • -s or --summarize: Display only the total size of the specified directory.

  $ du -s /path/to/directory
Enter fullscreen mode Exit fullscreen mode
  • -a or --all: Display both directory and file information.
  $ du -a /path/to/directory
Enter fullscreen mode Exit fullscreen mode
  • -c or --total: Display the grand total.
  $ du -c /path/to/directory
Enter fullscreen mode Exit fullscreen mode
  • --max-depth=N: Display information up to a depth of N directories.
  $ du --max-depth=1 /path/to/directory
Enter fullscreen mode Exit fullscreen mode

Understanding the df and du commands is essential for monitoring disk space usage and managing file storage effectively.

Top comments (0)