Server and Network Monitoring with iPhone
February 25, 2010 – 6:53 pm | No Comment

What is a Unix sysadmin doing with an iPhone, you ask? It was a birthday present, if that’s all right with you. I know, I should have gotten something odd with a beta version of …

Read the full story »
Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands and Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Files

Find largest files

Submitted by admin on November 19, 2005 – 11:17 pmOne Comment
cd to start point (is acceptable) and as super user run: ls -ailR | sort -rn +5 | more

Sample output under SuSE Linux:

deathstar:/opt # ls -ailR | sort -rn +5 | more
247704 -rwxr-xr-x  1 root root 18330960 Nov 20  2004 oxpsp1.exe
243985 -rwxr-xr-x  1 root root 15516048 Nov 20  2004 oxpsp2.exe
 91951 -r--r--r--  1 root root 14886200 Apr 13  2005 libsvx645li.so
 91952 -r--r--r--  1 root root 13648358 Apr 13  2005 libsw645li.so
96205 -rwxr-xr-x   1 root root 12957520 Sep 13  2004 thunderbird-bin
 91931 -r--r--r--  1 root root 10539873 Apr 13  2005 libsc645li.so
974337 -rwxr-xr-x   1 root root 9771152 Nov  7  2004 firefox-bin
  447 -rwxr-xr-x   1 root root 9004320 Sep 26 14:02 libgklayout.so
 91890 -r--r--r--  1 root root  8576819 Apr 13  2005 libicudata.so.22.0
201928 -rwxr-xr-x   1 root root 6649080 Apr  7  2004 libgucharmap.so.3.0.3

Here’s a Korn shell script that finds largest files on Solaris:

#! /bin/ksh
# igor@krazyworks.com
#
# Use this script to find the largest files in a particular directory.
#
# Variables:
#		$pathname	name of the dir. which to search for large files
 
clear
 
echo "Enter path which to search: \c"
 
read pathname
 
if [ -z $pathname ]
then
	echo "Error: pathname cannot be null! Exiting..."
	exit
fi
 
if [ -d $pathname ]
then
 
clear
 
echo " "
echo "File Owner	File Size	File Date		File Name"
echo "________________________________________"
echo " "
 
du -koda "$pathname" | sort -rn | head -50 | awk '{print $2}' | while read file
do
	if [ -f $file ]
	then
		owner=$(ls -als $file | awk '{print $4}')
		bsize=$(ls -als $file | awk '{print $6}')
		(( fsize = bsize / 1024 /1024 ))
		mdate=$(ls -als $file | awk '{print $7" "$8" "$9}')
		fpath=$(ls -als $file | awk '{print $10" "$11" "$12}')
 
		echo $owner"		"$fsize" Mb		"$mdate"		"$fpath
	fi
done
 
else
 
	echo " "
	echo "Error: '$pathname' - no such directory! Exiting..."
	echo " "
	exit
fi

Sample output of the above script on a Solaris 8 box:

File Owner      File Size       File Date               File Name
_____________________________________________
 
nbar            93 Mb           Nov 21 08:14            /opt/SUNWnbaro/var/nbar/nbjobs.MYI
nbar            60 Mb           Nov 21 08:06            /opt/SUNWnbaro/var/nbar/nbjobfs.MYD
nbar            59 Mb           Nov 21 05:20            /opt/SUNWnbaro/var/nbar/nbwindows.MYI
nbar            50 Mb           Nov 21 08:14            /opt/SUNWnbaro/var/nbar/nbjobs.MYD
nbar            43 Mb           Nov 20 08:16            /opt/SUNWnbaro/var/nbar/nbwindows.MYD
nbar            31 Mb           Nov 21 08:06            /opt/SUNWnbaro/var/nbar/nbjobfs.MYI
nbar            13 Mb           Nov 21 05:20            /opt/SUNWnbaro/var/nbar/nbschedules.MYI
root            13 Mb           May 6 2001              /opt/VRTSob/jre/lib/rt.jar
root            12 Mb           May 11 2001             /opt/VRTSvcs/gui/jre/lib/rt.jar
root            12 Mb           Aug 7 2003              /opt/QLogic_Corporation/SANblade_Control_FX/scfx

Popularity: 19% [?]

Related posts

One Comment »

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.