Followers

Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Wednesday, January 14, 2015

Find the Hostname with IPAddress

[test@srinfosoa01 logs]$ nslookup srinfosoa01
Server:         128.166.33.44
Address:        128.166.33.44#53



nslookup 208.77.188.166 
...
Non-authoritative answer:

166.188.77.208.in-addr.arpa     name = www.example.com.

Thursday, October 23, 2014

delete files before n days in the folder

find * -mtime +n -exec rm {} \;

n=1 before 1 day

n=2 before 2 days

n=7 before 7 days

Wednesday, October 8, 2014

Vi Search and Replace Commands

Vi: Search and Replace

Change to normal mode with <ESC>.
Search (Wrapped around at end of file):
  Search STRING forward :   / STRING.
  Search STRING backward:   ? STRING.

  Repeat search:   n
  Repeat search in opposite direction:  N  (SHIFT-n)

Replace: Same as with sed, Replace OLD with NEW:

 First occurrence on current line:      :s/OLD/NEW
  
 Globally (all) on current line:        :s/OLD/NEW/g 

 Between two lines #,#:                 :#,#s/OLD/NEW/g
  
 Every occurrence in file:              :%s/OLD/NEW/g 

Saturday, July 5, 2014

find out top 10 largest file/directories

To find  top 10 largest file/directories


du -a /opt/middleware | sort -n -r | head -n 10

 more human readable output try:
$ du -hsx * | sort -rh | head -10

Tuesday, July 1, 2014

Alert for diskspace in Weblogic Environemnts

#!/bin/bash
#admin email account
ADMIN="madhuchilipi@gmail.com"
# set usage alert threshold
THRESHOLD=10

#hostname
HOSTNAME=$(hostname)

#mail client
MAIL=/usr/bin/mail

# store all disk info here
EMAIL="/l01/apps/oracle"

for line in $(df -hP | egrep '^/l01/apps/oracle' | awk '{ print $6 "_:_" $5 }')
do
part=$(echo "$line" | awk -F"_:_" '{ print $1 }')
part_usage=$(echo "$line" | awk -F"_:_" '{ print $2 }' | cut -d'%' -f1 )

if [ $part_usage -ge $THRESHOLD -a -z "$EMAIL" ];
then
EMAIL="$(date): Running out of diskspace on $HOSTNAME\n"
EMAIL="$EMAIL\n$part ($part_usage%) >= (Threshold = $THRESHOLD%)"

elif [ $part_usage -ge $THRESHOLD ];
then
EMAIL="$EMAIL\n$part ($part_usage%) >= (Threshold = $THRESHOLD%)"
fi
done 

if [ -n "$EMAIL" ];
then 
echo -e "$EMAIL" | $MAIL -s "Alert: Partition(s) almost out of diskspace on $HOSTNAME" "$ADMIN"
fi