How to Find Large Files in Ubuntu

  • Post category:Ubuntu

Managing disk space effectively is crucial for any Linux user, especially when working on limited storage. Finding large files can help you reclaim valuable space and improve system performance. In this guide, we will explore various command-line tools and techniques to find large files in Ubuntu.

1. Using the find Command

The find command is a powerful tool for searching files and directories in Linux.

Find Files Larger Than 100MB

To search for files larger than 100MB in your entire filesystem, run:

find / -type f -size +100M

You can replace / with a specific directory path to limit the search.

Find Files Larger Than 10GB

To find files larger than 10GB, use:

sudo find / -type f -size +10G 2> /dev/null

The 2> /dev/null part suppresses error messages about directories that you cannot access.

2. Using the du Command

The du (Disk Usage) command provides information about disk space used by files and directories.

List the Largest Files

To list the top 20 largest files and directories in human-readable format, sorted by size, use:

sudo du -ah / | sort -rh | head -n 20

3. Using ncdu

ncdu (NCurses Disk Usage) is an interactive tool that provides a visual representation of disk usage.

Install ncdu

First, install ncdu by running:

sudo apt install ncdu

Run ncdu

To scan your filesystem and navigate through directories to find large files, execute:

ncdu /

4. Using ls

For a quick overview of file sizes in a specific directory, you can use:

ls -lhS | head -n 10

This command lists the top ten largest files in the current directory sorted by size.

Conclusion

These methods allow you to efficiently locate large files on your Ubuntu system, helping you manage disk space effectively. Whether you prefer command-line tools or interactive interfaces, you can choose the method that best suits your needs. For more helpful tips and guides on Ubuntu, check out other articles on CodeAllow.