• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools
No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools
No Result
View All Result
DefenceDev
No Result
View All Result
Home Linux Tutorials Commands

Check Disk Usage on the Linux with du Command

by neo
November 28, 2025
in Commands
0
Check Disk Usage on the Linux with du Command

Check Disk Usage on the Linux with du Command

0
SHARES
32
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.

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

10+ Useful Linux find Command Examples You Should Know

Linux Process, List all Running Services with ps Command
Commands

Check Running Processes and Services in Linux via ps

Descripton for kill command on Ubuntu
Commands

Linux Process Management, kill Command

Linux Files Operation: chwon (Change Ownership of The Files)
Commands

Linux Files Operation: chown (Change Ownership of the Files)

Linux Files Operation: grep, Efficient Text Search
Commands

Linux Files Operation: grep, Efficient Text Search

Linux Files Operation: find Temp Files and Execute Commands on Found Files
Commands

How to Find Temporary Files in Linux and Execute Commands on Them

Next Post
YouTube Channel about Linux Topics

YouTube Channel about Linux Topics

Recommended

Fortinet FortiGate Upgrade Path Tool

Fortinet FortiGate Upgrade Path Tool

MikroTik OpenVPN: Sound Alert When VPN Tunnel Fails

MikroTik OpenVPN: Sound Alert When VPN Tunnel Fails

Maximizing Network Efficiency with AdGuard: My 7-Day Results

Maximizing Network Efficiency with AdGuard: My 7-Day Results

FortiGate Brute Force Protection: Ban IPs After Failed Admin Login

FortiGate Brute Force Protection: Ban IPs After Failed Admin Login

Install Portainer on Ubuntu 24.04 Using Docker Compose

Install Portainer on Ubuntu 24.04 Using Docker Compose

Categories

  • Blog
  • Cloud
    • Private
  • Linux Tutorials
    • Bash Scripting Tutorials
    • Commands
    • Networking
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Solutions
    • Docker
  • Video Tutorials
    • MikroTik Videos
  • 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

Maximizing Network Efficiency with AdGuard: My 7-Day Results

Maximizing Network Efficiency with AdGuard: My 7-Day Results

FortiGate Brute Force Protection: Ban IPs After Failed Admin Login

FortiGate Brute Force Protection: Ban IPs After Failed Admin Login

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

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools

© 2025 defencedev.com - All rights reserved.