Some more useful Unix commands and scrtipts

Find files modified in the last X days

find . -name “*” -mtime –X -ls|more

Find the largest files on the current filesystem:

AIX:        find . -xdev -ls | sort +7 -nr | head -20

LINUX:    find . -type f -size +20M -exec ls -lh {} \; | awk ‘{ print $NF “: ” $5 }’

Solaris  listing process with full classpath

/usr/ucb/ps -auxww

Sed command to delete a string from a file

sed -i ‘/STRING_TO_DELETE/d’ file.txt

Delete lines not containing a specific pattern

sed -i ‘/[a-z]*[0-9]\-[a-z]/!d’ file

Delete lines not starting with a specific pattern

sed -i ‘/^[a-z]*[0-9]\-[a-z]/!d’ file

Linux process memory occupied

ps -Ao rsz,vsz,cmd|grep java

Test website response time


for I in `seq 1 30`


(time curl -k ‘ > /dev/null ) 2>&1 | egrep real


Curl oneliners to get http response code and underlying URL

curl -sL -w “%{http_code} %{url_effective}\n” “url/param1/param2” -o /dev/null

curl –header “Host:”  -sL -w “%{http_code} %{url_effective}\n” “servername:8173” -o /dev/null

curl -sL -w “%{http_code} %{url_effective}\\n” “server_name:9173/param1/param2” -o /dev/null

Faking the userAgent

Doing it via curl:

curl -k -L -A “Googlebot/2.1 (+”

Doing it manually in Firefox browser:

go to about:config

and create this new key value pair


Mozilla/5.0 (compatible; Googlebot/2.1; +

Following script snippet to extact certain values from an httpd.conf file –of IBM HTTP Server

while read filename


version=`head -1 $filename | grep -o “IHS [0-9].[0-9]”`

string=`egrep “MaxClients|ServerLimit|ThreadsPerChild|ThreadLimit|MinSpareThreads|MaxSpareThreads” $filename |grep -v ‘#’|tr  ‘\012\015’ ‘|’`

if [ $string = “” ]


string=”No worker module section”


echo $filename “|” $version “|” $string;

done < top_10_httpd.txt

egrep “MaxClients|ServerLimit|ThreadsPerChild|ThreadLimit|MinSpareThreads|MaxSpareThreads” httpd.conf |grep -v ‘#’|tr  ‘\012\015’ ‘|’`

egrep “MaxClients|ServerLimit|ThreadsPerChild|ThreadLimit|MinSpareThreads|MaxSpareThreads” httpd.conf|grep -v ‘#’

for filename in `cat top_10_plugin.txt`; do awk ‘/\<Server\ CloneID\=/ {print FILENAME,$2,$3,$5,$7}’ $filename >> out.txt; done

awk ‘/\<Config\ ASDisableNagle\=/ {print FILENAME,$2,$3,$5,$7}’

Disk Usage command and sort

du -sm * |sort -nr |more

du -sh * |sort -nr |more

IBM HTTP Server: Modify the WSSN and WSSP variables to fool the WAS app server that the request is actually coming from IHS

wget –header=’$WSSN:HOST-IP’ –header=’$WSSP:80′ WAS_Server:DEFAULT_HOST_PORT/appurl

wget WAS_Server:DEFAULT_HOST_PORT/appurl- hitting the app directly on app server – but the port is taken off the Virtual Host config on WAS.

Find out what process is using a specific port – very useful during port conflicts when starting jvms

netstat -Ana|grep LISTEN|grep 9633  #Gives out the socket name

rmsock  f1000e000019cbb8 tcpcb         #give the processid thats using it.

List files in a filesystem that have been ‘deleted’ but still take space on the file system due to a process holding them open

fuser -dV /tmp                   #That will show all Column 2 is the size, column 4 is the PID.

istat                                       #can tell you when it was last update/modified/accessed



AIX Resource Group Application Monitoring

/usr/local/bin/appmon_cntrl –a stop –r all

/usr/local/bin/appmon_cntrl –a check –r all

EBCIDC to ASCII Conversion

dd if=inputfilename cbs=170 conv=ascii | head -n 100

Linux free memory commands

vmstat -s

free -m



LINUX Process Listing

ps -aefww

Linux file encoding

file -bi filename

Linux command – list all os packages / YUM commands

rpm -qa

rpm -qa –last | head -30

rpm -qf `which htpasswd`

yum –enablerepo=fil-custom-rhel6_64 list | grep -i was

Password less entry – copy ssh gen key

ssh-keygen #dont type in password when prompted

ssh-copy-id -i /home/USER/.ssh/ $host

Copy ssh to remote server

while read host;


echo “——–“;

echo “now copying to host $host”;

ssh-copy-id -i /home/USER/.ssh/ $host;

done < hosts.txt.p

Rsync – change permission of file while scp

rsync –chmod=u+rwx,g+rx,o+rx $FILE_TO_SEND a560055@$dest:/tmp/

WAS – get a list of the name spaces:

./ -port 50487 -root node -report long