How to find large files in Linux Ubuntu

Open a terminal and enter the following command to find Ubuntu system in the top 10 largest files / directories:

Output is as follows:

7090664 / var
5138960 / var / lib
2567616 / var / lib / snapd
1926716 / var / lib / flatpak
1429988 / var / lib / flatpak / runtime
1343624 / var / lib / snapd / liquor
1121636 / var / lib / flatpak / runtime / org.gnome.Platform
1121632 /var/lib/flatpak/runtime/org.gnome.Platform/x86_64
1035888 / var / log
885952 /var/lib/flatpak/runtime/org.gnome.Platform/x86_64/3.36

How to find large files in Linux Ubuntu

In the above command, the options for estimating du space usage file, a text file or data to a given input row if the sort order, and for outputting a first portion of the file (i.e., the n largest display file / directory) options. n is a numeric string comparison, r is the result inversion display.

It is difficult to interpret the number sign documents. Therefore, to make the output more readable this command, try the following command:

Output is as follows:

How to find large files in Linux Ubuntu

You can also use the above command to find the top 10 files in the directory. To use this command, first change the directory, and then use the command.

cd /path/to/directory

du -hsx * | sort -rh | head -10

Run the following command in a terminal to find out / home folder partition maximum of the first 10 files and directories:

root@linux:/home# sudo du -a /home | sort -n -r | head -n 10

Output is as follows:

How to find large files in Linux Ubuntu

Similarly, if you want to find the current working directory in the 10 largest directory, run the following command:

sudo du -a | sort -n -r | head -n 10

Let us understand the command:

du -h command options: Displays the file size in human readable format to KB, Megabytes and Gigabytes units.

du command -s option: the total number of each parameter display.

du command -x option: Skip directory. (If different file systems)

sort command -r option: reverse comparison.

sort command -h option: comparative figures.

-10 OR -n 10 head command options: the first 10 lines of output.

Please note that the above command only GNU (installed by default sort) valid. For other Unix systems, use the following command:

for i in G M K; do du -ah | grep [0-9]$i | sort -nr -k 1; done | head -n 11

Find the top 10 largest files and directories consume disk space

You can use the sort command to find consume the top 10 largest files and directories disk space.

alias ducks='du -cks * | sort -rn | head'

Now run the following command to obtain occupy the first 10 maximum disk space the files and directories in the Ubuntu system:

How to find large files in Linux Ubuntu

Guess you like

Origin www.linuxidc.com/Linux/2020-03/162758.htm