Home Learn Linux 5 ways to find large files in Linux

5 ways to find large files in Linux

Large files can quickly consume disk space and potentially impact Linux system performance. Learn five efficient techniques to identify these files, ensuring your system remains streamlined and responsive.

by Divya Kiran Kumar
Published: Last Updated on
find large files in linux

Greetings, FOSSLinux enthusiasts! As a seasoned user, I have come across a common issue that plagues many of us – the presence of large, unwanted files that take up precious storage space on our systems. To address this problem, I have created a comprehensive guide that provides insights into how to identify these files and remove them with ease.

As someone who has dealt with this issue numerous times, I know how frustrating it can be to locate these files. However, with the help of these five methods, you will be able to navigate and manage your files with ease. With a little guidance and a bit of patience, you can say goodbye to those pesky, large files and enjoy a clutter-free system.

5 ways to find large files in Linux

Command/Tool Description
du Traditional command used to measure disk usage, often combined with sort for enhanced readability.
ncdu A visually-appealing, interactive tool that presents a user-friendly interface to analyze disk usage.
find A versatile command capable of locating files not only by name and type, but also by size.
baobab (Disk Usage Analyzer) A graphical method that visually represents disk usage, enabling easy identification of large files and directories.
ls A basic command primarily used for listing files, but can be creatively used to highlight large files when combined with specific options.

Let’s go into the details of each of these commands.

1. The classic du command

Ah, the du command – my old and reliable friend. It stands for “disk usage” and is an age-old tool for gauging the size of directories and files.

General Syntax:

du [OPTIONS] [FILE…]

Tip: Pair it with the sort command to order the output by size.

Sample command:

du -h /path/to/directory | sort -rh | head -n 10

Output:

1.5G /path/to/large/file1
1.2G /path/to/large/file2
900M /path/to/large/file3
...

This combination sorts the output in reverse order, showcasing the top 10 heaviest items. Although du is a classic, I sometimes wish it was a tad quicker.

2. The nifty ncdu tool

Enter ncdu, a more visual, and in my opinion, neater method than its predecessor. This tool presents a user-friendly interface to analyze disk usage. It’s like du on steroids!

Installation (For Debian-based systems):

sudo apt install ncdu

General syntax:

ncdu [OPTIONS] [DIRECTORY…]

Sample command:

ncdu /path/to/directory

You’ll be presented with an interactive interface, detailing the sizes of files and directories. It’s incredibly intuitive, making it one of my top choices when I want to navigate through directories.

3. Harnessing the power of find

The find command, versatile as ever, is a lifesaver. Not only can it locate files based on criteria like name and type, but also by size!

General syntax:

find [PATH…] [EXPRESSION]

Sample command:

find /path/to/directory -type f -size +100M

Output:

/path/to/large/file1
/path/to/large/file2
...

The above command pinpoints files larger than 100 MB. You can tweak the size as per your needs. The only downside? The sheer versatility of find means there’s a steeper learning curve, but oh, the power it wields!

4. The intriguing baobab tool

Also known as Disk Usage Analyzer, baobab is a graphical way to visualize disk usage, letting you quickly identify large files and directories. It’s like taking a visual tour of your filesystem.

Installation (For Debian-based systems):

sudo apt install baobab

General syntax: Just launch baobab!

Sample command:

baobab
baobab command usage in linux

baobab command usage in linux

You’ll be greeted with a colorful graphical representation of your directories and files, making it simpler to pinpoint those size-consuming entities. I love the aesthetic touch of baobab, although I do find myself leaning more towards command-line methods out of habit.

5. Peeking with ls

Last but certainly not least, the humble ls command. While primarily used for listing files, with a little creativity, it can aid in our quest.

General syntax:

ls [OPTION]… [FILE]…

Sample command:

ls -lhS /path/to/directory | head -n 10

Output:

-rw-r--r-- 1 user user 1.5G Sep 29  2023 large_file1
-rw-r--r-- 1 user user 1.2G Sep 28  2023 large_file2
...

The -S option ensures the list is sorted by file size, with the heaviest ones appearing first. While ls is elementary, its simplicity is its charm. It’s like a trusty old knife in my Linux toolbox.

Conclusion

As we delved into the world of Linux, we discovered five powerful and effective methods to help us identify large files that might be consuming valuable space on our systems. These methods include the traditional du command, the visually impressive ncdu, the versatile find command, the graphical wonder baobab, and the evergreen ls. Each method has its unique capabilities and features that make it perfect for managing disk space. Whether you prefer using a command-line interface or a graphical user interface, Linux has got you covered with the appropriate tool for your preference. Let’s continue exploring the vast world of Linux and never lose sight of what we are searching for!

You may also like

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.