![]()
|
SysAdmin Topics
|
How to Find Large Files and Directories in the Solaris OSby 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 DirectoriesTo 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 FilesTo 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 AuthorRoss Moffatt has been a UNIX system administrator for 10+ years and can be contacted at ross.stuff@telstra.com. |