•  Home
  •  Dashboard
  •  Company
    • About Us
    • Blog
    • Careers
    • Contact Us
    • Data Centers
    • Looking Glass
    • Network
    • Reseller
  •  Hosting Services
    • Infrastructure
      • iColocation
    • Compute
      • cMetal
      • cVirtual
    • Storage
      • sObject
      • sBlock
    • Networking
      • nCDN
      • nIP Transit
      • nWavelength
    • Protection
      • pBackup
      • pDDoS
  •  Solutions
    • Ecommerce
    • Finance
    • Gaming
    • Hosting
    • Management
    • Security
    • System Integrator
  •  Support
    • Community
    • Knowledge Base
    • Open A Ticket
  •  USA & Canada: 800-933-1517
  •  International: 626-549-2801
  •  Email: sales@psychz.net
  • Services
    • new-colocation-header-img
      Infrastructure
      • iColocation
    • new-compute-header-img
      Compute
      • cMetal
      • cVirtual
    • new-storage-header-img
      Storage
      • sObject
      • sBlock
    • new-networking-header-img
      Networking
      • nCDN
      • nIP Transit
      • nWavelength
    • new-protection-header-img
      Protection
      • pBackup
      • pDDoS
  • Solutions
    • Ecommerce
    • Security
    • Gaming
    • Hosting
    • Management
    • Finance
    • System Integrator
  • Dashboard

How To Find Large files and directories on Linux ?

  • Home
  • Client
  • Qa Forum
  • How To Find Large files and directories on Linux ?

Posted By: Andres | 1 Replies | Last Reply On: Jun 21, 2021 05:12:19

My Ubuntu 18 system is running low on disc space. I want to check which files and folders are eating up maximum disc space.

Psychz - Medha

Votes: 0Posted On: Jun 21, 2021 05:12:19
 

Over time, your disk drive may get cluttered with many unnecessary files taking up large amounts of disk space. Usually, Linux systems run out of disk space due to large log or backup files on the filesystem such as /tmp/ or /var/ or /home/. We will see how to use commands to identify large files and directories on Ubuntu 18 Linux system.

We will be using a combination of three commands using pipes. Let us see how

Steps to find Largest Directories in Linux

du: Estimate file space usage.
sort: Sort lines of text files or given input data.
head: Output the first part of files, i.e., to display the first # largest files. # - you can pass a value in number
find: Search file.

 

How to find out top Directories and files in Linux

Type the following command at the shell prompt to find out the top 10 largest file/directories:

# du -a /var | sort -n -r | head -n 10

Sample outputs:

3129868 /var
2633128 /var/log
2580580 /var/log/journal
2580576 /var/log/journal/148ccab1fd69e38429968ea6df486546
365440 /var/lib
235332 /var/lib/apt
235288 /var/lib/apt/lists
129716 /var/cache
122884 /var/log/journal/148ccab1fd69e38429968ea6df486546/system@dab35793633c410d96ea039f49e41a9a-00000000002286b8-0005c4abe3087a49.journal
122884 /var/log/journal/148ccab1fd69e38429968ea6df486546/system@dab35793633c410d96ea039f49e41a9a-000000000020a1de-0005c49843f2ffd7.journal

For more readable output, use the following combinations of commands.

$ du -hsx * | sort -rh | head -10

Output

2.6G log
357M lib
127M cache
1.5M backups
28K spool
20K www
20K tmp
4.0K snap
4.0K opt
4.0K mail

-h : display sizes in a human-readable format (e.g., 1K, 10M, 5G)
-s : show only a total for each argument (summary)
-x : skip directories on different file systems
-r : reverse the result of comparisons
-h : compare human readable numbers
head -10 : show the first 10 lines.

 

We hope this information helps you in improving your overall experience with Linux operating system.

Was this reply helpful?

Related topics

  • Linux Command for Find Directory
  • How to find a file using find and locate command on Linux?
  • Basic and useful Linux commands
  • Rsync Two Directories
  • Linux Find Commands
  • How to search in Linux?
  • Linux File Permissions Cheat Sheet
  • EasyApache 4: better than ever?
  • How to rsync two directories
  • Deploy Psychz Dedicated Server Using Terraform Provider
  • Upgrade Centos 6 to Centos 7
  • What is Web Hosting?
  • Introducing sObject: The New Object Storage Solution by Psychz Networks
  • Top Useful Features Of Linux Mint
  • Top Myths About Linux Security
Copyright © 2025 Psychz Networks,
A Profuse Solutions Inc Company
Hosting Services
Infrastructure
  • iColocation
Compute
  • cMetal
  • cVirtual
Storage
  • sObject
  • sBlock
Networking
  • nCDN
  • nIP Transit
  • nWavelength
Protection
  • pBackup
  • pDDoS
Company
  • About Us
  • Blog
  • Careers
  • Contact Us
  • Data Centers
  • Looking Glass
  • Network
  • Reseller
Policies
  • Acceptable Usage Policy
  • Privacy Policy
  • Service Level Agreement
  • Terms and Conditions
Support
  • Community
  • Knowledge Base
  • Open A Ticket
Get In Touch
  • Psychz Networks,
    A Profuse Solutions Company
    611 Wilshire Blvd #300
    Los Angeles,California 90017
    USA
  • US/Canada: 800-933-1517
  • International: 626-549-2801