Cand nu mai aveti spatiu pe disc, puteti sa verificati cu comanda df sau cu comanda ncdu, dar toate acestea nu arata fisiere mari din sistem.
Deci, vreau sa obtin cele mai mari 10 fisiere din sistem. In acest tutorial, va vom invata cum sa gasiti cele mai mari 10 fisiere din sistemul Linux folosind patru metode.
# find / -type f -print0 | xargs -0 du -h | sort -rh | head -n 101.4G /swapfile 1.1G /home/john/ubuntu-17.04-desktop-amd64.iso 564M /home/john/.gdfuse/magi/cache/0B5nso_FPaZFqTFU0XzkzUlJUZzA 378M /home/john/.gdfuse/magi/cache/0B5nso_FPaZFqeldzUmhPeC03Zm8 377M /home/john/.gdfuse/magi/cache/0B5nso_FPaZFqRGd4V0VrOXM4YVU 100M /usr/lib/x86_64-linux-gnu/libOxideQtCore.so.0 93M /usr/lib/firefox/libxul.so 84M /var/lib/snapd/snaps/core_3604.snap 84M /var/lib/snapd/snaps/core_3440.snap 84M /var/lib/snapd/snaps/core_3247.snap
# find / -type f -exec du -Sh {} + | sort -rh | head -n 101.4G /swapfile
1.1G /home/john/ubuntu-17.04-desktop-amd64.iso
564M /home/john/.gdfuse/magi/cache/0B5nso_FPaZFqTFU0XzkzUlJUZzA
378M /home/john/.gdfuse/magi/cache/0B5nso_FPaZFqeldzUmhPeC03Zm8
377M /home/john/.gdfuse/magi/cache/0B5nso_FPaZFqRGd4V0VrOXM4YVU
100M /usr/lib/x86_64-linux-gnu/libOxideQtCore.so.0
93M /usr/lib/firefox/libxul.so
84M /var/lib/snapd/snaps/core_3604.snap
84M /var/lib/snapd/snaps/core_3440.snap
84M /var/lib/snapd/snaps/core_3247.snap
# find / -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}84M /var/lib/snapd/snaps/core_3247.snap
84M /var/lib/snapd/snaps/core_3440.snap
84M /var/lib/snapd/snaps/core_3604.snap
93M /usr/lib/firefox/libxul.so
100M /usr/lib/x86_64-linux-gnu/libOxideQtCore.so.0
377M /home/john/.gdfuse/magi/cache/0B5nso_FPaZFqRGd4V0VrOXM4YVU
378M /home/john/.gdfuse/magi/cache/0B5nso_FPaZFqeldzUmhPeC03Zm8
564M /home/john/.gdfuse/magi/cache/0B5nso_FPaZFqTFU0XzkzUlJUZzA
1.1G /home/john/ubuntu-17.04-desktop-amd64.iso
1.4G /swapfile
# find / -type f -ls | sort -k 7 -r -n | head -10 | column -t | awk '{print $7,$11}'1494845440 /swapfile
1085984380 /home/john/ubuntu-17.04-desktop-amd64.iso
591003648 /home/john/.gdfuse/magi/cache/0B5nso_FPaZFqTFU0XzkzUlJUZzA
395770383 /home/john/.gdfuse/magi/cache/0B5nso_FPaZFqeldzUmhPeC03Zm8
394891761 /home/john/.gdfuse/magi/cache/0B5nso_FPaZFqRGd4V0VrOXM4YVU
103999072 /usr/lib/x86_64-linux-gnu/libOxideQtCore.so.0
97356256 /usr/lib/firefox/libxul.so
87896064 /var/lib/snapd/snaps/core_3604.snap
87793664 /var/lib/snapd/snaps/core_3440.snap
87089152 /var/lib/snapd/snaps/core_3247.snap
Legenda (engleza):
find : It’s a command, search for files in a directory hierarchy.
/ : Check in the whole system (starting from / directory)
-type : File is of typef : Regular file
-print0 : Print the full file name on the standard output, followed by a null character
| : Control operator that send the output of one program to another program for further processing.
xargs : It’s a command, which build and execute command lines from standard input.
-0 : Input items are terminated by a null character instead of by whitespace
du -h : It’s a command to calculate disk usage with human readable format
sort : It’s a command, Sort lines of text files
-r : Reverse the result of comparisons
-h : Print the output with human readable format
head : It’s a command, Output the first part of files
n -10 : Print the first 10 files.
cut : It’s a command, remove sections from each line of files
-f2 : Select only these fields value.
-I{} : Replace occurrences of replace-str in the initial-arguments with names read from standard input.
column : It’s a command, formats its input into multiple columns.
-t : Determine the number of columns the input contains and create a table.
awk : It’s a command, Pattern scanning and processing language
'{print $7,$11}' : Print only mentioned column.