• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools
No Result
View All Result
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools
No Result
View All Result
DefenceDev
No Result
View All Result
Home Linux Commands&Tips

Check Disk Usage on the Linux with du Command

by neo
September 3, 2026
in Commands&Tips
0
Check Disk Usage on the Linux with du Command

Check Disk Usage on the Linux with du Command

0
SHARES
53
VIEWS
Share on FacebookShare on LinkedIn
Table of Contents
  • Disk Usage on the Linux
    • Introduction
    • Basic du Syntax
    • Commonly Used Options
    • Basic Examples of du command
    • Advanced Usage and Tips
    • Other Examples

Disk Usage on the Linux

Check Disk Usage on the Linux with du Command is a crucial aspect of maintaining a healthy Linux system. When storage starts to fill up, identifying which files or directories are consuming the most space can save time and prevent disruptions. The du (disk usage) command is an indispensable tool for this purpose, providing detailed insights into disk usage at the file and directory level.

Introduction

The du – disk usage command displays the amount of disk space used by files and directories on Linux systems. By default, it shows the disk usage of each directory and subdirectory within the current directory.

Basic du Syntax

du [OPTION]... [FILE]...

Commonly Used Options

Here are some of the most commonly used options with the du command:

  • -a or --all: Includes both files and directories in the output.
  • -h or --human-readable: Displays sizes in human-readable format (e.g., K, M, G).
  • -s or --summarize: Displays only the total for each argument.
  • -c or --total: Displays a grand total of the disk usage found by the other arguments.
  • --max-depth=N: Limits the output to directories (and files) at most N levels deep.
  • -d or --depth=N: Similar to --max-depth=N, shows the total for directories up to N levels deep.
  • --exclude=PATTERN: Excludes files that match the given pattern.

Basic Examples of du command

  • To display the disk usage in a human-readable format:
du -h
  • To display only the total disk usage of the current directory:
du -sh
  • To include all files in the output:
du -ah
  • To limit the depth of the directories shown in the output to two levels:
du --max-depth=2
  • To display a grand total at the end of the output:
du -ch
Output of the du command "du -ch"
Output of the command “du -ch”
  • To exclude files that match a specific pattern:
du --exclude='*.log'
  • Displays disk usage of files and directories and summarize the total size of each argument:
du -skh *

Advanced Usage and Tips

  • Analyzing Large Directories: Combine du with other commands like sort and head to find the largest directories:
du -ah /path/to/directory | sort -rh | head -n 10




  • To see the memory usage of directories within a folder and sort them by size, you can use the du (disk usage) command combined with sort:
du -h --max-depth=1 /path/to/folder | sort -hr

Explanation

  • du -h --max-depth=1 /path/to/folder:
    • du stands for “disk usage.”
    • -h makes the output human-readable (e.g., in K, M, G for kilobytes, megabytes, and gigabytes).
    • --max-depth=1 limits the command to only look at the top-level directories within /path/to/folder.
  • sort -hr:
    • sort sorts the output.
    • -h sorts by human-readable numbers.
    • -r sorts in reverse order (i.e., from largest to smallest).
  • To check the memory usage in the current directory and sort by size:
du -h --max-depth=1 . | sort -hr
Output of the du command "du -h --max-depth=1 . | sort -hr"
Output of the command “du -h –max-depth=1 . | sort -hr”

This command will provide a list of directories and their sizes, sorted from largest to smallest.

Other Examples

A very efficient way to check disk usage is the ncdu application. You can check it at the link.

Tags: linuxstorage
Previous Post

Nextcloud: How to Upgrade Nextcloud via the Web Interface

Next Post

YouTube Channel about Linux Topics

neo

Related Posts

10+ Useful Linux find Command Examples You Should Know
Commands&Tips

10+ Useful Linux find Command Examples You Should Know

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)
Commands&Tips

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

Timeshift on Linux: How to Create and Restore System Snapshots
Commands&Tips

Timeshift on Linux: How to Create and Restore System Snapshots

Remote Desktop Access to Ubuntu 24.04 from Windows
Commands&Tips

Remote Desktop Access to Ubuntu 24.04 from Windows

Fix "blk_update_request: critical target error" on Ubuntu Server (dev sdb, DISCARD Operation)
Commands&Tips

Fix “blk_update_request: critical target error” on Ubuntu Server with SSD (dev sdb, DISCARD Operation)

Passwordless SSH Login on Ubuntu: Secure Server Access
Commands&Tips

Passwordless SSH Login on Ubuntu: Secure Server Access

Next Post
YouTube Channel about Linux Topics

YouTube Channel about Linux Topics

Recommended

MikroTik: Port Forwarding (NAT) Configuration

MikroTik: Port 443 Forwarding to Web Server (NAT) Configuration

Setting Up IPS (Intrusion Detection System) Profiles on FortiGate to Detect Web Attacks

Setting Up IPS (Intrusion Detection System) Profiles on FortiGate to Detect Web Attacks

Briefly unavailable for scheduled maintenance. Check back in a minute.

WordPress Stuck in Maintenance Mode After Plugin Update

Promox Telegram Alert Example

Configure Telegram Notifications in Proxmox VE Using Webhooks

Fix Proxmox VM Snapshot “Out of Space” Errors

Fix Proxmox VM Snapshot “Out of Space” Errors

Categories

  • Linux
    • Bash Scripting
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Web Tools

DefenceDev Tutorials

defencedev Logo

Whether you’re just starting or looking to expand your skills, I hope you find useful information and engaging discussions here. Let me take you through my journey and the goals behind this space!

Follow Us

Recent News

Briefly unavailable for scheduled maintenance. Check back in a minute.

WordPress Stuck in Maintenance Mode After Plugin Update

Promox Telegram Alert Example

Configure Telegram Notifications in Proxmox VE Using Webhooks

  • Site Map
  • Privacy Policy
  • Facebook Page
  • GitHub
  • Disclaimer
  • Contact
  • About Me

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools

© 2025 defencedev.com - All rights reserved.