Sunday, November 4, 2012

Solaris / Linux Useful Commands - Part 1

Solaris / Linux Useful Commands - Part 1

Find & List Archive files older than 1 day
find ./ -name "*.ARC" -mtime +1 -exec ls -l {} \;


Find and remove Archive files older than 1 day
find ./ -name "*.ARC" -mtime +1 -exec rm {} \;


Find and zip archive files older than 1 day
find ./ -name "*.ARC" -mtime +1 -exec gzip {} \;


Find and move archive files older than 1 day
find ./ -name "*.arch" -mtime +1 -exec mv {} /u01/andy/;

 
Delete the 500 oldest files
rm -f `ls -tr|head -500`

 
Find and grep
find ./ -grep <what> {} \; -print 2>/dev/null


Or...
find ./ -exec grep -l "string" {} \;

 
list all files opened by a process
lsof -p <pid>

 
List and sorted by size
ls -l |sort -k 5

Sum and sort files for size
du -sk *|sort -n

 
cpio unzip syntax
cpio -idmv < <filename>

 
man commands
man -k <what> -displays the chapters containing the specified
man <chapter> <what> -shows the page

 
pipes
mknod <name> p

 
Turn off auto indent and bracket matching in vi
:set noai nosm

 
Capture a control
ctl-v then press the control key (eg. backspace)

Configure ksh environment
To display the current settings
set -o
set -o

To set HP/UX stylee...
set -o vi
 
Show routing tables
netstat -r

 
Check all logs for ORA- errors
grep ^ORA- *log |cut -f2 -d"-"|cut -f1 -d:|awk '{print "ORA-" $1}'|sort -u

#dtterm -bg white -fn <fontset>
Kill all the oracle processes
# ps -fu oracle| awk '{print "kill -9 " $2}' > /tmp/kill.sh

Setting the VT terminal
setenv TERM vt100

No comments:

Post a Comment