There are basically two methods by which you can find large files on your Linux system. The first is by typing commands in the terminal, which will provide you with information regarding large files in the form of text. Then there is the GUI method, which involves using programs that have a graphical interface and can show you how large files are using the storage on your system graphically.
Using terminal commands
The fastest and most efficient way of finding large files on Linux is via the terminal. There are different commands that you can use depending on which files you are looking for.
Method 1: Find the largest files in a directory
You can easily find the ten largest files in Linux using the du
command.
Open the terminal and type du
and then you can follow it up with an argument like -ah/directory/name
.
If you wish to find the largest files in the current directory, use the command without the directory name. Also, you can use any other number instead of 10 depending on how many large files you want to see.
Method 2: Find the largest files in the system
You can also use the du
command to find the largest files on your system.
Open the terminal and type sudo du -aBm / 2>/dev/null
and press Enter.
You will need to use sudo
in this case, since the command will look for the largest files in all the directories, which requires root privileges. Also, because it will search through all the directories, the command can take some time to run.
Method 3: Find a specific number of the largest files in a directory
To find the ten largest files in a directory, you can use the find
command.
Type find /directory/name -type f -exec ls -sh {} \;
and then press Enter.
This will show you the ten largest files in the current directory along with their sizes. You can change the number of files you want to see and you can search for all the largest files in the current directory by replacing the directory name with .
or excluding it altogether.
Method 4: Look for files over a certain size in a directory
You can also find files exceeding a certain size in Linux with the command find /directory/name -type f -size
.
For instance, you can find all the files exceeding 500 MB by typing find /directory/name -type f -size +500M
. You can replace 500 with any other size and replace the directory name with .
to search the current directory.
Method 5: Find files above a certain size across the system
The sudo find / -type f -size +500M -ls
command lets you search for files exceeding a certain size on the entire Linux system.
All files that are more than 500 MB in size will show up when you type in this command, along with their permissions, owners, and sizes.
Method 6: View file systems using the most space
If you want to view the percentage of the total disk space that each mounted file system is using, you can use the df -h
command.
Using GUI programs
If you are not comfortable using terminal commands, Linux has several GUI-based programs that allow you to find the largest files on your system.
Filelight
You can install Filelight by typing sudo apt install filelight
in the terminal and pressing Enter. Or open your package manager and search for it there.
Once installed, launch Filelight and it will show you all the large files on your system.
QDirStat
QDirStat is another GUI-based application that provides information about large files on your system graphically.
If you're using Debian, Ubuntu, or any distros based on those, use the sudo apt install qdirstat
command to install the program.
On the other hand, if you're using Redhat, Fedora, or distros based on those, use sudo dnf install qdirstat
. Once the program is installed, open it and select any directory to view all large files inside it.
Things to know
- The terminal commands to view large files may vary depending on which Linux distro you are using, so make sure to check which commands work for your system.
- Try running commands without
sudo
as far as possible, since that will keep your system protected. Only usesudo
in cases where you cannot run a command without root privileges. - Depending on the number of files and their sizes as well as how you have organized the file system, it can take some time for the commands or GUI programs to show you the files that are using up your storage.
Member discussion