Finding large files:

Suppose we are facing a disk space issue in one system user directory and we want to find out which files are using most of the disk space, we can run the following command to find it out:

<36 SMSC :/export/home2/mml/tmp> find /export/home2/mml/ -size +400000| sort –r| head –3


The command found out 3 core files for us. Let’s see what’s their space.

<38 itellin2 :/export/home2/mml/sms/bin>ls –l | grep core

-rw——-   1 mml  mml      486457128 Dec  4 10:53 core_20101204105309_5074

-rw——-   1 mml  mml      486104872 Dec 31 11:58 core_20101231115847_13489

-rw——-   1 mml  mml      486244136 Jan 19 15:29 core_20110119152929_14771

So, we found our top disk utilizing files with sizes more than 400MB. The core files are produced by the application when there is some exception in the program. These files help out in troubleshooting the actual problem. As the files are not dependent on some program, you can take their backup and remove them.

To find the files in a specific range, we can mention the size twice. Suppose we want to find top 10 disk utilizing files with sizes in the range of 400MB ~ 600MB, you can use the following command:

<36 SMSC :/export/home2/mml/tmp> find /export/home2/mml/ -size +400000 -size -600000| sort -r| head -10

Finding large directories:

To find large directories, use ‘du’ command. The command is given as follows:

SUNOS$ du -sk /usr/*
4            /usr/X11R6
97664     /usr/bin
24         /usr/games
11628    /usr/include
167812  /usr/lib
0         /usr/lib64
96      /usr/local
25076     /usr/sbin
201500  /usr/share
4        /usr/src

The –s option allows the command to search only for the results matching /usr/* and not their subdirectories. The k option is used to display the results in KBs. You can use the h option to make the output more readable.

SUNOS$ du -sh /usr/*
4.0K    /usr/X11R6
96M     /usr/bin
24K     /usr/games
12M     /usr/include
164M    /usr/lib
0       /usr/lib64
96K     /usr/local
25M     /usr/sbin
197M    /usr/share
4.0K    /usr/src

Adnan Khurshid

Adnan Khurshid, the author of this article, has been working in a telecommunication sector since 2007. He has worked there as a VAS (Value Added Services) engineer and has excelled remarkably in the field. Working in this field has been his passion and he has always made efforts to keep himself up to date. Find more about him on LinkedIn

More Posts

Tags: , , ,

Leave a Reply