•  Home
  •  Dashboard
  •  Company
    • About Us
    • Blog
    • Careers
    • Contact Us
    • Data Centers
    • Looking Glass
    • Network
    • Reseller
  •  Hosting Services
    • Backup
    • Content Delivery Network
    • Colocation Hosting
    • Dedicated Hosting
    • DDoS Mitigation
    • IP Transit
    • Private Cloud
    • Wavelength
  •  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
    • Dedicated Servers
    • Colocation
    • Private Cloud
    • DDos Protection
    • IP Transit
    • CDN
    • Backup
  • 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

  • Basic and useful Linux commands
  • Linux Command for Find Directory
  • How to find a file using find and locate command on Linux?
  • Rsync Two Directories
  • Linux Find Commands
  • How to search in Linux?
  • EasyApache 4: better than ever?
  • Linux File Permissions Cheat Sheet
  • Top Useful Features Of Linux Mint
  • How to rsync two directories
  • Top Myths About Linux Security
  • Scientific Linux and its features
  • Upgrade Centos 6 to Centos 7
  • What is Web Hosting?
  • Learn About Colocation Benefits And How To Get Started
Hosting Services
  • Dedicated Hosting
  • Colocation Hosting
  • Backup
  • IP Transit
  • DDoS Mitigation
Support
  • Portal Login
  • Knowledgebase
  • Community
Company
  • About Us
  • Contact Us
  • Network
  • Data Centers
  • Looking Glass
  • Affiliates
  • Reseller
  • Blog
Policies
  • Privacy Policy
  • Acceptable Usage Policy
  • Terms and Conditions
  • Service Level Agreement
Company
  • Psychz Networks,
    A Profuse Solutions Company
    611 Wilshire Blvd #300
    Los Angeles,California 90017
    USA
  • US/Canada: 800-933-1517
  • International: 626-549-2801
Subscribe to Our Mailing List
* indicates required
Copyright © 2023 Psychz Networks, A Profuse Solutions Inc Company