01 April, 2015

Quick Unix / Linux commands reference

1. To zip the file using gunzip :
tar cvf - export_from_agprd_schema.dmp | gzip > export_from_agprd_schema.dmp.04012015.tar.gz

2. To find the delpoy* files with the age of more than 3 days and move it to a directory 

example : 
find /usr/sap/NPQ/J00/work/deploy* -mtime +3 -type f -exec mv "{}" /usr/sap/NPQ/J00/work/neel_test/ \; 

3. top CPU, memory consuming process on RHEL:  
ps aux --sort -rss  --> user friendly ; the below shows the process in detail . 
ps -eo pmem,pcpu,vsize,pid,cmd | sort -k 1 -nr | head -20

4. top disk space consuming directories and files 
du - xak <path> | sort -rn | head -20

5. copy the files with a modified time stamp to a different directory:

find . -mtime 8 -type f -exec cp {} /dd890/orabackup/Dev-Test/Donot_Remove/DSNPR/ \;

6. Uncompress the tgz file:

tar -xzvf <filename>.tgz
tar -xzvf <filename>.TGZ

7. killing the processing with a pattern

kill -9 `ps -ef | grep /usr/sap/hostctrl/exe/sapdbctrl | grep -v grep | cut -c10-15`

8. Find if the Linux server is a VM or physical ? 

dmesg |grep -i hypervisor  --> shows if it is a VM and is built with hypervisor. 

dmidecode -t system|grep 'Manufacturer\|Product' --> shows the Manufacturer and Product Name details :

eg:
1. root@hq-agtest1 ~]# dmidecode -t system|grep 'Manufacturer\|Product'
        Manufacturer: Dell Inc.
        Product Name: PowerEdge R720     ===> physical 


2. [root@hq-agsbx ~]# dmidecode -t system|grep 'Manufacturer\|Product'
        Manufacturer: Red Hat
        Product Name: RHEV Hypervisor    ===> virtual 


9. Find the files created after a date in unix / linux system 

find ./BIParch1* -type f -newermt 'Dec 16 13:14';

10. recursive search of a string within the files across the system from root path. 

grep -Ril "9001" /u01/home/oracle/Agile | more

11. understanding the CUP stats - 
https://www.tecmint.com/understand-linux-load-averages-and-monitor-performance/

12. delete older than number of days files 

find /almdata/almlogs/sa/SaServerLog* -mtime +90 -exec rm -rf {} \;
 
 

   

No comments:

Post a Comment