Search This Blog

Showing posts with label Summary DBA's linux commands. Show all posts
Showing posts with label Summary DBA's linux commands. Show all posts

Thursday, February 24, 2011

Summary DBA's linux commands

Mount
#Mount Windows folder on Linux
$ yum install cifs-utils -y
$ mount -t cifs //192.169.1.1/Temp /tmp/ora_soft -o username=DOMAIN/user,password=password
#Mount ISO image under Linux
mount -o loop /backup/soft/Enterprise-R5-U3-Server-x86_64-dvd.iso /mnt/OEL53

 rpm -ivh --nodeps *.rpm

Edit fstab in 'Repair filesystem' mode
#You might get Read-Only error when you try to change the fstab file, to save it try wq! on vi :
Repair filesystem# mount -w -o remount /
Repair filesystem# vi /etc/fstab

Find Out Linux CPU Utilization
$ mpstat -P ALL
$ sar -u 2 5

Remote copy
$ rsync -avz --stats /local_path  username@10.10.10.10:/remote_path
$ rsync -avz --stats username@10.10.10.10:/remote_path  /local_path
lftp ftpuser:'password'@10.10.10.10 << EOF
  mput /local_path/file.ext -O /remote_path/file.ext
>> EOF


Finding & Sorting
$ find . -name "alert*.log" 2>/dev/null
$ find . -name "*.sql" | xargs grep -i "create table"
$ find . -name "*.trc" -exec grep -i "error" '{}' \; -print
$ awk '{$2="SURPRISE"; for (i=0; i<100; i++) print }' | grep -n SURPRISE
$ find . -type f -mtime +14 -exec rm -f {} \;
$ find . -name "*.log" -ls | sort -nrk7 | head
$ ls -al | sort -rk5 


Finding & Change Owner User
$ find / -uid 1000 -exec chown -R tom {} \;


Finding the Largest Space-Consuming Directories
$ du -S . | sort -nr | head -5
$ du . | sort -nr | head -5


Bundling & Unbundling Files Using tar
$ tar one_mandatory_option [other non-mandatory options] [tar file] [other files]
$ tar -cvf prodrel.tar *.sql
$ tar -cvf script.tar /orahome/scripts
$ tar -cvzf orahome.tar /oracle/product/10.2  --> ( -z option for gzip or the -j option for bzip2)
$ tar -xvf mytar.tar
$ tar -xvf mytar.tar script1.sql script2.sql
$ tar -xvf mytar.tar *.bsh
Finding Differences in Bundled Files Using tar
$ tar -df backup.tar scripts
$ tar -uvf backup.tar scripts

Bundling & Unbundling Files Using cpio
$ ls | cpio -ov > backup.cpio
$ find . -depth | cpio -ov > orahome.cpio
$ find . -depth | cpio -ov | gzip > orahome.cpio.gz
$ find scripts -name "*.sql" | cpio -ov > mysql.cpio
$ cpio -idvm < linux10g_disk1.cpio
$ cat linux10g_disk1.cpio | cpio -idvm
$ cat linux10g_disk1.cpio.gz | gunzip | cpio -idvm

Bundling & Unbundling Files Using zip
$ zip -r ora10g.zip oracle10g
$ zip myzip.zip *.sql
$ zip -r /orahome/ora.zip orascripts
$ unzip mvzip.zip
$ unzip upgrade.zip upgrade.sql
$ unzip upgrade.zip *.sq
$ unzip -n /orahome/ora.zip  -->  (-n option: not overwrite existing files)

Bundling Files Using find
$ find /ora01/admin/bdump -name "*.trc" -mtime +2 | xargs tar -czvf trc.tar.gz
$ find /ora01/admin/bdump -name "*.trc" -mtime +2 | cpio -ov | gzip > trc.cpio.gz


Listing the Contents of a Bundled File
$ tar -tvf orahome.tar
$ tar -tzvf orahome.tar.gz
$ cpio -itv < orahome.tar
$ cat dir.cpio | cpio -itv
$ unzip -l backup.zip


Adding to a Bundled File
$ tar -rvf backup.tar newscript.sql  -->  (-r option: append)
$ tar -rvf backup.tar scripts
$ ls *.sql | cpio -ovAF my.cpio
$ find dirname | cpio -ovAF my.cpio
$ zip -g my.zip script.sql
$ zip -gr my.zip dirname


Compressing and Uncompressing Files
$ gzip scripts.tar
$ gunzip scripts.tar.gz
$ gunzip -c scrdv12_ora_19029.trc.gz | grep -i error
$ zcat scrdv12_ora_19029.trc.gz | grep -i error
$ bzip2 exp.dmp
$ bunzip2 exp.dmp.bz2
$ bunzip2 -c scrdv12_ora_19029.trc.bz2 | grep -i error


Synchronise system datetime
$ crontab -e
*/5 * * * * ntpdate -u 1.rhel.pool.ntp.org 


OS Block Size
$ tune2fs -l /dev/sda1 | grep Block

Device BlockSize
# blockdev --getbsz /dev/sda1

Others
# rpm -q --queryformat "%{name}-%{version}-%{release}.%{arch}\n" openmotif22
Related Posts with Thumbnails