Tuesday, September 4, 2012

All About Unix commands


Find Large Files on Solaris file system
du -k * | sort -n | tail -10
du -ka | sort -nrk1 | tail -10
find /dirname * -size +82100 -print --in kb

Processes ordered by memory usage
ps -eo pcpu,pmem,args | sort -k 2 -n
prstat -a -s rss
You can see how much ram is used by all processes by using the "prstat -a" option.
You can display how much free RAM is available by looking at the vmstat "free" column.

Find files with date.
find /opt/esb/app/stg/esb/log "*.log" -mtime -38 -mtime +6 -print -- will give 1 month files
find /opt/esb/app/stg/esb/log "*.log" -mtime -38 -print | zip source -@
find . -mtime -38 -mtime +7 -ls

Find the files older then 10 days
find . -type f -mtime +10 -exec ls -lrt {} \;

Find file with extension
find . -name "*.log.?" -exec ls -lrt {} \;

Remove File
find . -name "*.log.?" -exec rm {} \;
find . -type f -mtime +10 -exec rm -rf {} \;

Greping from many files and sending mail
grep "\"stg01gh0*\" is dead" 20091107.log -atime/-ctime/-mtime" [+|-]n
-- the last time a files's "access time", "file status" and "modification time".
grep "is dead" `find . -mtime -38 -mtime +6` | grep stg01* | mailx -s "STG01 Bounce Log" kuldeepsingh@xyz.com

Finding all the instances of the text "applicationX" and replacing all instances with the text "applicationY"
find /path/to/start/from/ -type f | xargs perl -pi -e 's/applicationX/applicationY/g'

Find a text in subdir. (deep search)
find . -type f -print |xargs grep "BIADMIN"   - gives file path and full line text from file
find . -name *.* | xargs grep pvttap03        - gives file path and full line text from file
find . -type f -exec grep -il "pvttap03" {} \;  - gives only file names
find . -type f -name "*.properties" -exec grep -il "pvttap03" {} \; - find for specific extention, gives only file names

Using JAR Command.

Creating JAR Files
jar -cvf my_help.jar *
Listing JAR Files
jar -tvf my_help.jar
Extracting Files from JAR Files
jar -xvf my_help.jar
jar -xvf coresv-4.0.jar com/cfluent/gateway/sdk/service/MessengerStep.class
Adding files back to jar.
jar -uvf coresv-4.0.jar com/cfluent/gateway/util/XmlSoapWrapper.class


OOM Cmd
cd $ORACLE_HOME/opmn/logs;ls -lrt;grep -i OutOf default_group~oc4j_soa~default_group~1.log
cd $ORACLE_HOME/j2ee/oc4j_soa/log/oc4j_soa_default_group_1/oc4j;ls -lrt;grep -i OutOf log.xml
cd $ORACLE_HOME/opmn/logs ; ls -lrt oc4j_soa_heapdump*

How to install a software on HP-UX with example of less utility

1. Download depot file from below site
http://hpux.connect.org.uk/hppd/auto/summary_all.html
2. gunzip less-444-ia64-11.31.depot.gz
3. cp less-444-ia64-11.31.depot /tmp
4. swinstall -s /tmp/less-444-ia64-11.31.depot



How to extract CPIO file on Unix (HP-UX)

cpio -idcmv
How to copy a file from one server to another server by scp command

# Use -r for directory copy
# Use -p for copying a file from one server to another while you on destination server prompt.
scp user_name@server_name:<dest_dir_path/>

#Directory Copy
scp -r /u01/system/files/reports/ user_name@ttytest01:/u01/app/oracle/Reports/

#File Copy
scp -r /u01/system/files/reports/*.txt user_name@ttytest01:/u01/app/oracle/Reports/





How to install a jks certificateFile: mycerts.jks

1) keytool -v -genkey -keyalg RSA -keysize 1024 -keystore /home/user/Certificate/mycerts.jks -storepass serverpass -alias server1 -keypass server

Name: mycertTX
What is the name of your organizational unit?:  TXGlobal
What is the name of your organization?:  TX
What is the name of your City or Locality?: Indore
What is the name of your State or Province? : MP
What is the two-letter country code for this unit? :  IN
Is CN=
mycertTX, OU=TXGlobal, O=TX, L=INDORE, ST=MP, C=IN correct? : yes

2) keytool -import -noprompt -trustcacerts -keystore
/home/user/Certificate/mycerts.jks -storepass serverpass -alias {1234d7bc-272b-4d81-9a84-f9655d4f94af} -file /home/user/Certificate/mycerts.cer
3) keytool -list -keystore /home/user/Certificate/mycerts.jks -storepass serverpass

4) Update WSM policy for certificate authN with below.

public-key:
1234d7bc-272b-4d81-9a84-f9655d4f94af
Keystore location: /home/user/Certificate/mycerts.jks
Keystore password : serverpass







Importent Unix commands.
"/etc/default/security" for the parameter NUMBER_OF_LOGINS_ALLOWED=
to check if account is locked - /usr/lbin/getprpw -l -r -m lockout oracle
do account unlock  - /usr/lbin/getprpw -l -r -m lockout oracle
reset the correct login count - /usr/lbin/modprpw -k oracle


No comments:

Post a Comment