Find All Large Files On A Linux System

The best way to find large files on your Linux system is to use the command line. This how-to will suggest a few methods for listing such files in specific directories or complete file systems.

 

 

Before getting started, we suggest you Learn Linux Basics and follow these precautions.

 

 

Steps to follow

Option 1

This is a basic method for listing files of a certain size. Here we're searching the home directory of the user you're currently logged in as for files greater than 20MB.
find ~ -size +20M

Note: Alternatively, you may search for files less than a certain size by changing the + to a - and may also change the directory path to search.
Option 2a

For more detailed output, we can use find to search directories for files greater than 20MB, display the path and file size. In this example we're searching the entire file system, but you may choose to use a specific path.
find / -type f -size +20M -exec ls -lh {} \; | awk '{ print $NF ": " $5 }'

Option 2b

Find reports errors when it searches directories for which it has no permissions. This is attributed to not having administrative privileges, so you may want to su to root, otherwise, discard these errors by redirecting to /dev/null.

find / -type f -size +20M -exec ls -lh {} \; 2> /dev/null | awk '{ print $NF ": " $5 }'

Option 2c

Additionally, you may find it beneficial to sort (numerically) based on the size (second column).

find / -type f -size +20M -exec ls -lh {} \; 2> /dev/null | awk '{ print $NF ": " $5 }' | sort -nk 2,2

Output will be similar to this:
./Desktop/linuxlookup/.cache/tracker/file-index.db: 24M
./.mozilla/firefox/z65ywy3s.default/places.sqlite: 43M
./Desktop/linuxlookup/.evolution/mail/local/Inbox.sbd/ll: 98M
./Desktop/linuxlookup/dev/security-report.tar: 140M
..
Option 2d

Or reverse the sort order (larger files listed first) by using this.

find / -type f -size +20000k -exec ls -lh {} \; 2> /dev/null | awk '{ print $NF ": " $5 }' | sort -nrk 2,2

0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
Learn Linux System Auditing with Auditd Tool on CentOS/RHEL
Viewed 2403 times since Fri, Apr 5, 2019
RHEL: Building a custom kernel on RHEL 6
Viewed 1699 times since Sat, Jun 2, 2018
RHEL: Extending the maximum inode count on a ext2/ext3/ext4 filesystem
Viewed 1770 times since Sun, May 27, 2018
stunnel Howto A Guide to create SSL access to a HTTP-only webserver with stunnel
Viewed 1186 times since Fri, Sep 28, 2018
HowTo: The Ultimate Logrotate Command Tutorial with 10 Examples
Viewed 2689 times since Fri, Nov 30, 2018
RHCS6: Mirror/unmirror a GFS2 volume
Viewed 3992 times since Sun, Jun 3, 2018
ZFS: Verify/change properties of a zfs filesystem
Viewed 1501 times since Sun, Jun 3, 2018
RHEL: Remove existing SAN LUNs
Viewed 12612 times since Sat, Jun 2, 2018
ubuntu How to reset lost root password on Ubuntu 16.04 Xenial Xerus Linux
Viewed 6886 times since Tue, Dec 8, 2020
RHEL: Allowing users to ’su’ to "root" / Allowing ’root’ to login directly to the system using ’ssh’
Viewed 1512 times since Sat, Jun 2, 2018