Find et du pour trouver des gros fichiers et gros dossiers
From Deimos.fr / Bloc Notes Informatique
1 Finding Large Directories
To find large directories, use the du command and sort the output.
For example, to output the 10 largest directories in /var, sorted in ascending size order, use the following command:
du |
du -ko /var |
To avoid crossing file system boundaries, that is, to see the directory usage in / but not in the other mounted files systems (/var, /opt, and so on), add the d option to the du command:
du |
du -kod /var |
2 Finding Large Files
To find large files, use the find command and sort the output.
- Example 1: To find all plain files (not block, character, symbolic links, and so on) in a file system larger than 200,000 512-byte blocks (approximately 100 Mbytes) and sort on field 7 (file size) while numerically ignoring leading blanks, do this:
find |
find / -size +200000 -type f -ls |
- Example 2: To find all plain files (not block, character, symbolic links, and so on) in a /var file system larger than 1,000 512-byte blocks (approximately 500 Kbytes) and sort on field 7 (file size) while numerically ignoring leading blanks, do this:
find |
find /var -size +1000 -type f -ls |