+1 vote
in Operating Systems by (64.6k points)
I want to find the top 3 largest files on my Ubuntu machine. How can I do it using the Linux command? Is there any command for it?

1 Answer

+2 votes
by (86.3k points)
selected by
 
Best answer

To find the largest file(s) on Ubuntu, you can use the "find" command in combination with the "du", "sort", and "head" commands.

Here is an example:

sudo find / -type f -exec du -h {} + | sort -rh | head -n 3

The above command will return top 3 largest files on your system.

  • /: Searches the entire filesystem. Replace / with a specific directory (e.g., /home).
  • -type f: Only finds files (not directories).
  • -exec du -h {} +: Displays the file size in human-readable format.
  • sort -rh: Sorts the files in descending order by size.
  • head -n 3: Limits the output to the 3 largest files.

...