I want to share useful Linux commands for Oracle DBAs. I will edit this post day by day 🙂
mounting disk:
——————————
1- Create folder that you want to mount disk
mkdir /media/newdisk
mkdir /DATA
For mounting as FAT32:
mount -t vfat -o umask=ooo /dev/hdb1 /media/newdisk
For mounting as NTFS:
mount -t ntfs -o umask=0222 /dev/hdb1 /media/newdisk
For mounting as CDROM:
mount -t iso9660 -r /dev/cdrom /media/cdrom
For mounting as OCFS2:
mount -t ocfs2 -o noatime,_netdev,datavolume,nointr /dev/emcpowera1 /DATA
For mounting as ext3:
mount -t ext3 /dev/sdb1 /software
unmounting disk:
————————–
umount -l /dev/sdb1
umount /DATA
Partitioning
—————
fdisk /dev/sdb
Formatting
————
Formatting as ext3:
mkfs -t ext3 /dev/sdb1
Formatting as OCFS2:
mkfs.ocfs2 -b 4K -C 128K -N 5 -L /DATA /dev/emcpowera1
FILE SYSTEM CHECK
———————————————
fsck.ocfs2 -n /dev/sdf2
fsck.ocfs2 -y /dev/sdf2 –>repair
List disk drives
————–
df -h
Increasing tmpfs
—————————————————-
mount -t tmpfs shmfs -o size=3g /dev/shm
Getting user id
———————–
id username
id oracle
Changing owner of folder
——————————————-
chown -R oracle:dba /oracle
Changing permissions on a folder or file
——————————————–
chmod 775 file_name
Checking for rpm package if it is installed or not
————————————————–
rpm -qa | grep “package name”
For installing rpm package
——————
rpm -ivh package
For updating rpm package
———————–
rpm -Uvh package
For deleting rpm package
——————
rpm -e package
List the rpms needed to install the Oracle
—————————————————————————————————————-
rpm -q binutils compat-db compat-libstdc++-33 libgcc glibc glibc-devel glibc-headers gcc gcc-c++ libgcc libstdc++ cpp make libaio ksh elfutils-libelf make sysstat libaio libaio-devel setarch libXp unixODBC –qf “%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n”|sort
Rpm packages by date of installation
———————
rpm -qa –last | more
Extracting CPIO file
———————————-
cat cpio_file | cpio -idmv
Creating MD5 file
————————————————————-
md5sum file > file.md5
Comparing MD5 file
————————————————-
md5sum -c file.md5
File transfer from a server to another
———————————
#file download
scp 192.168.2.1:oracle/tlp.pw /oracle
#file upload
scp /oracle/full.dmp ora10g@192.168.3.5:/export
Searching in a file
———————-
grep -ins 192.168.2.1(Text) -A2 -B1 list1.log
Finding process count
————————
ps -ef |grep TALIPDB|wc
Changing date
———————————–
date -s “30 MAR 2010 12:32:00”
SEMAPHORES
——————–
ipcs -s
ipcrm
Tracing OS process
—————————-
strace -p pid
List contents of Tar file
—————————————
tar -tf java_patch.tar
Adding a folder to tar file
———————————————–
tar -rf java_patch.tar jre
Creating tar file
—————————–
tar -cf java_patch.tar jdk
Changing ID of a user
—————————————–
usermod -u UID user
To empty the contents of a file without killing process
———————————————-
echo “”>talipdb_ora_7001.trc
Finding path of word
———————————————–
which exp
Creating shortcut
——————————————
ln -s path kısayol_adı
SELinux Status
——————————-
sestatus
Getting rpm package version which you want to install
———————————————–
echo ocfs2-`uname -r`
monitoring i/o statistics
——————————-
iostat 3
Checking date between RAC nodes
—————————————
ssh taliprac1 date; ssh taliprac2 date; date
Adding a command to sudoers
——————————————————————————————–
/etc/SUDOERS
ora10g localhost=NOPASSWD:/bin/mount,/bin/umount
ora10g talipdb=NOPASSWD:/bin/mount,/bin/umount
Sending broadcast message
——————-
wall mesaj
Last Logins
——————-
last | more
Size of directory which you are in
———————–
du . -sh
Size of files which you are in
————————————————————–
du * -sh | sort -n
Sending e-mail
———————————–
mail -s “deneme” talip_hakan_ozturk@hotmail.com < sqlnet.log(attachment)
Finding files which covers “word”
———————————-
grep -ins word *
Creating kill script file for processes .
——————————————————————————–
ps -ef |grep “process_name” |awk ‘{print ” kill -9 ” $2}’>/tmp/kill.sh
Monitoring processes in every 2 seconds
—————————————————–
watch -n 2 “ps -ef | grep process_name | grep -v ps”
monitor instantaneous changes in the content of a file
—————————————————-
tail -f /var/log/messages
Talip Hakan Ozturk