• 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
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
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
30
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:

ADVERTISEMENT
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.

ADVERTISEMENT

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

ADVERTISEMENT

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

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

Related Posts

My Ultimate Docker Command Cheat Sheet (2025 Edition)
Docker

My Ultimate Docker Commands Cheat Sheet (2025 Edition)

Protect Docker-Hosted Application from HTTP Flood (DDoS) Attacks Using a Bash Script
Docker

Protect Docker-Hosted Application from HTTP Flood (DDoS) Attacks Using a Bash Script

Raspberry Pi Monitoring with Monit: Docker, Temperature, Network & More
Solutions

Raspberry Pi Monitoring with Monit: Docker, Temperature & More

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

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

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

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

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

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

Next Post
Linux Networking: Display Open Ports and Listening Services

Linux Networking: Display Open Ports and Listening Services

Recommended

FortiGate Packet Capture from 'Network' and 'Packet Capture' sub menu.

Fortinet FortiGate: Packet Capture from CLI and GUI

Linux Networking: netplan DHCP Configuration on Ubuntu

Linux Networking: netplan DHCP Configuration on Ubuntu

MikroTik OpenVPN: Sound Alert When VPN Tunnel Fails

MikroTik OpenVPN: Sound Alert When VPN Tunnel Fails

MikroTik: OpenVPN Client Failover Script

MikroTik: OpenVPN Client Failover Script

GitHub: How to Add a Script or a Folder to Your Repository

GitHub: How to Add a Script or a Folder to Your Repository

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
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

Recent News

MikroTik OpenVPN: Sound Alert When VPN Tunnel Fails

MikroTik OpenVPN: Sound Alert When VPN Tunnel Fails

MikroTik: OpenVPN Client Failover Script

MikroTik: OpenVPN Client Failover Script

  • 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

© 2025 defencedev.com - All rights reserved.