How To Find Largest Top 10 Files and Directories On Linux / UNIX / BSD

https:/‮ual.www/‬tturi.com
How To Find Largest Top 10 Files and Directories On Linux / UNIX / BSD

To find the largest top 10 files and directories on Linux, UNIX, or BSD, you can use the "du" and "sort" commands. "du" is a command-line utility that allows you to view the sizes of directories and their subdirectories, and "sort" is a command-line utility that allows you to sort the output of a command in various ways.

To find the largest top 10 files and directories, follow these steps:

  1. Change to the directory that you want to search for the largest files and directories. For example, to search for the largest files and directories in the root directory, type the following command:
cd /
  1. Use the "du" command to list the sizes of the directories and their subdirectories. For example:
du -h --max-depth=1

This will list the sizes of the directories and their subdirectories in human-readable format (e.g., "1M" for 1 megabyte), showing only the top-level directories (i.e., with a depth of 1).

  1. Pipe the output of the "du" command to the "sort" command, and use the "-rn" options to sort the output in reverse numerical order. For example:
du -h --max-depth=1 | sort -rn
  1. Use the "head" command to show the top 10 lines of the output. For example:
du -h --max-depth=1 | sort -rn | head -n 10

This will show the largest top 10 files and directories, along with their sizes.

With these steps, you should be able to find the largest top 10 files and directories on your system. Consult the documentation of "du", "sort", and "head" for more information on how to use these utilities.

Created Time:2017-10-28 21:38:51  Author:lautturi