oracledba.help
SpecialTopics

Linux Quick Reference for DBAs

Alma 8.n OS Updating (patches, pkgs)

QC

 dnf repolist
 repo id                          repo name
 appstream                        AlmaLinux 8 - AppStream
 baseos                           AlmaLinux 8 - BaseOS
 extras                           AlmaLinux 8 - Extras
 plus                             AlmaLinux 8 - Plus

 dnf check-update
 Last metadata expiration check: 0:13:07 ago on Mon 07 Aug 2023 12:36:18 PM EDT.

Update OS Patches and Packages

 dnf clean all
 dnf check-update
 dnf update -y
 cat /etc/redhat-release

Update Issues

Stuck at 99%

Edit any that get stuck at 99% as shown below.

 1. cd /etc/yum.repos.d
 2. vi /etc/yum.repos.d/almalinux.repo
    For any enabled repo (enabled=1)
    a. Comment out mirrorlist=
    b. Enable baseurl=

As needed (sub repos still stuck at 99%):

 mv <file>.repo <file>.repo.bak
 mv almalinux-ha.repo almalinux-ha.repo.bak  

GPG check FAILED

Linux 8 Alma Bug

  -- QC GPG key
  rpm -q gpg-pubkey-ced7258b-6525146f
     gpg-pubkey-ced7258b-6525146f

    -- If you get below error, import the new AlmaLinux 8 GPG key to the rpm database.
    package gpg-pubkey-ced7258b-6525146f is not installed

     -- Import Cmd
    rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux


  -- Re-Attempt Update
  dnf update -y

Improving Update Performance

vi /etc/dnf/dnf.conf

 max_parallel_downloads=10
 fastestmirror=1

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

cpu

  • Display number of cpu's: nproc
  • CPU Info: lscpu
  • Get CPU Usage: sar -u 2 5
  • Which process is monopolizing or eating the CPUs:
    • ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10
    • ps -eo pcpu,pid,user,args | sort -r -k1 | less
  • nmon -> gnome-system-monitor

crontab

  • List: crontab -l
  • Edit: crontab -e
# Min.  Hour  Day   Month  Day of Week
# 0-60  0-23  1-31  1-12   0-6 (0 is Sunday)
TERM=xterm
OUT=/u01/app/scripts/out
SCRIPTS=/u01/app/scripts

# Every 5 Minutes
*/5 * * * * $SCRIPTS/myscript.sh

# Every 5 Minutes Between 1am and 7am
*/5 01-07 * * * $SCRIPTS/myscript.sh

# Output Job to File
0 13 * * 0 $SCRIPTS/myscript.sh > $OUT/myscript.sh.out 2>&1
  • Setting TERM in your crontab can avoid output that will create mail entries. Ex: TERM=xterm
  • Using 2>&1 with an .out file can also avoid mail entries.

Run Job Last Day of Month

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

Example

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

Inversely (dont run job on last day)

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

Run Script on Boot

 @reboot /u01/app/scripts/onBoot/initNFS.sh > /u01/app/scripts/out/initNFS.out 2>&1

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 *
quit

Vars in cron

Cron is not a shell, it does not parse commands in the same way that a shell does. That said, the following methods\examples do work on Redhat related Linux crons.

OUT=/u01/app/scripts/out
SCRIPTS=/u01/app/scripts
sDay=date +%d
0 03 * * 2 [ "$($sDay)" != "01" ] && $SCRIPTS/optTableList.sh > $OUT/optTableList.out 2>&1

Notice

  • The vars have no quotes when set.
  • The vars have no space after the last character.
  • $sDay itself is wrapped in $() to execute it in a separate shell.

crontab Job Script Suggestions

  • Check what your cron environment actually sees and adjust accordingly:
    * * * * * env > /tmp/env.out
    env.out will show what your cron environment sees. You may find cron is using the Bourne shell by default.
  • Your crons may need:
    SHELL=/bin/bash
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
  • Export vars, i.e. use: set -a
  • Make a var to your scripts path in your parent script.
    Ex: DIR_SCRIPTS="/u01/app/scripts"
  • Sourcing global vars during script preamble.
    Ex: source $DIR_SCRIPTS/inc_sysvars.sh
  • Include your scripts dir in your PATH.
  • Change (cd) to your scripts dir from your main parent script.
  • Ensure PATH, ORACLE_SID and ORACLE_HOME in your script.
    Alternatively place in crontab.
Preamble Example
set -a; DIR_SCRIPTS="/u01/app/scripts"; source $DIR_SCRIPTS/inc_sysvars.sh
scrFullName=$(basename "$0"); scrName=${scrFullName%.*}
scrHistLog="$DIR_LOGS/$scrName.hist.log"; scrOutLog="$DIR_OUT/$scrName.out"

A crontab entry without >/dev/null 2>&1 will send an email to the owner of the crontab. The email will contain the script/program output.

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.

My IP Address

Show the IP address you connected to this system with.

  curl ifconfig.me

Show this systems IP address.

 hostname -I
 10.230.2.45 192.168.122.1

hostname, Changing

Change a systems hostname (to lnx02 example).

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

VBox: resolv.conf

Set IP to current system.

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

VBox: dnsmasq

Set IP (listen-address) to current system.

  1. vi /etc/dnsmasq.conf
expand-hosts
local=/localdomain/
listen-address=127.0.0.1
listen-address=192.168.56.71
bind-interfaces
  1. enable dnsmasq.service
  2. service dnsmasq restart
  3. If needed: shutdown -r now

One Line: enable, restart, status

systemctl enable dnsmasq.service; systemctl restart dnsmasq.service; service dnsmasq status

blkid

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"

cdrom\dvd

Common Commands

  cat /etc/fstab

  lsblk
     sr0 ... rom
  ls -l /dev | grep '\->'
       cdrom -> sr0
  ls -l /dev/cdrom
     cd /dev/cdrom
        -bash: cd: /dev/cdrom: Not a directory

  To eject a cdrom\dvd:
    eject
  In case this command doesn't work, you can try the following:
    eject /dev/cdrom
    eject /dev/cdrw
    eject /dev/dvd
    eject /dev/dvdrom
    eject /dev/dvdrw
  To close the drive, use the following command:
    eject -t

Date, set

date -s "string" Format: DD MON YYYY HH:MM:SS

 root> date -s "05 JAN 2022 07:10:00"

fdisk

fdisk can be used to create LINUX disk partitions up to 2 TB.

  • Use scan and lsblk to ensure your OS can see the disk for new partition.
  • If for RAC shared disk, you only need to fdisk from node 1.
    Other nodes will see the new partition after /sbin/partprobe run.
  • For disk volumes larger that 2 TB, create them as EXT4 using parted.
  • Disks for ASM only need to be partitioned, i.e. not formatted and mounted.

Prerequisite

Scan for new disk hardware (ex: for sdd):

 for host in /sys/class/scsi_host/*; do echo "- - -" | sudo tee $host/scan; ls /dev/sd* ; done
 ...
 /dev/sdd

List Disks:

 lsblk

 NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
 fd0           2:0    1    4K  0 disk
 sda           8:0    0  1.3T  0 disk
 ├─sda1        8:1    0    1G  0 part /boot
 ├─sda2        8:2    0   35G  0 part /home
 └─sda3        8:3    0  1.2T  0 part
   ├─ol-root 249:0    0  1.2T  0 lvm  /
   └─ol-swap 249:1    0   17G  0 lvm  [SWAP]
 sdb           8:16   0  2.3T  0 disk
 └─sdb1        8:17   0  2.3T  0 part /u02
 sdc           8:32   0  2.3T  0 disk
 └─sdc1        8:33   0  2.3T  0 part /u03
 sdd           8:48   0  2.3T  0 disk
 sr0          11:0    1 1024M  0 rom

Procedure

  1. Run: fdisk /dev/sdd
  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).
    If you dont want partition to use entire disk you can specify a value also (example +50G).
  7. Command (m for help): w to write changes to disk.

Replace /dev/sdd with your disk name.

Shortcut Example

 fdisk /dev/sdd
 n
 [Enter] x 4
 w

lsblk now shows the attached partition (sdd1)

 sdd               8:16   0    8G  0 disk 
 └─sdd1            8:17   0    8G  0 part

Repeat above steps for each disk.

fdisk Session

Adding a new volume (/dev/sdc) as /u03

 -- Check HW detected and ensure Not mounted
 lsblk

 -- Create Partition
 fdisk /dev/sdc

 -- Create xfs Filesystem
 mkfs.xfs -f /dev/sdc1

 -- QC
 file -s /dev/sdc1
 /dev/sdc1: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs)

 -- Create Mount Points
 cd /
 mkdir /u03
 mount /dev/sdc1 /u03

 -- Check
 mount | grep /dev/sdc1
 /dev/sdc1 on /u03 type xfs (rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota)
 df -h
 /dev/sdc1 1022G  7.2G 1015G   1% /u03

 -- Make Mount Point Permanent
 vi /etc/fstab
 /dev/sdc1  /u03 xfs  defaults  0  0

 -- Test /etc/fstab via command
 mount -a

To mount using UUID go here.

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.

/sbin/partprobe

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
 ...

Change

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

DNS

For a Linux system to resolve system names it minimally needs two entries in the /etc/resolv.conf file: search & nameserver.

  • search: (domain) is required for some name resolution calls and
  • nameserver: needs to be your DNS server IP(s).
 search mydomain.local
 nameserver 192.168.1.200
 nameserver 192.168.1.201

You can have multiple entries for each. Normally though you only have one search entry and 1 or more nameserver entries.

Download Oracle Linux

 0) https://edelivery.oracle.com/osdc/faces/SoftwareDelivery
 1) Search for 'Oracle Linux'
 2) From the search result find required version of OL and click on: 
    Add to cart (DLP: Oracle Linux 7.6 (Oracle Linux ).
 3) After adding to cart, click on: Selected Software.
 4) Select platform from the drop down list and click Continue.
 5) Review and accept the terms check box, click Continue.
 6) Select V980739-01.iso and uncheck other selections. 
 7) Click download.

Refer: What is the Use for the Various Installation Media Provided on eDelivery for Oracle Linux? (Doc ID 2135942.1 )

Files

Date\Time, Changing

touch -t yyyymmddhhmm
touch -t 201712151500 myfile.txt

Delete Files Older Than n Days (+)

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

Delete Files Created in the Last n Days (-)

find /stuff -maxdepth 1 -type f -name '*.tar' -mtime -30 -delete

Delete Files Older Than x Minutes

find /stuff -maxdepth 1 -type f -name '*.tar' -mmin +360 -delete

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

-mmin

  1 hour  = 60        1 Day  = 1440
  4 Hours = 240       1 Week = 10080
  6 Hours = 360
 12 Hours = 720

Delete Directory and All Files in It

cd /my_parent_dir
rm -r -f my_sub_dir_to_delete

Delete File by inode Number

This is useful when you cannot delete a file by its name.

 -- List file names and inode number (far left field).
 ls -li
 ...
 51447 -rwxr-xr-x 1 root root 61982720 Jan  5 14:05 myfile_42

  -- Delete file using its inode number.
  -- Format: find . -inum <inode_number> -delete
 find . -inum 51447 -delete

Delete All Files With Spaces

rm -- *\ *

rm -i -- *\ *
Use above method if you want a prompt to confirm each file deletion.

Copy Directory and Contents to New Location

 cp -Rvp /Path2Dir/MyDir /Path2Dir/MyDir

 R = copy directories recursively.
 v = explain what is being done.
 p = Preserve permission and ownership with timestamps.

The directory for the destination does not have to be pre-created. It will be created in the process above.

find

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

Find a File
Run updatedb from /etc dir to be able to use.
locate myfile

List Files by Size
ls -lS

Show Newest File
ls -Art | tail -n 1

Show Oldest File
find -type f -printf '%T+ %p\n' | sort | head -n 1

Show All Directories File In
find /u01 -name "*MyString*" -type f -printf '%h\n' > /tmp/find.out; clear; more /tmp/find.out
This method shows a cleaned up output without all the permission denied messages too.

Count Total Files Meeting find Criteria
find /u02/rman/ -maxdepth 1 -type f -name "*.rman" -mtime +1 -print | wc -l

Examples:

  • locate tnsnames.ora
  • find / -name php.ini -print
  • find / -name "myscript*.sh" -printf '%h\n'
  • find / -iname "myscript"
  • find /u01/orasw -iname "myscript.sh"
  • grep "10046_Trace" /u01/app/oracle/diag/rdbms/mydb/mydb1/trace/*.trc
    Finds file containing string.

Find String in Multiple Files
grep -r "SCOTT" /u01/app/scripts/*.sh

Folder and File Sizes

Find folder\files taking up the most space.
Folders

  • cd /parent_folder_with_subfolders_to_check
  • du -shx */

Files

  • cd /folder_to_check
  • du -sh *

Total Size of All Files for Given Day (ex: 2024-03-29)

  • Place on one line.
  • Change path (/u05/rman).
  • Change dates to match day of files desired.

find /u05/rman -type f -newermt 2024-03-29 ! -newermt 2024-03-30 -exec stat --format="%s" {} \; | awk '{total += $1} END {print "Total size:", total/1073741824, "GB"}'

644.743 GB

gzip

Gzip File and Keep Original

New Linux use: -k/--keep

 gzip -k input.file

Older Linux

 gzip < test.txt > test.txt.gz

Immutable

The Immutable flag makes a file unchangeable.

  -- Is File Immutable?
  cd /etc
  lsattr|grep resolv.conf
  ----i----------- ./resolv.conf

  -- Remove Immutable Flag
  chattr -i /etc/resolv.conf
  ---------------- ./resolv.conf

  -- Add Immutable Flag
  chattr +i /etc/resolv.conf
  ----i----------- ./resolv.conf

Permissions (privs)

 # 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

Set For All Sub Dirs or Files

 find /var/www/html/app1 -type d -exec chmod 755 {} \;
 find /var/www/html/app1 -type f -exec chmod 644 {} \;

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

If need be: umount -f <mtpt>
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

Check

 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.
  • Disks for ASM only need to be partitioned, i.e. not formatted and mounted.
 -- Show Existing Partitions
 root> lsblk

 If need be unmount
umount -l /u02
 -- Create Partition: TB Example
 root> parted /dev/sdb
   (parted) 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
   (parted) unit TB
   (parted) mkpart primary 0.00TB 2.30TB
   (parted) print
   (parted) quit

 -- Create Partition: GB Example
 root> parted /dev/sdb
   (parted) mklabel gpt
   (parted) unit GB
   (parted) mkpart primary 0 20
   (parted) print
   (parted) quit

 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
  • Large Disk mkpart Example: mkpart primary 0.00TB 6.00TB
  • Ext4 defaults to a 5% overhead so critical daemons can always write. It also prevents fragmentation when disk over 95% used.
    • If not a boot partition you can reclaim it as so: tune2fs -m 0 /dev/sdb1
    • To allocate 1\2 of 1%: tune2fs -m .5 /dev/sdb1
    • To check number of blocks allocated: tune2fs -l /dev/sdb1 | grep 'Reserved block count'

gparted

gparted is a free partition editor for graphically managing your disk partitions.

Configure repos

vi /etc/yum.repos.d/public-yum-ol7.repo

[ol7_developer_EPEL]
name=Oracle Linux $releasever Development Packages ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL7/developer_EPEL/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

Add the above section to bottom of file if it does not exist.

Install

 yum install gparted.x86_64 -y

Run

 gparted

Redhat (untested)

 vi /etc/yum.repos.d/public-yum-ol7.repo
 1. vi /etc/yum.repos.d/public-yum-ol7.repo
 2. Find ol7_addons
 3. Set enabled=1

 yum install epel-release -y
 yum install gparted -y

HCtrl ID (SCSI\ATA)

 lsblk -S
 NAME HCTL       TYPE VENDOR   MODEL            REV TRAN
 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

Resize Partition

Changes are made immediately once End value made.

 -- Install\Update Parted
 yum install parted -y         Some earlier versions dont have the resizepart command.

 -- Run parted
 root> parted
 (parted) select /dev/sdX       Replace X with your disk device name.
 (parted) print                 Confirm desired disk\partition selected. Note End and Size.

 -- Resize Partition
 (parted) resizepart
            Partition number? 1 Enter the number of your partition to resize.
            End [nn.nGB]? 10G    Change this to the max value as needed.
 -- Confirm Changes OK
 (parted) print                 Note new Start, End and Size
 (parted) quit
 lsblk                          Should show disk using new partition value.

 --If needed, Extend File System (XFS).
 xfs_growfs /dev/sdX      Replace X with your disk device name.
 xfs_growfs /dev/sdb1
 df -h

Oracle Dirs to Routinely Cleanup

#!/bin/bash
# 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 12.1.0.2

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/12.1.0.2/db_1/log/lnx01/client -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 {} \;

# RMAN
#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"

firewall, Disable

  -- Individual Commands
 systemctl disable firewalld
 systemctl stop firewalld
 systemctl status firewalld
 service iptables stop
 chkconfig iptables off

  -- All Commands (one line)
 systemctl disable firewalld; systemctl stop firewalld; service iptables stop; chkconfig iptables off; systemctl status firewalld

gedit, Set Values (window size etc.)

Show Values

 gsettings list-recursively|grep gedit|grep window

Set Value

 gsettings set org.gnome.gedit.state.window size '(1024,768)'

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.)

nautilus

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

gedit

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

GNOME, Set to Classic (in Linux 8)

In Linux 8 the default Gnome GUI uses Wayland. Set to Classic by:

  1. At the login screen select desired.
  2. Enter your password (dont press enter yet).
  3. Click the options icon and select: Classic (X11 display server).
  4. Click [Sign In]

GNOME Shell Open Terminal

Linux 8, enable right-click: Open Terminal for root.

  1. Actvities
  2. Type: Terminal
  3. GNOME Shell Open Terminal
    1. [Install]
    2. [Extension Settings]
    3. GNOME Shell Open Terminal: [ON]

Alternatively set gnome to use Classic rather than new Wayland GUI for each user.

Interface, Bounce

Format: if[up|down] <InterfaceName>

ifdown ens192
ifup ens192

To ensure interface (ens192) bounces afer disconnect:

 1. Edit interface config file.
    vi /etc/sysconfig/network-scripts/ifcfg-MyIntNameHere
 2. Bounce
    nohup sh -c 'ifdown ens192; ifup ens192'

Display All Network Connections to Your System

 netstat -atp
 nmap localhost

Use -c for continuous: netstat -atp -c

Gateway, Change from Command Line

 -- Confirm Interface Name to Change
 ifconfig
 ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
 ...

 -- Note Current Gateway Value
 netstat -rn
 Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
 0.0.0.0         10.230.0.41     0.0.0.0         UG        0 0          0 ens192

 -- Change
 cd /etc/sysconfig/network-scripts
 ls -l ifcfg-*
 -rw-r--r--. 1 root root 415 Jan 30  2017 ifcfg-ens192

 vi ifcfg-ens192
 GATEWAY=10.230.0.42

 Also check\edit this file if used:
 cat /etc/sysconfig/network

 -- Activate
 ifdown ens192
 ifup ens192

 -- Confirm Value Changed
 netstat -rn
 Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
 0.0.0.0         10.230.0.42     0.0.0.0         UG        0 0          0 ens192

GUI options: nm-connection-editor, system-config-network, redhat-config-network or network-admin.

Interface, Reset Counters Without Bouncing Interface

 -- Determine Interface to Reset (Ex: enp0s9) 
 ifconfig

 -- 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

Set (eth0 example)

vi /etc/network/interfaces

 auto eth0
 iface etho0 inet static
   address 192.168.1.42
   netmask 255.255.255.0
   network 192.168.1.0
   gateway 192.168.1.1
   broadcast 192.168.1.255
   dns-nameservers 192.168.1.1 8.8.8.8

GUI method here.

Port, ping

 nmap -p <port> <host>
 nmap -p 1521 lnx01

yum install nmap -y

Is Port Beings Used?

 lsof -P |grep 1521
 netstat -tulpn|grep 1521
 netstat -ltnp | grep -w ':1521'
 fuser -v -n tcp 1521

What process is using a port?

 netstat -tulpn|grep 1521
 tcp6   0   0    :::1521   :::*   LISTEN   4485/tnslsnr
 ls -l /proc/4485/exe
 lrwxrwxrwx 1 oracle oinstall 0 Jan 27 13:43 /proc/4485/exe -> 
 /u01/app/oracle/product/12.1.0.2/dbhome_1/bin/tnslsnr 

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
  saved_entry=1

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

  Test
  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: dbMaint.sh

  • View program: ps -ef|grep dbMaint
  • Kill by name: pkill dbMaint.sh
  • Kill by Process ID:
    • Get Process ID: pgrep stdmaint OR ps -ae|grep dbMaint
    • 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.username, 
       b.sid, b.serial#,
       a.users_executing, 
       a.sql_text
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;

From the above you can kill the corresponding Oracle session if need be.

GUI Apps

  • ASM Cfg Assistent: asmca
  • Calculator: gnome-calculator
  • GEdit: gedit
  • Disk Manager: gnome-disks
  • File Mgr: xdg-open .
  • Firefox: firefox
  • Network Connections:
    • nm-connection-editor Maintains cfg file => /etc/sysconfig/network-scripts/ifcfg--<IntName>
    • redhat-config-network
    • network-admin
  • System Monitor: gnome-system-monitor

The command-line name 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 actual program may be here: /usr/bin

  ls -l /usr/bin/gnome-*

History

Commands

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

 /home/oracle/.bash_history

Logins

last [-t YYYYMMDDHHMMSS] -w

 -w Display full user and domain names in the output.
 -t Display the state of logins as of the specified time.
 last -t 20200901070000 -w | more

MTU

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>
    MTU=9000

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

GUI Method

 1. nm-connection-editor
 2. Select\Set: Priv Interface (ex: enp0s10 192.168.10.1)
      Ethernet Tab -> MTU: 9000
 3. Bounce Interface 
      a. ifdown enp0s10
      b. ifup enp0s10
      c. ifconfig

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

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

ping

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

--- 10.15.124.13 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 10.15.124.14 (10.15.124.14) 8972(9000) bytes of data.
8980 bytes from 10.15.124.14: 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 10.15.124.13 -c1 -M do -s 9999
PING 10.15.124.13 (10.15.124.13) 9999(10027) bytes of data.
ping: local error: Message too long, mtu=9000

iperf

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.

Restart Network Services

 service network restart

Mount Disk Using UUID

xfs

 1. Confirm newly added disk (sdb).
    # lsblk
    NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
     sdb           8:16  0    1G  0 disk
 2. Parition disk.
    # fdisk /dev/sdb
    # /sbin/partprobe
    # lsblk
 3. Create File System
    # mkfs.xfs -f /dev/sdb1
 4. Create mount point.
    # cd /
    # mkdir /u01
 5. Determine the UUID of Device (sdb1).
    # blkid /dev/sdb1
    /dev/sdb1: UUID="09fa9d84-bf89-4eee-bac6-842d968574c6" TYPE="xfs"
 6. Make an entry in the /etc/fstab file for the new disk.
    # vi /etc/fstab
    UUID=09fa9d84-bf89-4eee-bac6-842d968574c6 /u01 xfs defaults 0 0   
 7. Test
    # mount -a
    # df -h
  • mount -a causes all filesystems in fstab to be mounted as indicated.
  • Show disk labels and UUID's: lsscsi -iss or lsblk -f
  • It is a good idea to also reboot and re-check mount points.

ext4

 1. Confirm newly added disk (sdc).
    # lsblk
    NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
     sdc           8:16  0    3T  0 disk
 2. Parition disk.
    # parted /dev/sdc
       (parted) mklabel gpt
       (parted) unit TB
       (parted) mkpart primary 0.00TB 3.00TB
       (parted) print
       (parted) quit
    # lsblk
 3. Create File System
    # mkfs.ext4 /dev/sdc1
 4. Create mount point.
    # cd /
    # mkdir /u03
 5. Determine the UUID of Device (sdc1).
    # blkid /dev/sdc1
    /dev/sdc1: UUID="1401c3b2-766f-4376-a87a-3f4b8d3cb83e" TYPE="ext4"
 6. Make an entry in the /etc/fstab file for the new disk.
    # vi /etc/fstab
    UUID=1401c3b2-766f-4376-a87a-3f4b8d3cb83e /u03 ext4 defaults 0 0   
 7. Test
    # mount -a
    # df -h
  • mount -a causes all filesystems in fstab to be mounted as indicated.
  • If above properly mounts disk reboot and re-check mount points.

mpstat

Report processors related statistics. mpstat [interval] [count]

 mpstat 1 5

This is actually the optimal quick check for disk performance via %iowait.

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.

Linux Disk Discovery 101

There is no expectation, by design, that bus number and device naming will be persistent/consistent across reboots. Device discovery is performed both in parallel and asynchronously.

The scsi bus numbers and device names are handed out in callback order -- that is after a HBA completes initialization it callsback into the kernel to register itself. This is done asychronously in terms of any other HBAs in the process of being initialized... first one with the callback gets the next available bus number. The same with device names.

Linux is built with the expectation that disks and their contents will be accessed via self-identification. With disks self-identification is done via WWIDs, and for content such as filesystem or LVM/PV/LV... by UUIDs.

Working with WWIDs is how multipath devices are created and using aliases within /etc/multipath.conf users can assign persistent names to a multipath device. Ditto with individual disks, using udev rules triggering off of WWIDs, symbolic links can be created with persistent names for a device, for example asm01 to always point to a specific disk. The same is true for booting or mounting filesystems, a UUID can be specified as such UUIDs are self-identifying and persistent across boots.

Add Disk Session

Mount new disk (sdd) as /u05.

Create Partition
  lsblk
  fdisk /dev/sdd

Create File System
  mkfs.xfs -f /dev/sdd1
  file -s /dev/sdd1

Create Mount Point
 cd /
 mkdir /u05

Mount and Test
  mount /dev/sdd1 /u05
  mount | grep /dev/sdd1
  df -h

Create Dir (oradata)
  mkdir /u05/oradata
  chown oracle:oinstall /u05/oradata
  chmod 777 /u05
  chmod 765 /u05/oradata

Bind Disk via UUID
  blkid /dev/sdd1
    /dev/sdd1: UUID="334458a8-db6a-42a6-9947-b40f96d8f488" TYPE="xfs"
  vi /etc/fstab
    UUID=334458a8-db6a-42a6-9947-b40f96d8f488 /u05 xfs defaults 0 0
  umount /u05

Test
  mount -a
  df -h

Partition Change Session

Checks Pre\Post Changes

df -h /opt

lvs -v
  LV   VG     #Seg Attr       LSize    Maj Min KMaj KMin Pool Origin Data%  Meta%  Move Cpy%Sync Log Convert LV UUID                                LProfile
  home centos    1 -wi-ao----   50.00g  -1  -1  253    2                                                     kjy48G-eB48-Sjbd-PKfq-Wn2P-XBrE-bPZQmC
  root centos    2 -wi-ao---- <210.20g  -1  -1  253    0                                                     VaoQJL-FhNQ-uHa6-Usxf-JPmW-ErMh-GTEz5Z
  swap centos    1 -wi-ao----   18.00g  -1  -1  253    1                                                     kyNBpU-E0JU-VG36-Xpf8-QzX2-byh6-HlKu3y
vgs -v
  centos wz--n- 4.00m   1   3   0 <278.20g    0  2ez176-obtF-u307-ZOF7-PiCB-3T99-JgnmQy
pvs -a
  PV         VG     Fmt  Attr PSize    PFree
  /dev/sda1              ---        0     0
  /dev/sda2              ---        0     0
  /dev/sda3  centos lvm2 a--  <278.20g    0
df -h
  Filesystem               Size  Used Avail Use% Mounted on
  devtmpfs                  63G     0   63G   0% /dev
  tmpfs                     63G  184K   63G   1% /dev/shm
  tmpfs                     63G   11M   63G   1% /run
  tmpfs                     63G     0   63G   0% /sys/fs/cgroup
  /dev/mapper/centos-root  211G   19G  192G   9% /
  /dev/sda2               1014M  240M  775M  24% /boot
  /dev/sda1                200M   12M  189M   6% /boot/efi
  tmpfs                     13G   12K   13G   1% /run/user/42
  /dev/mapper/centos-home   50G  2.3G   48G   5% /home
  tmpfs                     13G     0   13G   0% /run/user/0

Actions

umount /dev/mapper/centos-home
lvremove /dev/mapper/centos-home
lvcreate -L 50GB -n home centos
mkfs.xfs /dev/mapper/centos-home
mount /dev/mapper/centos-home
df -h
tar -xvfz /root/home.tgz -C /home
pwd

tar xvfz /root/home.tgz -C /home
cd /home
ll
df -h
lvextend -r -l +100%FREE /dev/mapper/centos-root
df -h

Memory

Free

 free -h -t
 free -m
 cat /proc/meminfo|grep -E MemTotal\|MemFree

 cat /proc/meminfo|grep -E MemTotal
 cat /proc/meminfo|grep -E MemFree
 cat /proc/meminfo|grep -E Active\|SwapTotal

Usage

 vmstat 1 20

chronyd, Configure System as NTP Client

Status

 systemctl status chronyd
 chronyc sources

Configure

 vi /etc/chrony.conf

Enter Your NTP\Timer Server IP

 server 192.168.56.42

If Firewall Enabled, Add NTP Exception

 firewall-cmd --permanent --add-service=ntp
 firewall-cmd --reload

Make Changes Active

 systemctl restart chronyd
 systemctl status chronyd
 chronyc sources

disable

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

enable

 systemctl enable chronyd
 systemctl enable chronyd.service    
 systemctl start chronyd
 systemctl status chronyd

Configure NTP (ntpd)

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.

In Oracle 8.4 and later you cannot use ntp. You must use chronyd.

Disable chrony

  1. systemctl stop chronyd
  2. systemctl disable chronyd.service
  3. systemctl disable chronyd
  4. mv /etc/chrony.conf /etc/chrony.conf.orig
  5. systemctl status chronyd

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

Install ntpd Package

  1. yum install -y ntp
  2. systemctl enable ntpd
  3. systemctl start ntpd
  4. systemctl status ntpd

systemctl enable ntpd; systemctl start ntpd; systemctl status ntpd

Configure Parameter Files

/etc/sysconfig/ntpd
OPTIONS entry:
OPTIONS="-g -x -u ntp:ntp -p /var/run/ntpd.pid"

  • -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).

/etc/ntp.conf
Server entry with prefer clause:
server <NTP_Auth_Server_IP> prefer

Restart NTP

  1. systemctl restart ntpd
  2. ntpq -p
In a few minutes you should see a * next to your ntp server.
  remote    refid           st t when poll  reach   delay   offset  jitter
  ========================================================================
  *myntpsrv 192.168.1.42     2 u 778  1024    377   5.018   -0.054  0.183

Display

-- Status Checks

  • ntpq -p
  • ntpdc -c loopinfo
  • ntpstat (quick check to determine if NTP is in sync.)
  • timedatectl <== Alert: Can produce inaccurate results!
  • For RAC as grid user: cluvfy comp clocksync -n all -verbose

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

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

NTP Misc

-- Stop|Disable

  • systemctl stop ntpd
  • systemctl disable ntpdate

-- 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.

-- Redhat NTP /etc/hosts Entries

# Redhat NTP
162.159.200.1   0.rhel.pool.ntp.org
173.255.192.10  1.rhel.pool.ntp.org
162.159.200.1   2.rhel.pool.ntp.org
209.51.161.238  3.rhel.pool.ntp.org

As of 10:17 AM 11/22/2019.

NTP Troubleshooting

Open Office (Apache AKA AOO)

 -- Init Install Dir
 su -
 mkdir -p /u01/sw/aoo
 chmod -R 775 /u01/sw/aoo  

 -- Download
 1. Go to download page.
 2. Select: Linux 64-bit (x86-64) (RPM)  -  English  -  4.1.5 (or latest version)
 3. Select: [Download Full Installation]
    Ex File Downloaded: Apache_OpenOffice_4.1.5_Linux_x86-64_install-rpm_en-US.tar.gz

 -- Copy to Linux System and Extract
 1. cp /media/sf_sw/aoo/Apache_OpenOffice_4.1.5_Linux_x86-64_install-rpm_en-US.tar.gz /u01/sw/aoo/ 
 2. cd /u01/sw/aoo
 3. tar -xvzf Apache_OpenOffice_4.1.5_Linux_x86-64_install-rpm_en-US.tar.gz
    The name of the installation directory will be the language abbreviation: en-US.

 -- Perform rpm Install
 1. cd /u01/sw/aoo/en-US/RPMS
 2. rpm -Uvih *rpm
    By default, this will install Apache Open Office in your /opt directory.
 3. cd /u01/sw/aoo/en-US/RPMS/desktop-integration
 4. rpm -Uvih openoffice4.1.5-redhat-menus-4.1.5-9789.noarch.rpm

 -- Create Desktop Shortcut
 1. Login as your Linux user account.
 2. Left Drag-n-Drop Applications -> Office: Open Office 4.x to desktop.

Package Install\Uninstall\Status

FTP package (vsftpd) used in these examples.

Install Package

 yum install vsftpd -y
 chkconfig --levels 235 vsftpd on
 service vsftpd start

Uninstall Package

 -- Stop & Disable Service
 service vsftpd stop
 chkconfig --levels 235 vsftpd off  

 -- Remove Pkg
 1. Get exact pkg name
    rpm -qa | grep vsftp
    vsftpd-3.0.2-22.el7.x86_64
 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 shows startup status of all packages and run levels.

Enable EPEL Repository

  wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  rpm -ivh epel-release-latest-7.noarch.rpm
  clear;yum repolist|grep epel

PackageKit, Disable

 systemctl stop packagekit; systemctl disable packagekit; systemctl status packagekit

Processes

 ps -ef|grep <string>
 ps -ef|grep mon
 pstree -a

prompt, Setting Colors

 Export PS1
 White on Red
 export PS1="\[$(tput setab 1)$(tput setaf 7)\]\u@\h:\w $ \[$(tput sgr0)\]"
 Example:lnx01:/mydir $

 Blue on White
 export PS1="\[$(tput setab 7)$(tput setaf 4)\]\u@\h:\w $ \[$(tput sgr0)\]"
 Example:lnx01:/mydir $

 Set Alias
 alias setp='export PS1="\[$(tput setaf 7)\]\u@\h:\w $ \[$(tput sgr0)\]";export PS1="\[$(tput setab 1)\]\u@\h:\w $ \[$(tput sgr0)\]"'
 alias resetp='export PS1="\[\u@\h \W]\$\]"'

 Safe Putty Session tput Colors
 0 – Black
 1 – Red
 2 – Green
 3 – Yellow
 4 – Blue
 5 – Magenta
 6 – Cyan
 7 – White
 75 and other 8-bit colors can work. Test for your system.

 Show Current Prompt Values
 echo $PS1
 [\u@\h \W]\$

 Reset
 export PS1="\[\u@\h \W]\$\]"

Putty

Core Recommended Settings

 - Session
   Port: 22
   Conn Type: (x) SSH
 - Connection
   Seconds between keepalives: 30
   + SSH -> X11
            [x] Enable X11 Forwarding
            X display location: localhost0
            (x) Remote-Magic-Cookie-1
  • Console Colors
  • If localhost0 does not work add a colon. Ex: localhost:0.

Create New Session Using Color-Theme

  • Get color-themes.
  • View color-themes.
 0. Close all Putty sessions.
 1. Change Putty Default Session by Double-clicking on desired color-theme .reg file.
 2. Launch Putty
    a. Select "Default Settings".
    b. Press [Load]
 3. Set Values for New Session
    a. Hostname (or IP): MyHostnameOrIpHere
    b. Saved Sessions:   MyNewSessonNameHere
 4. Press [Save]

Reset your new putty session default back by double clicking on the desired .reg file. Example: Solarized Darcula.reg

Run Putty From Cmd Line

putty.exe -ssh [user]@[host] [port] -pw [Password]

 putty.exe -ssh root@1.1.1.1 22 -pw MyPassword

Common Putty Intial Connection Message

When configured for X11:

 Post X11 forwarding
 /usr/bin/xauth:  file /root/.Xauthority does not exist

KWrite

  • GEdit does not support X-Window redirection well. It cannot resize windows etc..
  • Use KWrite if you need a GUI editor from putty.
  • KWrite docs.

Install\Usage

 yum install kwrite -y
 /usr/bin/kwrite

scp

scp sets up a tunnel using ssh and then transfers the file over that tunnel, with an ssh command on the far end to catch the file as it comes over. If the hostname does not work try the IP and vice-versa.

Pull (get file from remote server)

  scp RemoteUser@RemoteHost:FullPath2RemoteFile /LocalDestDir 
  scp oracle@10.4.0.152:/tmp/MyDB.dmp /u02/exports

Push (copy file to remote server)

  scp /SrcPath/SrcFilename RemoteUser@RemoteHost:/DestPath/DestFilename
  scp /u02/exports/MyDB.dmp oracle@10.4.0.152:/tmp/MyDB.dmp

Notice with push the file to copy needs to be specified on both sides.

Automate Password Prompt via sshpass

yum install wget
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/sshpass-1.05-1.el6.x86_64.rpm
rpm -ivh sshpass-1.05-1.el6.x86_64.rpm
which sshpass

sshpass -p 'mypassword' scp /temp/myfile.dmp oracle@192.168.1.42:/u02/exports

sshpass rpm is here.

scp to Samba Mount Point Method

 sshpass -p 'MyrootPw' scp /u03/exports/oradb1.20180716.tar root@localhost:/mnt/smb01/exports

This method allows you to copy a file to a mount point that only allows root using a non-root account (oracle etc.).

sendmail

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

Installation

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

Relay Server Configuration (if used)

  • cp /etc/mail/sendmail.mc /etc/mail/sendmail.mc.orig
  • vi /etc/mail/sendmail.mc
    Note: Remove dnl entry at the beginning of line to uncomment the line.
    • Uncomment (dnl) 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.
    MASQUERADE_AS(`mydomain.com')dnl
    • Uncomment FEATURE(masquerade_envelope).
    FEATURE(masquerade_envelope)dnl
  • Rebuild
    • cd /etc/mail
    • make
    • service sendmail restart

sendmail Service

 service sendmail [stop|start|restart|status]

Monitoring

User mail files dir: /var/spool/mail

 tail -f /var/log/maillog

Usage

mail -s "Subject" ReceverEmailAddress@Domain < PathToEmailMsgFile

mail -s "Email Test 1" michaele@mydomain.com < /dev/null
mail -s "Email Test 2" michaele@mydomain.com < /tmp/MyEmailMsg.txt
mail -s "Email Test 3" "em1@abc.com em2@abc.com" < /dev/null
mail -s "Email Test: $ORACLE_SID" michaele@sccu.com < /dev/null

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

Queue

View

 sendmail -bp
   /var/spool/mqueue (1 request)
   -----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
   30DEXFwt2907604*       2 Fri Jan 13 09:33 <oracle@orlldorav01.sccu.local>
                                             <michaele@mydomain.com>
   Total requests: 1

   /var/spool/mqueue is empty
   Total requests: 0

Clear (AKA Delete/Flush) Mail Queue

 -- One Line
 echo 'd *' | mail -N

 -- Manually: Option 1
 mail -N
 d *
 quit

 -- Manually: Option 2
 cd /var/spool/mqueue/
 ls
 rm * -f

Stop root Email Flooding

 -- Get root configed email files.
 cd /var/spool/mqueue
 grep -ri mailto /etc/cron*
 /etc/cron.d/0hourly:MAILTO=root
 /etc/crontab:MAILTO=root

 -- Comment Out MAILTO=root
 cd /etc/cron.d
 cp 0hourly 0hourly.bak
 vi 0hourly
 #MAILTO=root

 cd /etc
 cp crontab crontab.bak
 vi crontab
 #MAILTO=root

Make sure to uncomment after email spam source fixed.

Services

httpd service used in these examples.

List

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

Stop|Start|Bounce|Status

 systemctl stop httpd
 systemctl start httpd
 systemctl restart httpd.service
 systemctl status httpd 

chkconfig

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

Shutdown or Reboot

 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.

ccze (Colorize Log)

 yum install ccze -y

 tail -f /var/log/messages | ccze
 tail -f /u01/app/oracle/diag/rdbms/oradb/oradb/trace/alert_oradb.log| ccze

If need be, get rpm here

Redhat SOS Report Generation

 -- Install
 # yum install sos

 -- Standard Report Run (outputs file to /tmp)
 # sosreport

 -- List Plugins
 # sosreport -l > /tmp/sos_info.txt

 -- Example Custom Runs
 Ex 1: Disable filesys, nfs and nfsganesha plugins.
 # sosreport -n filesys,nfs,nfsganesha

 Ex 2: Disable memory and samba plugins, turn off rpm -Va collection:
 # sosreport -n memory,samba -k rpm.rpmva=off

 -- Help Screen
 # sosreport --help

You might want to make the files readable for transfer: chmod 655 /var/tmp/sosreport-<reportname>.tar.xz

Clear Swap

To clear the swap memory on your system cycle the swap off and on.
Be sure you have the RAM to support this operation

 free -m
 swapoff -a

 swapon -a
 free -m

 swapon -s

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
    lsblk

sshd Logging, Enabling

Used to debug SFTP and related transfers.
1. Edit /etc/ssh/sshd_config and change line below as shown:

 # Default
 Subsystem       sftp    /usr/libexec/openssh/sftp-server

 # Change
 Subsystem   sftp    /usr/libexec/openssh/sftp-server -l VERBOSE

2. Restart Service

  service sshd restart
  OR
  systemctl restart sshd.service 

Corresponding log messages go to: /var/log/secure (not to /var/log/sftp.log).

Disable root Logging in via SSH

 1. Edit the /etc/ssh/sshd_config
 2. Add\Edit entry as so: PermitRootLogin no
 3. service sshd restart

sudo

sudo can be used to allow a standard user to run a privileged command.

Example: Allow oracle user to run any command.

 root> visudo
 Opens the sudo vi editor.

At end of file add the following lines:

 # Custom Changes
 oracle ALL=(ALL:ALL) ALL
 oracle ALL=(ALL) NOPASSWD:ALL

Usage Example

 oracle> sudo unmount /mnt/u99

Useful Links

  • For more info go here.
  • Redhat page here.
  • Limiting commands example here.

tab, complete (enable)

 locate bash_completion.sh
 $ source /etc/profile.d/bash_completion.sh 

tar

Create (tar all files in current dir)

 tar -cvf scripts.tar * [options]
 tar -czvf /u03/OraWiki/html.tar.gz /var/www/html/*
  • z: gzips (.gz) files.
  • Delete tar'd files option: --remove-files scott*.dmp
  • Exclude files otpion: --exclude '*.tar'

Create from List Example

 D1=$(date --date="yesterday" "+m%d")0000;
 D2=$(date "+m%d")0000; 
 touch -t $D1 startdate.tmp
 touch -t $D2 enddate.tmp
 find /mydir -maxdepth 1 -type f -name '*.tr?' -newer startdate.tmp -a ! -newer enddate.tmp > files.lst
 tar -cvf /u03/trace/$D1.tar -T files.lst --remove-files

Extract

 tar -xvf scripts.tar
 tar -xvf /path2TarFile/MyDBFullExp.20190701.tar -C /Path2ExtractFiles 

List Contents:

 tar --list --file=scripts.tar

telnet

Port Check

telnet [host] [port]

 telnet 192.168.1.42 5500

 -- OK
 Trying 192.168.1.42...
 Connected to 10.4.0.165.
 Escape character is '^]'.

 -- Could Not Connect
 Trying 192.168.1.42...
 telnet: connect to address 10.4.0.165: Connection refused

nmap can be used to ping ports as so: nmap -p 5500 192.168.1.42

Email Creation

ehlo mydomain.com
mail from: oracle@MyHostName
rcpt to: michaele@mydomain.com
data

Subject: Test

Hello, this is a test.
<CRLF>
.
<CRLF>

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

Permanently

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

Display Current Value

 df -h

7.x Bug Workaround (per Doc ID 2065603.1)
Upon a fresh install of OL7, the /dev/shm is not mounted in /etc/fstab. It is done in: /usr/lib/dracut/modules.d/99base/init.sh

 # ll /usr/lib/dracut/modules.d/99base/init.sh
 -rwxr-xr-x. 1 root root 11379 Mar 26 10:14

 vi /usr/lib/dracut/modules.d/99base/init.sh and comment the below lines

 if ! ismounted /dev/shm; then
 mkdir -m 0755 /dev/shm
 mount -t tmpfs -o mode=1777,nosuid,nodev,strictatime tmpfs /dev/shm >/dev/null
 fi

Alternatively you can still re-add it to the /etc/fstab

 tmpfs  /dev/shm  tmpfs   defaults,size=2g  0 0

Terminal

Set Color

 setterm -term linux -back <background_colour> -fore <text_color> -clear
 Color options: black|blue|green|cyan|red|magenta|yellow|white|default
 setterm -term linux -back blue -fore white -clear 

 .bashrc
 # Set Term 
 sFrom=$(echo $SSH_CLIENT | awk '{ print $1}')
 if [[ "$sFrom" == "MyIpHere" ]]; then
    setterm -term linux -back magenta -fore white -clear
 fi

See setterm /?

top

 z = color mode (Z = custom color mode: Z H4 S4 T4 M1)
 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 (.toprc).
 Y = Inspect PID

Add Field and Sort by It (SWAP example)

  1. Use the f key to see the fields
  2. Use the arrow keys to go to SWAP.
  3. Press d to display field. It will now be highlighted.  
  4. Press s to set the sort.
  5. Press <Esc>

Update Packages

Linux 8 and later uses dnf for all updates even when using yum.

dnf

Status

 dnf repolist
 repo id                          repo name
 appstream                        AlmaLinux 8 - AppStream
 baseos                           AlmaLinux 8 - BaseOS
 extras                           AlmaLinux 8 - Extras
 plus                             AlmaLinux 8 - Plus

 dnf check-update
 Last metadata expiration check: 0:13:07 ago on Mon 07 Aug 2023 12:36:18 PM EDT.

Update OS Patches and Packages

 dnf clean all
 dnf check-update
 dnf update -y
 cat /etc/redhat-release

Update Issue Edit any that get stuck at 99% as shown below.

 1. cd /etc/yum.repos.d
 2. vi /etc/yum.repos.d/almalinux.repo
    For any enabled repo (enabled=1)
    a. Comment out mirrorlist=
    b. Enable baseurl=

As needed (sub repos still stuck at 99%):

 mv <file>.repo <file>.repo.bak
 mv almalinux-ha.repo almalinux-ha.repo.bak  

Improving Update Performance
vi /etc/dnf/dnf.conf

 max_parallel_downloads=10
 fastestmirror=1

yum

Check repos

 yum repolist
 yum search release-el8 (or yum search release-el7)

Update All Packages

 -- Ensure system can adequately connect to repo and mirrors.
 root> yum repolist
 root> yum search release-el8 

 -- If Above OK, then Update
 root> yum update -y

PackageKit Messages If you get Another app is currently holding the yum lock... or PackageKit messages stop the packagekit:

 systemctl stop packagekit
 systemctl disable packagekit
 systemctl status packagekit
 yum update -y

Rollback

 1. Run "yum history list" 
 2. Followed by "yum history rollback <TID>" 
    Where <TID> is the transaction ID from the first command. 

Improving Update Performance (Linux 8)

vi /etc/dnf/dnf.conf

 max_parallel_downloads=10
 fastestmirror=1

Update Repos (OL7)

 cd /etc/yum.repos.d
 yum list *release-el7*
 TBD: yum list *release-el8*

 wget http://yum.oracle.com/public-yum-ol7.repo
 yum list *release-el7*

Run this if your yum update has issues finding mirrors etc..

Versionlock a Package

 -- List Oracle Packages
 yum list installed | grep oracle
 oracle-database-server-12cR2-preinstall.x86_64
 oracle-rdbms-server-12cR1-preinstall.x86_64

 -- Lock Oracle Client Packages
 yum install yum-plugin-versionlock

 yum versionlock oracle-database-server-12cR2-preinstall.x86_64
 yum versionlock oracle-rdbms-server-12cR1-preinstall.x86_64 
 yum versionlock list

 -- Clear Entire List
 yum versionlock clear

 -- Delete Lock on a Specific Package
 yum versionlock delete <package_name>

CentOS

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].

Rebuild repo Engine

Purge yum

 cd /etc/yum.repos.d
 yum clean all
 rm -rf /var/cache/yum
 gzip *

vi /etc/yum.repos.d/ol7-temp.repo

[ol7_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL7/latest/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

Get RPM-GPG-KEY-oracle-ol7

 wget https://yum.oracle.com/RPM-GPG-KEY-oracle-ol7 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle

 gpg --quiet --with-fingerprint /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle

Install

 yum install oraclelinux-release-el7 -y
 yum install oracle-epel-release-el7 -y

You can now cleanly perform: yum update -y

User Accounts

Create

 -- Example 1
 useradd lnxuser
 passwd lnxuser

 -- Example 2
 useradd --uid [FreeUserID] --gid [PrimaryGroupID] [username]
 useradd --uid 54330 --gid 54323 automictest
 passwd automictest

 -- Example 3
 useradd --uid 54321 --gid oinstall --groups dba,oper,asmdba,asmoper,backupdba,dgdba,kmdba oracle
 passwd 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

Manually

The username test is used in following examples:

  1. Identify the next available UID via the /etc/passwd file (1001).
  2. Create entry in the /etc/passwd file.
    test:x:1001:1001:test:/home/test:/bin/bash
  3. Create entry in the /etc/group file.
    test:x:1001:
  4. Create /home directory.
    mkdir /home/test
  5. Create a minimal shell file (see below).
    vi /home/test/.bashrc
  6. Assign privs.
    chown -R test:test /home/test
    chmod -R 744 /home/test
  7. Set initial password.
    passwd test

If passwd does not work edit the /etc/shadow file duplicating an entry for the new user.

Minimal .bashrc

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
   . /etc/bashrc
fi

Delete

 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.

Auto-Login

  1. Login as root.
  2. Applications Menu -> System Tools -> Settings
  3. Users
  4. Select user, then set Automatic Login to ON.

From this point on when system starts the selected user will automatically login.

Version and Relase Info

  • Kernel version: uname -r
    Example: 4.14.35-2047.510.4.1.el7uek.x86_64
  • Release: cat /etc/redhat-release
    Example: Red Hat Enterprise Linux Server release 7.9 (Maipo)
  • OEL Relase Info: cat /etc/system-release
    Example: Oracle Linux Server release 7.9

Essential Info

uname -r returns the current kernel version that is running. It also includes the OS release that it was created for, such as ".fc29, and the architecture, such as ".x86_64". It is kernel specific, and is not really a positive indicator of which OS release you are running. You could be running Fedora 30 OS release but booted into a leftover Fefora 29 kernel from when you were running Fedora 29 if you did a "dnf system-upgrade" and the output of "uname -r" would still show the ".fc29" part.

The redhat-release file shows you which OS release you are running, regardless of which kernel you are booted into. There are other "release" files in /etc/ that will also give you the current OS release. cat /etc/*release*

The command rpm -E %{fedora} will also return the OS release.

vi

Make Colors Readable From Putty

 vi ~/.vimrc
 :color koehler
  • Good putty color schemes: desert elflord koehler slate
  • Show avaiable schemes: :colorscheme [space] [press 'Ctrl + d']

Essential Commands

  • 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
  • Quit
    • Save\write changes and quit: <Esc> :wq
    • Just quit: <Esc> :q (gives warning if file changed)
    • Quit and don't save (use BANG!): <Esc> :q!

vi cheat sheet here.

watch

Displays any command by refreshing console screen and keeping position of all characters (similar to how top displays).

watch -d free -m
watch mpsat
watch -n15 df -h
watch -n60 ls -l /u03/trace|wc -l
  -d Difference             
-n Interval (in seconds) [default=2]

Show Cumulative Differences

 watch -d=cumulative df -h

Webmin

Webmin is a web-based interface for system administration for Unix\Linux.

Installation

  1. wget http://prdownloads.sourceforge.net/webadmin/webmin-1.900-1.noarch.rpm
  2. yum -y install perl perl-Net-SSLeay openssl perl-IO-Tty perl-Encode-Detect
  3. rpm -U webmin-1.900-1.noarch.rpm
  • The rest of the install will be done automatically to the directory /usr/libexec/webmin.
  • The admin username is set to root and the password to your current root password.

Usage

xrdp

xrdp can allow you to use Microsoft's Remote Desktop Connection (rdp) app to connect to a Linux system from a Windows PC. Reference

Enable EPEL Repository

 wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
 rpm -ivh epel-release-latest-7.noarch.rpm
 clear;yum repolist|grep epel

Install

 yum install xrdp -y
 systemctl enable xrdp.service
 systemctl start xrdp.service
 systemctl enable xrdp-sesman.service
 systemctl start xrdp-sesman.service

Edit xrdp.ini

 vi /etc/xrdp/xrdp.ini

Common Changes to xrdp.ini

 [Xvnc]
 name=lnxuser
 lib=libvnc.so
 username=ask
 password=ask
 ip=127.0.0.1
 port=-1
 #xserverbpp=24
 #delay_ms=2000

lnxuser is a local Linux user on the system you are connecting to.

Init Firewall (if used)

 firewall-cmd --permanent --add-port=3389/tcp
 firewall-cmd --reload

 netstat -antup | grep xrdp
 tcp  0  0 127.0.0.1:3350  0.0.0.0:*  LISTEN  3784/xrdp-sesman
 tcp  0  0 0.0.0.0:3389    0.0.0.0:*  LISTEN  3787/xrdp

Test From Windows RDP

Xming

With Xming you can launch GUI Linux applications from a putty session.

Xming Initial Client Cfg

  • Run: Xming XLaunch
  • Select display settings: (x) Multiple windows
  • Select how to start Xming: (x) Start a program
  • Enter or choose one X client to Run Local or Run Remote:
    • Start program: xterm default
    • (x) Run Local default
    • Specify parameter settings: [x] Clipboard default

Putty Settings

Set the following putty values 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

 Linux
 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

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

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

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

APPENDIX

Example Patch Prep Output

yum repolist

Loaded plugins: langpacks, ulninfo
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
repo id                   repo name                                                                               status
!ol7_UEKR5/x86_64         Latest Unbreakable Enterprise Kernel Release 5 for Oracle Linux 7Server (x86_64)           210
!ol7_latest/x86_64        Oracle Linux 7Server Latest (x86_64)                                                    18,974
repolist: 19,184

yum search release-el7

Loaded plugins: langpacks, ulninfo
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
=============================================== N/S matched: release-el7 ================================================
mysql-release-el7.x86_64 : MySQL yum repository configuration
oracle-ceph-release-el7.x86_64 : Ceph Storage yum repository configuration
oracle-epel-release-el7.x86_64 : Extra Packages for Enterprise Linux (EPEL) yum repository configuration
oracle-gluster-release-el7.x86_64 : Gluster yum repository configuration
oracle-golang-release-el7.x86_64 : Go Language  yum repository configuration
oracle-nodejs-release-el7.x86_64 : Node.js yum repository configuration
oracle-olcne-release-el7.x86_64 : Oracle Linux Cloud Native Environment yum repository configuration
oracle-openstack-release-el7.x86_64 : Oracle OpenStack for Oracle Linux yum repository configuration
oracle-php-release-el7.x86_64 : PHP yum repository configuration
oracle-release-el7.x86_64 : Oracle Software yum repository configuration
oracle-softwarecollection-release-el7.x86_64 : Software Collection Library yum repository configuration
oracle-spacewalk-client-release-el7.x86_64 : Spacewalk Client yum repository configuration
oracle-spacewalk-server-release-el7.x86_64 : Spacewalk Server yum repository configuration
oraclelinux-developer-release-el7.x86_64 : Oracle Linux Developer yum repository configuration
oraclelinux-release-el7.x86_64 : Oracle Linux yum repository configuration

  Name and summary matches only, use "search all" for everything.