works great on your mobile device too!

Linux Quick Reference for DBAs

<- SpecialTopics


  • Linux OS install here.
  • Example of listing of all Oracle related Disk Info here.

Boot, Last

 who -b
 system boot  2017-10-20 07:26

Boot Log

 last reboot
 reboot   system boot  4.1.12-61.1.18.e Wed Jul 19 08:55 - 09:08  (00:12)    
 reboot   system boot  4.1.12-61.1.18.e Wed Jul 19 08:53 - 09:08  (00:15)    
 reboot   system boot  4.1.12-61.1.18.e Wed Jul 19 08:43 - 09:08  (00:24)    

 wtmp begins Wed Jul 19 08:43:36 2017


  • Display number of cpu's: nproc


  • List: crontab -l
  • Edit: crontab -e
# Min.  Hour  Day   Month  Weekday
# 0-60  0-23  1-31  1-12   0-6 (0 is Sunday)
# Every n minutes = */n

# Every 5 Minutes
*/5 * * * * $SCRIPTS/ 2>&1

# Output Job to File
0 13 * * 0 $SCRIPTS/ > $OUT/

TERM=xterm is useful to avoid jobs that have output creating mail entries.

Run Job Last Day of Month

This can be done testing if next day is "01":
date +%d -d tomorrow


 00 21 * * * [ "$(date +\%d -d tomorrow)" == "01" ] && /mydir/

Inversely (dont run job on last day)

 00 21 * * * [ "$(date +\%d -d tomorrow)" != "01" ] && /mydir/

Run Script on Boot

 @reboot /u01/app/scripts/ > /u01/app/scripts/out/initNFS.out

Note @reboot can only from root user cron in some Linux distributions.

cron Output

By default cron outputs to /var/spool/mail/<username>

  • Delete all mail
    • -N Inhibits the initial display of message headers when reading mail or editing a mail folder.
    • d * delete all mails
mail -N
d *

cron Script Changes

  • Check what your cron environment actually sees and adjust accordingly:
    * * * * * env > /tmp/env.out
    env.out will show what your cron environment sees.
  • Common Script Changes for cron:
    • Ensure PATH, ORACLE_SID and ORACLE_HOME in your script.
      Alternatively place in crontab.
    • Export all vars called from sourced files.
      Example: export sDirScripts="/u01/app/scripts"
    • In some instances you may need to:
      • Export all non-local vars. All vars not inside a local function that is.
      • Include your scripts dir in your PATH.
      • Change (cd) to your scripts dir from your main parent script.

DHCP, Release and Renew Lease

Interface name in example: enp0s8

dhclient -r enp0s8
dhclient enp0s8
ifconfig enp0s8

In VirtualBox get a new IP by: Network-> Adpater -> Advanced -> Refresh MAC address button.

hostname, Changing

Change a systems hostname (to lnx02 example).

  • Run hostnamectl.
    hostnamectl set-hostname lnx02
  • vi /etc/sysconfig/network

VBox: resolv.conf

Set IP to current system.

  1. chattr -i /etc/resolv.conf
  2. vi /etc/resolv.conf
    Example entry line: nameserver
  3. chattr +i /etc/resolv.conf

VBox: dnsmasq

Set IP (listen-address) to current system.

  1. vi /etc/dnsmasq.conf
  1. service dnsmasq restart
  2. If needed: shutdown -r now


Block device attributes (dev, UUID, Type).

 root> blkid
 /dev/sda1: UUID="52226d66-7105-40f2-96c6-c86f3fbbd189" TYPE="xfs"
 /dev/sda2: UUID="pcmBFs-eAo5-Ww9f-fYPU-WpSP-rXFZ-P6YRnk" TYPE="LVM2_member"
 /dev/sdb1: UUID="8373859b-0c53-44ae-be76-927e02fbc0e6" TYPE="xfs"
 /dev/sdc1: UUID="1789294b-ef03-45a9-ad38-1e312e2c253f" TYPE="xfs"
 /dev/sdd1: UUID="dbd3f08e-7a08-4805-8329-a018c47eaa5f" TYPE="xfs"
 /dev/mapper/ol-root: UUID="bd8c4cf8-71bd-41a7-ab4a-077143dfba54" TYPE="xfs"
 /dev/mapper/ol-swap: UUID="a9433d99-5e6f-426b-81cc-5e99879e9bb4" TYPE="swap"
 /dev/mapper/ol-home: UUID="9084822a-a820-406a-a9df-191cface42db" TYPE="xfs"


fdisk can be used to create LINUX disk partitions.

  • Replace /dev/sdb with your disk name.
  • Ensure your OS can see the disk add partition to using: lsblk
  • If for RAC shared disk, you only need to fdisk from node 1.
    Other nodes will see the new partition after /sbin/partprobe run.


  1. Run: fdisk /dev/sdb
  2. Command (m for help): new
  3. Partition type: primary
  4. Partition Number: 1
  5. First sector: <Enter> taking default (first).
  6. Last sector: <Enter> taking default (last).
  7. Command (m for help): w to write changes to disk.

lsblk now shows the attached partition (sdb1)

sdb               8:16   0    8G  0 disk 
└─sdb1            8:17   0    8G  0 part

Repeat above steps for each disk.

Update Partition Table

partprobe is a program that informs the operating system kernel of partition table changes, by requesting that the operating system re-read the partition table.


Disk Device HW Paths

 lshw -class tape -class disk -class storage -short

Example Output:

H/W path          Device      Class       Description
/0/100/1.1        scsi1       storage     82371AB/EB/MB PIIX4 IDE
/0/100/1.1/0.0.0  /dev/cdrom  disk        CD-ROM
/0/100/d          scsi2       storage     82801HM/HEM (ICH8M/ICH8M-E) SATA Contr
/0/100/d/0        /dev/sda    disk        80GB VBOX HARDDISK
/0/100/d/1        /dev/sdb    disk        10MB VBOX HARDDISK
/0/100/d/0.0.0    /dev/sdc    disk        5242KB VBOX HARDDISK

If need be to install: yum install lshw -y

Take Disk Snapshot

 lsblk -S > /tmp/$HOSTNAME.dskinfo1.txt
 lsblk > /tmp/$HOSTNAME.dskinfo2.txt
 lshw -class tape -class disk -class storage -short > /tmp/$HOSTNAME.dskinfo3.txt

Disable Linux Disk IO Scheduler (if to be shared disk for ASM)

Confirm Scheduler Exists

 cat /sys/block/sdb/queue/scheduler
 cat /sys/block/sdc/queue/scheduler


 echo deadline > /sys/block/sdb/queue/scheduler
 echo deadline > /sys/block/sdc/queue/scheduler


Date\Time, Changing

touch -t yyyymmddhhmm
touch -t 201712151500 myfile.txt

Delete Files Older Than x Days

find /stuff -maxdepth 1 -type f -name '*.tar' -mtime +30 -exec rm {} \;

Delete Files Older Than x Minutes

find /stuff -maxdepth 1 -type f -name '*.tar' -mmin +2880 -exec rm {} \;

If you want files in child directories deleted too remove -maxdepth 1.

  60    = 1 hour
  1440  = 1 day
  2880  = 2 days
  10080 = 1 week
  20160 = 2 weeks

Delete Directory and All Files in It

cd /my_parent_dir
rm -r -f my_sub_dir_to_delete


Show the ten biggest files on my system:
find / -printf 'p\n'| sort -nr | head -10


  • find / -name "myscript*.sh" -printf '%h\n'
    Shows all directories file exists in.
  • find / -iname "myscript"
  • find /u01/orasw -iname ""
  • grep "10046_Trace" /u01/app/oracle/diag/rdbms/mydb/mydb1/trace/*.trc
    Finds file containing string.

Folder and File Sizes

Find folder\files taking up the most space.

  • cd /parent_folder_with_subfolders_to_check
  • du -shx */


  • cd /folder_to_check
  • du -sh *


 # Permission              File Attributes (User Group Other)
 7 read, write and execute rwx
 6 read and write          rw-
 5 read and execute        r-x
 4 read only               r--
 3 write and execute       -wx
 2 write only              -w-
 1 execute only            --x
 0 none                    ---
 mkdir /u01/rman
 chown -R oracle:oinstall /u01/rman
 chmod -R 765 /u01/rman

fstab and mount

There must be a mount point on the local system to mount a file system. A mount point is a directory to which the mounted file system is attached. The following scenario creates /u01 from the disk partition /dev/sdb.
Note: Disks for ASM only need to be partitioned, i.e. not formatted and mounted.

Create Disk Partitions

 Display existing: lsblk
 Create partition: fdisk /dev/sdb

Ensure Not mounted

 umount -l /dev/sdb1

Create xfs Filesystem

 mkfs.xfs -f /dev/sdb1

 You can only mount file systems, not partitions. An empty partition (one   
 created with fdisk but not initialized with mkfs) cannot be mounted. If
 file -s can’t find a file system inside a disk partition, you cannot mount
 it – you probably forgot to make one using mkfs.

 To check use this: file -s /dev/sdb1

Create Mount Points

 cd /
 mkdir /u01
 mount /dev/sdb1 /u01


 mount | grep /dev/sdb1
 df -h

Make Mount Point Permanent

 vi /etc/fstab
 /dev/sdb1  /u01 xfs  defaults  0  0

 Test /etc/fstab via command: mount -a

 This command mounts everything in the /etc/fstab except for those
 lines that contain the noauto keyword.  In this way you can test 
 without rebooting.

Reboot Check

 shutdown -r now
 mount | grep /dev/sdb1
 df -h

Creating Partitions Larger than 2tb

The following scenario creates a partition larger than 2tb (2.3tb) via ext4 filesystem.

 -- Show Existing Partitions
 root> lsblk

 If need be unmount
  umount -l /u02

 -- Create Partition
 root> parted /dev/sdb
   mklabel gpt
   Warning: The existing disk label on /dev/sdb will be destroyed 
            and all data on this disk will be lost. 
            Do you want to continue? Yes/No? yes
   unit TB
   mkpart primary 0.00TB 2.30TB

 root> lsblk

 -- Format New Partition as ext4
 root> mkfs.ext4 /dev/sdb1

 -- Create Mount Point
 root> cd /
 root> mkdir /u02
 root> mount /dev/sdb1 /u02
 root> df -h

 -- Make Permanent
 root> vi /etc/fstab
 /dev/sdb1  /u02 ext4  defaults  0  0

 root> mount -a

The max size for EXT2 type file systems is 2tb.


 lsblk -S
 sda  0:0:0:0    disk VMware   Virtual disk     1.0
 sdb  0:0:1:0    disk VMware   Virtual disk     1.0
 sdc  0:0:8:0    disk VMware   Virtual disk     1.0
 sdd  1:0:0:0    disk VMware   Virtual disk     1.0
 sde  1:0:1:0    disk VMware   Virtual disk     1.0

Oracle Dirs to Routinely Cleanup

# find /u01/ -name "*adump*"         -type d > /tmp/find.out; clear; more /tmp/find.out
# find /u01/ -name "*alert*"         -type d > /tmp/find.out; clear; more /tmp/find.out;
# find /u01/ -name "*trace*"         -type d > /tmp/find.out; clear; more /tmp/find.out;
# find /u01/ -name "*listener*"      -type d > /tmp/find.out; clear; more /tmp/find.out;
# find /u01/ -name "cvures"          -type d > /tmp/find.out; clear; more /tmp/find.out;
# find /u01/ -name "*listener_scan*" -type d > /tmp/find.out; clear; more /tmp/find.out;
# find /u01/ -name "*client*" -type d > /tmp/find.out; clear; more /tmp/find.out|grep

printf "$(basename ""$0""): Started $(date "+%Y-%m-%d %H:%M:%S")\n"
usrStdRet=35;  # Days to retain files, i.e. standard retention.
usrAudRet=10;  # Days to retain Audit files (adump).
usrRmnRet=14;  # Days to retain RMAN files.

# Scripts
find /u01/app/scripts/logs  -type f -name '*.log' 
  -mtime +$usrStdRet -exec rm {} \;
find /u01/app/scripts/tmp   -type f -name '*.tmp' 
  -mtime +$usrStdRet -exec rm {} \;

# oracle: adump
find /u01/app/oracle/admin/mydb/adump -type f -name '*.aud' 
  -mtime +$usrAudRet -exec rm {} \;

# trace
find /u01/app/oracle/diag/rdbms/mydb/mydb1/trace -type f -name '*.tr?' 
  -mtime +$usrStdRet -exec rm {} \;
find /u01/app/oracle/diag/rdbms/mydb/mydb1/trace -type f -name '*.log.[1-9]'  
  -mtime +$usrStdRet -exec rm {} \;
find /u01/app/grid/diag/asm/+asm/+ASM1/trace -type f -name '*.tr?' 
  -mtime +$usrStdRet -exec rm {} \;
find /u01/app/grid/diag/crs/lnx01/crs/trace -type f -name '*.tr?' 
  -mtime +$usrStdRet -exec rm {} \;
find /u01/app/grid/diag/rdbms/_mgmtdb/-MGMTDB/trace -type f -name '*.tr?' 
  -mtime +$usrStdRet -exec rm {} \;
find /u01/app/grid/diag/tnslsnr/lnx01/listener/trace -type f -name '*.tr?' 
  -mtime +$usrStdRet -exec rm {} \;
find /u01/app/grid/diag/tnslsnr/lnx01/listener_scan1/trace -type f -name '*.tr?' 
  -mtime +$usrStdRet -exec rm {} \;
find /u01/app/grid/diag/tnslsnr/lnx01/listener_scan2/trace -type f -name '*.tr?' 
  -mtime +$usrStdRet -exec rm {} \;
find /u01/app/grid/diag/tnslsnr/lnx01/listener_scan3/trace -type f -name '*.tr?' 
  -mtime +$usrStdRet -exec rm {} \;

# oracle: alert
find /u01/app/oracle/agent/agent_inst/diag/ofm/emagent/emagent/alert 
  -type f -name '*.xml' -mtime +$usrStdRet -exec rm {} \;
find /u01/app/oracle/diag/rdbms/mydb/mydb1/alert
  -type f -name '*.xml' -mtime +$usrStdRet -exec rm {} \;

# Std Listener
find /u01/app/grid/diag/tnslsnr/lnx01/listener/alert -type f -name '*.log.[1-9]' 
  -mtime +$usrStdRet -exec rm {} \;

# grid: alert
find /u01/app/grid/diag/rdbms/_mgmtdb/-MGMTDB/alert  -type f -name '*.xml' 
  -mtime +$usrStdRet -exec rm {} \;
find /u01/app/grid/diag/tnslsnr/lnx01/mgmtlsnr/alert -type f -name '*.log.[1-9]' 
  -mtime +$usrStdRet -exec rm {} \;
find /u01/app/grid/diag/crs/lnx01/crs/alert          -type f -name '*.xml' 
  -mtime +$usrStdRet -exec rm {} \;

# grid: cvures
find /u01/app/12.1.0/grid/cv/baseline/cvures           -type f -name '*.zip' 
  -mtime +$usrStdRet -exec rm {} \;
find /u01/app/grid/crsdata/@global/cvu/baseline/cvures -type f -name '*.zip' 
  -mtime +$usrStdRet -exec rm {} \;

# grid: gpnp_* Logs
find /u01/app/oracle/product/ -type f -name '*.log' 
  -mtime +$usrStdRet -exec rm {} \;

# RAC Listener
find /u01/app/grid/diag/tnslsnr/lnx01/listener_scan1/alert -type f -name '*.log.[1-9]' 
  -mtime +$usrStdRet -exec rm {} \;
find /u01/app/grid/diag/tnslsnr/lnx01/listener_scan2/alert -type f -name '*.log.[1-9]' 
  -mtime +$usrStdRet -exec rm {} \;
find /u01/app/grid/diag/tnslsnr/lnx01/listener_scan3/alert -type f -name '*.log.[1-9]' 
  -mtime +$usrStdRet -exec rm {} \;

#find /u02/backup/mydb -type f -name '*.rman' -mtime +$usrRmnRet -exec rm {} \;

# End
printf "$(basename ""$0""): Ended $(date "+%Y-%m-%d %H:%M:%S")\n"

gnome, Change default app settings

You must install dconf-editor to change settings via GUI.

  • yum install dconf-editor -y
  • Run: dconf-editor (Run for each user account as desired.)


org -> gnome -> nautilus ->
    default-visible-columns: ['name', 'size', 'type', 'date_modified', 'permissions']
    user-tree-view [x]
    always-use-location-entry  (enables access to pwd top text)
    show-hidden-files [x]


org -> gnome -> gedit-> preferences
    insert-spaces [x]
    tabs-size: 3
    status-bar-visible: [x]
    side-panel-visible: [x] 
    toolbar-visible: [x] 

Interface, Bounce

Format: if[up|down] <InterfaceName>

ifdown ens192
ifup ens192

Interface, Reset Counters Without Bouncing Interface

 -- Determine Interface to Reset (Ex: enp0s9) 

 -- Show Counters
 ifconfig -a enp0s9

 -- Get Driver
 [root]# ethtool -i enp0s9
 driver: e1000

 -- Reset Counters
 modprobe -r e1000; modprobe e1000; ifup enp0s9

 -- Show Counters
 ifconfig -a enp0s9

Interface, Status

 All: ifconfig or netstat -in
 One: ifconfig -a <InterfaceName>
      Ex: ifconfig -a eth0

Set Default Kernel to Use at Boot Menu

The IDs are assigned in order the menu entries appear in the /etc/grub2.cfg file starting with 0. To specify which kernel should be loaded first, pass its number to the grub2-set-default command.

  Print List of Boot Options
  awk -F\' /^menuentry/{print\$2} /etc/grub2.cfg

  Set kernel to Boot
  Example to set it to 2nd line item.
  grub2-set-default 1

  Verify the new default kernel
  Check the below file to see the kernel which will be loaded at next boot, 
  crosscheck the numeric value with the menuentry in the /etc/default/grub file.

  cat /boot/grub2/grubenv |grep saved

  Rebuild GRUB2
  Changes to /etc/default/grub require rebuilding the grub.cfg file as follows:
  grub2-mkconfig -o /boot/grub2/grub.cfg

  Once you have verified everything and rebuilt the GRUB2 configuration file, 
  you can go ahead an reboot the server for changes to take effect.
  shutdown -r now

  To check the current kernel:
  uname -a

Kill a Program

Assuming your process\program name is:

  • View program: ps -ef|grep stdmaint
  • Kill by name: pkill
  • Kill by Process ID:
    • Get Process ID: pgrep stdmaint OR ps -ae|grep stdmaint
    • Kill program: kill <ProcessID>

To check active SQL before and after you can use this:

column executions      format 999999
column username        format a10
column sid             format 999999
column serial#         format 999999
column users_executing format 9999
column sql_text        format a50
SELECT a.executions, 
       b.sid, b.serial#,
FROM v$sql a, v$session b
WHERE users_executing > 0 
AND a.address = b.sql_address 
AND a.hash_value = b.sql_hash_value 
ORDER BY address, child_number;

GUI Apps

  • ASM Cfg Assistent: asmca
  • GEdit: gedit
  • Disk Manager: gnome-disks
  • File Mgr: xdg-open .
  • Firefox: firefox
  • Network Connections: nm-connection-editor
  • System Monitor: gnome-system-monitor

The command-line equivalents for any standard menu app can be found by grep-ing/browsing /usr/share/applications. All menu items point to .desktop files. Most are within this directory.


The $HISTFILE variable points to the file that contains your history. So for the oracle user the history file would be:



MTU, Setting

Example setting eth1 to 9000.

 ifconfig eth1 mtu 9000 up
 ifconfig eth1

MTU, Make Value Permanent

If there is no value in interface config file the default (1500) will be used.

  1. cd /etc/sysconfig/network-scripts
  2. vi ifcfg-<Interface>

To make active now (if nothing running on system): service network restart

MTU, Confirming Value

These tests can be used to confirm if a given interface MTU value (ex: 9000) is working on a given interface\IP.


traceroute rac01-priv --mtu 
traceroute -F rac01-priv 9000


ping <privIP> -c 1 -M do -s 8972
PING ( 8972(9000) bytes of data.
8980 bytes from icmp_seq=1 ttl=64 time=0.018 ms

--- ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.018/0.020/0.022/0.004 ms
PING ( 8972(9000) bytes of data.
8980 bytes from icmp_seq=1 ttl=64 time=0.167 ms

If the MTU sizes don’t match the ping command will return “Packet needs to be fragmented by DF set”. The reason for the 8972 on *nix devices is that the ICMP/ping implementation doesn’t encapsulate the 28 byte ICMP (8) + IP (20) (ping + standard internet protocol packet) header – thus we must take the 9000 and subtract 28 = 8972.

Example of forcing an error:

rac02>  ping -c1 -M do -s 9999
PING ( 9999(10027) bytes of data.
ping: local error: Message too long, mtu=9000


iperf server, 
  rac01> iperf -s -u -i 10

iperf client
  rac02> iperf -c rac01-priv -u

-c is saying this is the client side. rac01-priv is my private network IP address 
-u says to send UDP traffic.

Mounting a Windows\Samba Share

On Windows System

  1. Identify windows system to host share (ex: winsrv01).
  2. Create Windows share (ex: oradata).
  3. Create user used to connect mount point to share (ex: orasvc).
  4. Assign privs to user to use data in share.

On Linux System

  1. Ensure cifs-utils installed.
    yum install cifs-utils -y
  2. Create mount point (ex: /mnt/winsrv01).
  3. Issue mount command.
root> mkdir /mnt/winsrv01
root> mount -t cifs //winsrv01/oradata -o username=orasvc,password=MyPassowrd /mnt/winsrv01

root> df -h
      winsrv01/oradata  190T   79T  112T  42% /mnt/winsrv01

Unmount Volume

umount /mnt/winsrv01

df -h shows it gone if successful.

Configure NTP

It is critical that the time of all your nodes is kept in sync for an Oracle RAC environment. Swift changes in time can lead to Oracle shutting down a node(s) due to inconsistent timers. Use the following line\values for the /etc/sysconfig/ntpd file.

OPTIONS="-g -x -u ntp:ntp -p /var/run/"

  • -g = panicgate: allows the first adjustment to exceed the panic limit (1000s by default).
  • -p = pidfile: name and path of the file used to record ntpd process ID.
  • -u = Linux user account to own process.
  • -x = slew: make micro time adjustments (rather than in one large adjustment).

-- If CentOS: Disable chrony (the default)

  • systemctl stop chronyd
  • systemctl disable chronyd.service
  • systemctl disable chronyd
  • mv /etc/chrony.conf /etc/chrony.conf.orig
  • systemctl status chronyd

-- System Date & Time: View
Tue Nov 22 08:46:20 EST 2016

-- System Date & Time: Set
date MMDDhhmmYYYY
date 112208362016
Tue Nov 22 08:36:00 EST 2016

-- ntpd Service: Installation

  1. yum install -y ntp
  2. systemctl enable ntpd
  3. systemctl start ntpd
  4. systemctl status ntpd
  5. ntpq -p
    • If you don't see a * next to a server your ntpd is not synced to any time source.-
    • It might take up to 5 minutes to sync after system booted.

-- Sync NTP To Time Source
Add server entry to /etc/ntp.conf with prefer clause.

  1. vi /etc/ntp.conf
  2. server <NTP_Auth_Server_IP> prefer
  3. systemctl restart ntpd
  4. ntpq -p
    In a few minutes you should see a * next to your ntp server.

-- Stop|Disable

  • systemctl stop ntpd
  • systemctl disable ntpdate

-- Status Check

  • ntpq -p
  • ntpdc -c loopinfo
  • ntpstat
  • timedatectl <== Alert: Can produce inaccurate results!
  • For RAC as grid user: cluvfy comp clocksync -n all -verbose

-- Sync NTP Manually
This forces the system time to change to NTP server's time now!

  1. service ntpd stop
  2. ntpdate -s <YourNTPServerIP>
  3. service ntpd start
  4. Check status: ntpq -p

If ntpdate does not work you can use ntpd -qg on that step.

NTP Troubleshooting

Package Install\Uninstall\Status

FTP package (vsftpd) used in this example.

Install Package

 yum install vsftpd -y
 rpm -qa | grep vsftp
 chkconfig --levels 235 vsftpd on
 service vsftpd start
 service vsftpd status
 pgrep ftp

Uninstall Package

 -- Disable Service
 service vsftpd stop
 chkconfig --levels 235 vsftpd off  
 service vsftpd status

 -- Remove Pkg
 1. Get exact pkg name
    rpm -qa | grep vsftp
 2. Uninstall Pkg
    rpm -e vsftpd-3.0.2-22.el7.x86_64

Check Status

 service vsftpd status
 pgrep ftp
 rpm -qa | grep vsftp
 chkconfig --list


If the hostname does not work try the IP and vice-versa.


  ping rac02
  rac01> scp /u02/backup/q6s2mkd3_9030_1.rman oracle@


  ping rac01
  rac02> scp oracle@ /u02/tmp_rman

Automate Password Prompt via sshpass

yum install wget
rpm -ivh sshpass-1.05-1.el6.x86_64.rpm
which sshpass

sshpass -p 'mypassword' scp /temp/myfile.dmp oracle@

sshpass rpm is here.


The following covers Linux system changes required to be able to send an email using sendmail.


  • yum install m4 telnet mailx -y
  • yum install sendmail sendmail-cf -y

Relay Server Configuration (if used)

  • cp /etc/mail/ /etc/mail/
  • vi /etc/mail/
    Note: Remove dnl entry at the beginning of line to uncomment the line.
    • Uncomment and change SMART_HOST entry to your relay email server.
    define(`SMART_HOST', `relay.myrelayserver.local')dnl
    • Uncomment and change MASQUERADE_AS entry to your email server.
    • Uncomment FEATURE(masquerade_envelope).
  • Rebuild
    • cd /etc/mail
    • make
    • service sendmail restart


tail -f /var/log/maillog


mail -s "Subject" ReceverEmailAddress@Domain < PathToEmailMsgFile

mail -s "Email Test 1" < /dev/null
mail -s "Email Test 2" < /tmp/MyEmailMsg.txt
mail -s "Email Test 3" "" < /dev/null

Attachment Example
mail -a /u01/app/scripts/rpt/db_growth.csv -s "Growth Rpt" < /dev/null



 systemctl list-unit-files
 systemctl list-unit-files|grep enabled
 systemctl list-unit-files|grep httpd


View Full List of Services Using chkconfig
chkconfig --list

View Full List of Services That Start at Boot (Normally, Runlevel 3)
chkconfig --list | grep 3:on

Turn On a Service for the Default Run Levels (2,3,4,5)
chkconfig httpd on

Turn Off a Service for the Default Run Levels (2,3,4,5)
chkconfig httpd off

Turn On a Service for a Selected Run Level
chkconfig --level 3 httpd on

It is also possible to combine multiple levels into one command:
chkconfig --level 35 httpd on

Turn Off a Service for a Selected Run Level
chkconfig --level 3 httpd off


 Reboot:                        shutdown -r now
 Shutdown and Power Off (halt): shutdown -h now

System Messages

# less /var/log/messages
# more -f /var/log/messages
# cat /var/log/messages
# tail -f /var/log/messages
# grep -i error /var/log/messages

Common Linux log files names and usage

  • /var/log/messages : General message and system related stuff
  • /var/log/auth.log : Authenication logs
  • /var/log/kern.log : Kernel logs
  • /var/log/cron.log : Crond logs (cron job)
  • /var/log/maillog : Mail server logs
  • /var/log/httpd/ : Apache access and error logs directory
  • /var/log/boot.log : System boot log
  • /var/log/secure or /var/log/auth.log : Authentication log
  • /var/log/utmp or /var/log/wtmp : Login records file
  • /var/log/yum.log : Yum command log file.

Create\Add New SWAP (using a file)

Change count=8096 to match size you need for SWAP.

-- Create

 dd if=/dev/zero of=/swapfile-additional bs=1M count=8096
 mkswap /swapfile-additional
 chmod 600 /swapfile-additional

-- Make Permanent

 vi /etc/fstab
 /swapfile-additional swap swap    0   0

-- Mount and Enable

 mount -a
 swapon -a

-- Check

 swapon -s
 free -m

Changing SWAP

If required you can enable or repoint the SWAP to another disk after the OS install using these steps:

  1. Allocate a new disk from VirtualBox or your OS (Ex: sdb).
  2. Disable existing SWAP (Ex: /dev/mapper/ol-swap)
    swapoff /dev/mapper/ol-swap
  3. Enable the new disk as your SWAP.
    mkswap /dev/sdb
    swapon -f
  4. Make permenent by editing your /etc/fstab file.
    Line entry: /dev/sdb swap swap defaults 0 0
  5. Reboot to test.
    shutdown -r now


Create (tar all files in current dir)

 tar -cvof scripts.tar * [options]
  • Delete tar'd files option: --remove-files scott*.dmp
  • Exclude files otpion: --exclude '*.tar'


 tar -xvf scripts.tar

List Contents:

 tar --list --file=scripts.tar


telnet 25

mail from: oracle@MyHostName
rcpt to:

Subject: Test

Hello, this is a test.

tmpfs: /dev/shm

The value of /dev/shm must be larger than your Oracle MEMORY_TARGET value. For instance, if you want your database to use 2048m you could set /dev/shm to 2304m.

Short Term

 mount -t tmpfs shmfs -o size=2304m /dev/shm


 vi /etc/fstab and add this entry:
 shmfs /dev/shm tmpfs size=2304m 0

Display Current Value

 df -h


z = color mode
t = cpu    (graphic mode)
m = memory (graphic mode)
c = COMMAND detail
j = Justify COMMAND

u = show for just one user
W = Write changes to file (set default values).
Y = Inspect PID

Update OS

root> yum update -y


0. Login as root user.
1. Applications -> System Tools -> Software Update
2. Continue.
3. Process runs that checks for updates.
4. Next a Window showing how many updates are available displayed.
5. Select [Install Updates].

User Accounts


 -- Example 1
 useradd scott
 passwd scott

 -- Example 2
 useradd --uid 54321 --gid oinstall --groups dba,oper,asmdba,asmoper,backupdba,dgdba,kmdba oracle
  • Required entries are created in the /etc/passwd, /etc/shadow and /etc/group files.
  • Set file permissions as required.
  • Add group: groupadd --gid 54321 oinstall


 userdel -r scott

The -r removes files in the user's home directory along with the home directory itself and the user's mail spool.


vi cheat sheet here.

  • Delete
    • To EOL: D
    • Current line to top: dgg
    • Current line to bottom: dG
  • Find string: <Esc> :/EnterString
  • Line Numbers: <Esc> :set number |set nonumber
  • Move
    • Screen (top|middle): H|M
    • File (top|end): gg | shift+g
    • Line (beginning|end):0 | $
    • Page (forward|Back): Ctrl+f|Ctrl+b
  • Search and Replace: <Esc> :%s/pattern/replace/
  • Turn hilite off: <Esc> :noh
  • Write & Quit: <Esc> :wq!
  • Quit: <Esc> :q


With XMing you can launch GUI Linux applications from a putty session. Set the following values in putty to use XMing: Connection -> SSH -> X11

  X11 forwarding
    [x] Enable X11 forwarding
    X display location: localhost:0
  Remote X11 authentication
     (x) MIT-Magic-Cookie-1

Ensure XMing is running before you run your putty session and launch a GUI app.

Disk Info

 su -
 lsblk    > /tmp/$HOSTNAME.lsblk.txt
 lsblk -S > /tmp/$HOSTNAME.HCtrlID.txt
 blkid    > /tmp/$HOSTNAME.blkid.txt
 lshw -class tape -class disk -class storage -short > /tmp/$HOSTNAME.lshw.txt

 su -
 export ORACLE_HOME=/u01/app/ 
 ls -alrt /dev/oracleafd/disks/*              > /tmp/$HOSTNAME.asmfd_disks.txt
 $ORACLE_HOME/bin/asmcmd afd_lslbl '/dev/sd*' > /tmp/$HOSTNAME.asmfd_lbls.txt

 su -
 ls -al /dev/asm* > /tmp/$HOSTNAME.udev_disks.txt

 su - grid
 ls -l /dev/oracleasm/disks    > /tmp/$HOSTNAME.asm_ls.txt
 /usr/sbin/oracleasm listdisks > /tmp/$HOSTNAME.asm_listdisks.txt