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

Find the Largest Files and Folders on Linux

neo by neo
May 27, 2025
in Solutions
0
Find the Largest Files and Folders on Linux

Find the Largest Files and Folders on Linux

0
SHARES
26
VIEWS
Share on FacebookShare on Twitter
ADVERTISEMENT

Find the Largest Files or Folders

Find the Largest Files and Folders on Linux is one of the essential tasks for any Linux user or administrator. It is very important is keeping an eye on disk space usage. The du command (short for disk usage) is an incredibly useful tool that helps analyze the size of files and directories. In this article, we’ll cover two common use cases: using du -skh * to check the sizes of files and directories in the current folder, and du -ah /path/to/folder | sort -rh | head -n 10 to find the largest files or folders in a directory.

Command to list 10 Biggest Folders

du -ah /path/to/folder | sort -rh | head -n 10

When you need to identify the largest files or directories in a specific path, the combination of du, sort, and head is incredibly useful. Here’s a breakdown of the command:

  • du -ah /path/to/folder: Shows the size of all files and directories recursively within the specified folder in human-readable format.
    • -a: Includes files in the output, not just directories.
    • -h: Displays sizes in a human-readable format.
  • sort -rh: Sorts the output by size in reverse order, showing the largest items first.
    • -r: Reverse order (largest to smallest).
    • -h: Sorts by human-readable sizes (KB, MB, GB).
  • head -n 10: Limits the output to the top 10 largest files or directories.

Example Output:

7T    /data/a/
3T    /data/a/folder1
2T    /data/a/folder2
1G    /data/a/folder3
1G    /data/a/folder4

When to Use du -ah /path/to/folder | sort -rh | head -n 10

This command is ideal for identifying large files or folders that are consuming a significant portion of your disk space. It’s especially useful for pinpointing storage hogs in larger directories, helping you prioritize what to clean up.

Understanding Disk Usage with du -skh *

du -skh * | sort -rh

The command du -skh * is a quick way to check the disk usage of all items (files and directories) in your current folder. Here’s how it works:

  • du: The disk usage command.
  • -s: Summarizes the total size of each file or directory instead of showing sizes for every subdirectory.
  • -k: Outputs the size in kilobytes.
  • -h: Makes the output more human-readable, showing sizes in KB, MB, or GB, depending on the file size.
  • *: Represents all files and directories in the current folder.
  • sort -rh: Sorts the output by size in reverse order, showing the largest items first.
    • -r: Reverse order (largest to smallest).
    • -h: Sorts by human-readable sizes (KB, MB, GB).

Example Output:

300M  backup_file.tar.gz
4.5M  project_folder
12K   script.sh

This output shows that script.sh takes up 12KB, project_folder uses 4.5MB, and backup_file.tar.gz occupies 300MB of space.

When to Use du -skh *

This command is perfect for getting a quick snapshot of how much space each file or directory in your current folder is using. It’s an ideal starting point when trying to clean up disk space.

More example how to use du command you can find on the following link.

ADVERTISEMENT
ADVERTISEMENT

A very useful application for monitoring disk space is ncdu. You can find out how it works on the link.

ADVERTISEMENT

Find the Largest Files and Folders on Linux

About The Author

neo

See author's posts

Tags: linux
ADVERTISEMENT
Previous Post

MikroTik: Configure Router with Winbox Application

Next Post

Linux Networking: Display Open Ports and Listening Services

neo

neo

Next Post
Linux Networking: Display Open Ports and Listening Services

Linux Networking: Display Open Ports and Listening Services

Follow Us

  • Trending
  • Comments
  • Latest
MikroTik: Export Configuration in Text File

MikroTik: Export Configuration in Text File

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Immich: Installation on Ubuntu 22.04

Immich: Installation on Ubuntu 22.04

Fortinet FortiGate Upgrade Path Tool

Fortinet FortiGate Upgrade Path Tool

NextCloud: Port Forwarding - Essential Ports for Smooth Functionality

NextCloud: Port Forwarding – Essential Ports for Smooth Functionality and Remote Access

Organizing and Managing Photos with Immich: Features I Use

Organizing and Managing Photos with Immich: Features I Use

Install Ubuntu 22.04 on Oracle VM Virtual Box

Install Ubuntu 22.04 on Oracle VM Virtual Box

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Recent News

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

MikroTik: Check Your Wireless Password

MikroTik: Check Your Wireless Password

ADVERTISEMENT

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

Browse by Category

  • 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

Recent News

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

  • 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
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos

© 2025 defencedev.com - All rights reserved.