Finding Large Files and Directories in the Solaris OS

How to Find Large Files and Directories in the Solaris OS

by Ross Moffatt, July 2008

This tech tip shows how to find large directories and files that are taking up space in a file system in the Solaris Operating System.

Note: This procedure works on Solaris versions up to and including Solaris 9. It should work on systems that run the Solaris 10 OS, but that was not tested.

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 -ko /var|sort -n | tail -10

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 -kod /var|sort -n | tail -10
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 / -size +200000 -type f -ls | sort -k 7,7 -n

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 /var -size +1000 -type f -ls | sort -k 7,7 -n
About the Author

Ross Moffatt has been a UNIX system administrator for 10+ years and can be contacted at ross.stuff@telstra.com.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact