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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay