Monday, April 9, 2018

Linux Basics Commands




================================================================================================================
Oracle Home Location on Windows Registry:

-->Registry-->HKEY_LOCAL_MACHINE-->SOFTWARE-->WOW6432Node-->Oracle-->KEY_DevSuiteHome1

================================================================================================================
List of Background process used by Database-DELL:
[oracle@rac1 ~]$ ps -ef | grep -i DELL|wc -l
36
[oracle@rac1 ~]$ ps -ef | grep -i DELL
[oracle@rac1 ~]$

[oracle@rac1 ~]$ env | grep ORA
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/12.0.0.0/oracle
ORACLE_SID=DELL
[oracle@rac1 ~]$

Pkill all background process of OS User:
[root@rac1 ~]# ps -fux ß to list all running backgroud process of logged user(root)
[root@rac1 ~]# pkill -9 FNDLIBR ß to kill all multiple users Concurrent running on Server
[root@rac1 ~]# pkill -9 FND ß to kill Weblogic and Java Connections
[root@rac1 ~]# pkill -u applahc ß to kill All BP’s running with user
[oracle@testdb01 ~]# ps -ef | grep LOCAL=NO |wc -l ß to veify all connections to DB
[oracle@testdb01 ~]# ps -ef | grep LOCAL=NO | awk '{print $2}' | xargs kill -9  ß to kill All Locall connections of executing user

kill all zombie process in Linux 6.10:
[root@rac1 ~]# ps aux | grep -w Z ß to list all zombie process
[root@rac1 ~]# kill -9 $(ps -A -ostat,ppid |grep -e '[zZ]'|awk '{print $2}') ß to kill all zombie process


================================================================================================================
Watch Command for FND Process
[oratest@RUH-ERPAT01 ~]$

[oratest@RUH-ERPAT01 ~]$ watch -n 1 'ps -fu oratest|grep -i fnd|wc -l'
================================================================================================================
Split Big file to small multiple files ex:FNDCPGSC WFM log
[oratest@RUH-ERPAT01 ~]$
[oratest@RUH-ERPAT01 ~]$ split --verbose -b600M FNDCPGSC2041260.txt_splt
[oratest@RUH-ERPAT01 ~]$ split -b600M FNDCPGSC2041260.txt_splt
[oratest@RUH-ERPAT01 ~]$ ls -ltrh
-rw-r--r--. 1 root    root     3.5G Mar  7 18:49 FNDCPGSC2041260.txt_splt
-rw-r--r--. 1 root    root     600M Mar  7 18:52 xaa
-rw-r--r--. 1 root    root     600M Mar  7 18:52 xab
-rw-r--r--. 1 root    root     600M Mar  7 18:52 xac
-rw-r--r--. 1 root    root     600M Mar  7 18:52 xad
-rw-r--r--. 1 root    root     600M Mar  7 18:52 xae
-rw-r--r--. 1 root    root     554M Mar  7 18:52 xaf
[oratest@RUH-ERPAT01 ~]$
Now Zip the split file to reduce size form 600MB to 60MB or less
zip xaa.zip xaa
zip xab.zip xab
zip xac.zip xac
zip xad.zip xad
zip xae.zip xae
to zip a folder in Linux (zip -r /u02/ftp/folder.zip folder_name)

If you want your file to be split based on the number of lines in each chunk rather than the number of bytes, you can use the -l (lines) option. In this example, each file will have 1,000 lines except, of course, for the last one which may have fewer lines.
[oratest@RUH-ERPAT01 ~]$ split --verbose -l1000 logfile log.

================================================================================================================
Unzip multiple file with single command:

[root@rac2 ~]# ls -ltr 
-rw-r--r--   1 root     root       23916 Oct  4 14:47 p30535550_R12.ATG_PF.C_R12_ar.zip
-rw-r--r--   1 root     root     5495314 Oct  4 14:48 p30535550_R12.ATG_PF.C_R12_GENERIC.zip
[root@rac2 ~]# unzip '*.zip'
2 archives were successfully processed.
[root@rac2 ~]# 
[root@rac2 ~]# ls -ltr
-rw-r--r--   1 root     root       23916 Oct  4 14:47 p30535550_R12.ATG_PF.C_R12_ar.zip
-rw-r--r--   1 root     root     5495314 Oct  4 14:48 p30535550_R12.ATG_PF.C_R12_GENERIC.zip
drwxr-xr-x   3 root     root           7 Nov 17 13:25 30535550_AR
drwxr-xr-x   4 root     root          13 Nov 17 13:25 30535550
[root@rac2 ~]# 
[root@rac2 ~]# unzip abc.zip -d /u02

[root@rac2 ~]# unzip -l abc.zip      (list all contents in zip file)
================================================================================================================

================================================================================================================
================================================================================================================
VI Editor Command useful:
-------------------------
###--- i insert text, before the cursor position
###--- a append text, after the cursor position
###--- o open new line below cursor, enter insert mode
###--- s enter insert mode to substitute text for the character on which the cursor rests 10s substitute 10 character and enter insert mode

###--- r replace character on which the cursor rests
###--- R enter overstrike mode, press the ESCAPE key to exit

###--- G go to the last line of the file 10G to go to the 10 line below from cursor
###--- gg  go to the first line of the file 10gg go to 10th line from top
###--- j  g and k move down and up one line, so 10j and 10k move down and up ten lines. You can repeat any motion by putting a number before it.
###--- $ move to the end of the line
###--- ^ move to the start of the line
###--- ?search_word go to bottom(G) search from bottom of the file backward direction 
###--- /search_word search in forward direction 


###--- u undo the last change and subsequently goes on to undo by hitting u
###--- x delete one character  10x to delete 10 character
###--- dd is to delete one line, so 10dd deletes up to 10 line below from cursor

###--- yyp is to copy current line and paste just after
###--- yy yank (copy) line into the general buffer 10yy copy below 10 lines into the general buffer
###--- p put contents of general buffer after current line

###--- :se nu to set line number in vi editor
###--- :se nonu to unset line number in vi editor

###--- :%s/DELL/CLONE/g substitute every occurrence of pattern with text

grep command to search a error word from same file name from multiple folders
[oracle@rac1 ~]$ ls -ltrh $INST_TOP/admin/log/*/adconfig.log
[oracle@rac1 ~]$ grep -ir Interrupted $INST_TOP/admin/log/*/adconfig.log
[oracle@rac1 ~]$ grep -in 'error\|ORA-\|RMAN-' /ext-backup/Daily_RMAN/*/`date +%y-%m-%d`/LogRMAN.log  <- to check multiple words/strings from multiple files

[oracle@rac1 ~]$ grep -A 6 MISSING_TRANSLATED_VERSION  $APPL_TOP/admin/${TWO_TASK}/adalldefaults.txt  <- to check 5 lines below grep word used for adop
[oracle@rac1 ~]$ grep OAF -B 52 $FND_TOP/admin/template/custom/oacore_web_xml_FMW.tmp  <- to check 52 lines above grep word used when auto config failed on apps tier with version bcoz of missing applaud parameters
AutoConfig failed with Version Conflicts after patch (Doc ID 2639310.1)

to check how many time database restarted
[oracle@rac1 ~]$ grep -A 1 'Starting ORACLE instance' alert_TEST.log 
[oracle@rac1 ~]$ grep -B 1 'Instance shutdown complete' alert_TEST.log  

[oracle@rac1 ~]$ grep -rni HXTUSTIM.fmx * <- to check grep word in all files of current folder
[oracle@rac1 ~]$ grep -rni MDSYS.HXTUSTIM *
r = recursive i.e, search subdirectories within the current directory
n = to print the line numbers to stdout
i = case insensitive search

Tail Command Tips:
This command takes into account the number of lines above also
Display Tailf of current file along with line numbers from beggning of file
[oracle@rac1 ~]$ tail -f -n +1 expdpapps.log | nl

================================================================================================================ 
Run level:
[root@rac1 ~]# who -r
         run-level 5  2020-12-02 17:02


================================================================================================================
ORACLE Packages Installation using Yum:

Oracle E-Business Suite Installation and Upgrade Notes Release 12 (12.2) for Linux x86-64 (My Oracle Support Knowledge Document 1330701.1)
[root@rac1 ~]#
[root@rac1 ~]# cd /etc/yum.repos.d
[root@rac1 yum.repos.d]# ls
public-yum-ol7.repo
[root@rac1 yum.repos.d]# mv public-yum-ol7.repo bkp_public-yum-ol7.repo
[root@rac1 yum.repos.d]#
[root@rac1 yum.repos.d]# ls
bkp_public-yum-ol7.repo  public-yum-ol7.repo

[root@rac1 yum.repos.d]# wget http://public-yum.oracle.com/public-yum-ol7.repo
[root@rac1 yum.repos.d]#

Using a text editor, modify the file, changing the field enabled=0 to enabled=1 to reflect repositories that correspond to the machine's operating system release.
[root@rac1 yum.repos.d]#
[root@rac1 yum.repos.d]# vi public-yum-ol7.repo
[ol6_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/latest/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7
gpgcheck=1
enabled=1


[ol6_addons]
name=Oracle Linux $releasever Add ons ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7
gpgcheck=1
enabled=1



[ol6_UEK_latest]
name=Latest Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/UEK/latest/$basearch/
gpgkey=http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7
gpgcheck=1
enabled=1

[root@rac1 yum.repos.d]#

For Oracle Database 18C issue the following command for Oracle Linux
[root@rac1 yum.repos.d]#
[root@rac1 yum.repos.d]# yum -y install oracle-database-preinstall-18c
[root@rac1 yum.repos.d]#

For Oracle Database 12CR1 issue the following command for Oracle Linux 6 & 7
[root@rac1 yum.repos.d
[root@rac1 yum.repos.d]# yum install oracle-rdbms-server-12cR1-preinstall
[root@rac1 yum.repos.d]#

For Oracle Database 11gR2 issue the following command for Oracle Linux 6 & 7
[root@rac1 yum.repos.d
[root@rac1 yum.repos.d]# yum install oracle-rdbms-server-11gR2-preinstall
[root@rac1 yum.repos.d]#



For Oracle Database 11gR2 issue the following command for Oracle Linux 5
[root@rac1 yum.repos.d]#
[root@rac1 yum.repos.d]# yum install oracle-validated
[root@rac1 yum.repos.d]#

For EBS R12 issue the following command
Update all packages and then install the pre-install rpm by running the following yum commands:
[root@rac1 yum.repos.d]#
[root@rac1 yum.repos.d]# yum update
. . . . .
. . . . .
. . . . .
. . . . .
Transaction Summary
================================================================================
Install    33 Packages (+182 Dependent packages)
Upgrade  1218 Packages

Total download size: 1.3 G
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for ol7_UEKR3
No Presto metadata available for ol7_UEKR5
No Presto metadata available for ol7_latest
warning: /var/cache/yum/x86_64/7Server/ol7_latest/packages/389-ds-base-libs-1.3.8.4-18.el7_6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Public key for 389-ds-base-libs-1.3.8.4-18.el7_6.x86_64.rpm is not installed
(1/1433): 389-ds-base-libs-1.3.8.4-18.el7_6.x86_64.rpm     | 698 kB   00:01    
(2/1433): 389-ds-base-1.3.8.4-18.el7_6.x86_64.rpm          | 1.7 MB   00:02    
(3/1433): LibRaw-0.14.8-5.el7.20120830git98d925.x86_64.rpm | 249 kB   00:00    
(4/1433): GeoIP-1.5.0-13.el7.x86_64.rpm                    | 1.5 MB   00:01    
(5/1433): ModemManager-glib-1.6.10-1.el7.x86_64.rpm        | 231 kB   00:00    
. . . . .
. . . . .
. . . . .
. . . . .
(1430/1433): zip-3.0-11.el7.x86_64.rpm                     | 259 kB   00:00    
(1431/1433): zlib-1.2.7-18.el7.i686.rpm                    |  90 kB   00:00    
(1432/1433): zlib-1.2.7-18.el7.x86_64.rpm                  |  89 kB   00:00    
(1433/1433): zenity-3.28.1-1.el7.x86_64.rpm                | 4.0 MB   00:03    
--------------------------------------------------------------------------------
Total                                              1.4 MB/s | 1.3 GB  14:57    
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Importing GPG key 0xEC551F03:
 Userid     : "Oracle OSS group (Open Source Software group) <build@oss.oracle.com>"
 Fingerprint: 4214 4123 fecf c55b 9086 313d 72f9 7b74 ec55 1f03
 Package    : 7:oraclelinux-release-7.2-1.0.5.el7.x86_64 (@anaconda/7.2)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libgcc-4.8.5-36.0.1.el7.x86_64                            1/2688
  Updating   : 1:redhat-release-server-7.6-4.0.1.el7.x86_64              2/2688
  Installing : ipa-common-4.6.4-10.0.1.el7.noarch                        3/2688
  Installing : 1:grub2-common-2.02-0.76.0.3.el7.noarch                   4/2688
  Updating   : xkeyboard-config-2.24-1.el7.noarch                        5/2688
. . . . .
. . . . .
. . . . .
. . . . .
  pygobject3.x86_64 0:3.14.0-3.el7
  pygobject3-base.x86_64 0:3.14.0-3.el7
  python-caribou.noarch 0:0.4.16-1.el7
  python-cryptography.x86_64 0:0.8.2-1.el7
  python-pyasn1.noarch 0:0.1.6-2.el7
  rdma.noarch 0:7.2_4.1_rc6-1.el7
  usbmuxd.x86_64 0:1.0.8-11.el7

Complete!

[root@rac1 yum.repos.d]#
[root@rac1 yum.repos.d]# yum install oracle-ebs-server-R12-preinstall

[root@rac1 yum.repos.d]#

================================================================================================================
Linux Packages Installation without dependencies:
[root@rac1 R122rpms]#
[root@rac1 R122rpms]# rpm -ivh openmotif21-2.1.30-11.EL5.i386.rpm --nodeps --force
Preparing...                ########################################### [100%]
   1:openmotif21            ########################################### [100%]
[root@rac1 R122rpms]#


================================================================================================================
================================================================================================================
How to resolve Backspace key issue in sqlplus.:
[root@rac1 R122rpms]#
[oracle@ahcoel ~]$ hostnamectl
   Static hostname: ahcoel.areefdba.com.sa
         Icon name: computer-server
           Chassis: server
        Machine ID: 748dd3dd58e44d419ee315814f52781c
           Boot ID: da1f1ccf1fa449bc89af278166bf4244
  Operating System: Oracle Linux Server 7.2
       CPE OS Name: cpe:/o:oracle:linux:7:2:server
            Kernel: Linux 3.8.13-98.7.1.el7uek.x86_64
      Architecture: x86-64
[oracle@ahcoel ~]$

SQL> s^H^H^H^H^H^H^H^H^H
SQL> dfasdfo^H^H^H^?^?^?^?^?^?^?^?^?^?^?^?^?^?^?^C^H^H^C

[oracle@ahcoel ~]$ stty -a
speed 38400 baud; rows 58; columns 208; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
[oracle@ahcoel ~]$ stty erase ^H
[oracle@ahcoel ~]$


================================================================================================================
Enable Screen/TMUX/VNC in Linux :

Enable Screen
[root@rac1 ~]#
[root@rac1 ~]# screen
-bash: /usr/bin/screen: No such file or directory
[root@rac1 ~]#
[root@rac1 ~]# rpm -qa screen
[root@rac1 ~]#
[root@rac1 ~]# yum -y install screen
Loaded plugins: langpacks, ulninfo
Repository ol7_latest is listed more than once in the configuration
Repository ol7_u0_base is listed more than once in the configuration
Repository ol7_u1_base is listed more than once in the configuration
Repository ol7_u2_base is listed more than once in the configuration
Repository ol7_UEKR3 is listed more than once in the configuration
Repository ol7_optional_latest is listed more than once in the configuration
Repository ol7_addons is listed more than once in the configuration
Repository ol7_UEKR3_OFED20 is listed more than once in the configuration
Repository ol7_MySQL56 is listed more than once in the configuration
Repository ol7_MySQL55 is listed more than once in the configuration
Resolving Dependencies
--> Running transaction check
---> Package screen.x86_64 0:4.1.0-0.25.20120314git3c2946.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package   Arch      Version                                Repository     Size
================================================================================
Installing:
 screen    x86_64    4.1.0-0.25.20120314git3c2946.el7       ol7_latest    552 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 552 k
Installed size: 914 k
Is this ok [y/d/N]: y
Downloading packages:
screen-4.1.0-0.25.20120314git3c2946.el7.x86_64.rpm         | 552 kB   00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : screen-4.1.0-0.25.20120314git3c2946.el7.x86_64               1/1
  Verifying  : screen-4.1.0-0.25.20120314git3c2946.el7.x86_64               1/1

Installed:
  screen.x86_64 0:4.1.0-0.25.20120314git3c2946.el7

Complete!
[root@rac1 ~]#
[root@rac1 ~]# rpm -qa screen
screen-4.1.0-0.25.20120314git3c2946.el7.x86_64
[root@rac1 ~]#
[root@rac1 ~]# screen -ls
No Sockets found in /var/run/screen/S-root.

[root@rac1 ~]#
[root@rac1 ~]# screen -S session_name
[root@rac1 ~]#
[root@rac1 ~]# screen -ls
There is a screen on:
        29495.session_name        (Attached)
1 Socket in /var/run/screen/S-root.

[root@rac1 ~]# 

Close the Window Directly
[root@rac1 ~]#
[root@rac1 ~]# screen -ls
There is a screen on:
        22409.pts-1.rac1        (Detached)
1 Socket in /var/run/screen/S-root.

[root@rac1 ~]#
[root@rac1 ~]# screen -r 22409
[root@rac1 ~]# screen -d -r 22409
[root@rac1 u01]#
[root@rac1 u01]# screen -ls
There is a screen on:
        22409.pts-1.rac1        (Attached)
1 Socket in /var/run/screen/S-root.

[root@rac1 u01]# exit
[screen is terminating]
[root@rac1 ~]#
screen cheat sheet for mouse scrolling:
[root@rac1 ~]# cat ~/.screenrc
# Enable scrolling
termcapinfo xterm* ti@:te@

---------------------------------------
Enable tmux
[root@rac1 ~]# yum -y install tmux
[root@rac1 ~]# rpm -qa tmux
tmux-1.8-4.el7.x86_64
[root@rac1 ~]# 

Tmux default installation and cheat Sheet: 

OS Level:
ps -ef | grep tmux  --> List all session of all users at OS level
pkill -f tmux  --> kill all sessions of current/root(all) OS user

Session:
tmux -V --> version check
tmux ls --> List all sessions of current OS user
tmux   --> create a new session 
tmux new -s sessionname  --> Create new session with session name
tmux rename-session -t 0 rac1  -->rename from 0 to rac1
tmux attach -t 0  --> attach recent session from tmux ls
tmux at -t 0  --> shortcut to attach (instead of "at" can also use "a")
tmux kill-session -t 0 --> kill background process running with 0 session

Window:
(ctrl + b)       --> default prefix key
(ctrl + b) + c   --> Create new Window
(ctrl + b) + p/n --> p(Switch previous/next Windows)
(ctrl + b) + w   --> to list all windows
(ctrl + b) + d   --> detach from tmux session
(ctrl + b) + &   --> Delete current window
(ctrl + b) + ,   --> Rename Window

Pane:
(ctrl + b) + %   --> Split vertically
(ctrl + b) + “   --> Split horizontally
(ctrl + b) + o   --> Switch panes (arrow mark also works )


1 - remap prefix
2 - Spliting Panes
3 - switch panes
4 - enable mouse mode
5 - copy/paste in panes (Shift + selection)/( Shift + right click paste)
6 - Pane scrolling to check history
7 - turnoff windows autorename
8 - Copy with mouse selection and paste with Mouse Middle Click

[root@rac1 ~]# tmux -f ~/.tmux.conf (force load all customizing in tmux session)
[root@rac1 ~]# vi ~/.tmux.conf
# remap prefix(leader Key) from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# reload source file
unbind r
bind r source-file ~/.tmux.conf
# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
# switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Enable mouse control (clickable windows & panes, resizable panes)
# (shift + TEXT)to copy from tmux to windows
set -g mouse-select-window on
set -g mouse-select-pane on
set -g mouse-resize-pane on
# Pane scrolling
set -g mode-mouse on
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# don't rename windows automatically
set-option -g allow-rename off
# Selection with mouse should copy to clipboard right away, in addition to the default action (Without Shift Key, within tmux buffer only).
unbind -n -Tcopy-mode-vi MouseDragEnd1Pane
bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel\; run "tmux save-buffer - | xclip -i -sel clipboard > /dev/null"
# Middle click to paste from tmux buffer only but not clipboard (shift + paste has something else)
unbind-key MouseDown2Pane
bind-key -n MouseDown2Pane run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"
# paste from right click with tmux version >2.1
unbind-key MouseDown3Pane
bind-key -n MouseDown3Pane run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"

Enable all above customization after updating tmux.conf
[root@rac1 ~]# bind r source-file ~/.tmux.conf


Now kill all session and create anew session and changes of prefix/pane(split&change)/mouse/scroll/ etc. will take effect: 

for copy/paste in panes use (shift + text selection)/(shift + right click paste) in pane
-some times Keys "FIR" found disable while running sessions. Close putty and reopen

---------------------------------------
Enable VNC
[root@rac1 ~]# rpm -qa *vnc* tigervnc-server
[root@rac1 ~]# yum -y install tigervnc
[root@rac1 ~]# yum -y install telnet
[root@rac1 ~]# vncserver -list
[root@rac1 ~]# vncserver
[root@rac1 ~]#
[root@rac1 ~]# netstat -tulpn |grep -i vnc
[root@rac1 ~]# ss -tulpn |grep -i vnc
[root@rac1 ~]# telnet rac1 5901
[root@rac1 ~]# vncserver -kill :1



================================================================================================================
SCRIPT:
Script command allows you to record everything you do in your Terminal, and saves the output in a text file. This command comes pre-installed with most Linux, and Unix-like operating systems. In this brief tutorial, let me show you how to use script command to record your Terminal session.
Also, you can give a custom name to the typescript by specifying a file name of your choice as and to update output file instantly script -f my_terminal_session

[root@rac1 u01]#
[root@rac1 u01]# script
Script started, file is typescript
[root@rac1 u01]# ls
apps  db_PROD  oracle  typescript
Now, everything you entered in the Terminal will be saved in a file called typescript.
[root@rac1 u01]#
[root@rac1 u01]# whoami
root
[root@rac1 u01]# uname -a
Linux rac1.dell.com 4.14.35-1844.0.7.el7uek.x86_64 #2 SMP Wed Dec 12 19:48:02 PST 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@rac1 u01]#
[root@rac1 u01]# hostnamectl
   Static hostname: rac1.dell.com
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 11b0755356ba4b99b64a2572c3a6d806
           Boot ID: 33b6391106284c84aa10f5d74901449d
    Virtualization: vmware
  Operating System: Oracle Linux Server 7.6
       CPE OS Name: cpe:/o:oracle:linux:7:6:server
            Kernel: Linux 4.14.35-1844.0.7.el7uek.x86_64
      Architecture: x86-64
[root@rac1 u01]# exit
exit
Script done, file is typescript
[root@rac1 u01]#
That’s enough for now. You can try as many commands as you want to record. Once you are done type ‘exit’ in the Terminal to stop recording.

[root@rac1 u01]#
[root@rac1 u01]# cat typescript
Script started on Wed 26 Dec 2018 05:19:06 PM +03
[root@rac1 u01]# whoami
root
[root@rac1 u01]# uname -a
Linux rac1.dell.com 4.14.35-1844.0.7.el7uek.x86_64 #2 SMP Wed Dec 12 19:48:02 PST 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@rac1 u01]#
[root@rac1 u01]# hostnamectl
   Static hostname: rac1.dell.com
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 11b0755356ba4b99b64a2572c3a6d806
           Boot ID: 33b6391106284c84aa10f5d74901449d
    Virtualization: vmware
  Operating System: Oracle Linux Server 7.6
       CPE OS Name: cpe:/o:oracle:linux:7:6:server
            Kernel: Linux 4.14.35-1844.0.7.el7uek.x86_64
      Architecture: x86-64
[root@rac1 u01]# exit
exit

Script done on Wed 26 Dec 2018 05:21:36 PM +03
[root@rac1 u01]#
[root@rac1 u01]#


For further details, I recommend you to refer the man pages.

[root@rac1 u01]# man script
[root@rac1 u01]# adopmon |& tee output.txt

================================================================================================================
Copy Files in Linux to Destination Folder
You can refer to the current directory with a dot (.)


[root@rac1 u01]#
[root@rac1 u01]# cp /file_path/file_name.txt .


================================================================================================================
Attach new 100 GB Hard disk to Openfiler and configure it in GUI

Format to Logical Disk and provide each logical disk of same, if not it will raise error CRS-4000: Command Replace failed, while performing any activity on such disks or disk groups for example replacing voting disk to such Disks:

fdisk –l
fdisk /dev/sdc


p
n
e
1


p
n
l

+2G
n
l

+2G
n
l

+2G
n
l

+2G
n
l

+2G
n
l

+2G
n
l

+2G
n
l

+2G
n
l

+2G
n
l

+2G
n
l

+2G
p
p
w
pwd

[root@rac1 ~]# partx -a /dev/sdc
[root@rac1 ~]# partx -a /dev/sdc

[root@rac2 ~]# partx -a /dev/sdc
[root@rac2 ~]# partx -a /dev/sdc
[root@rac2 ~]# partprobe  /dev/sdc

Creation of ASM DISKS
oracleasm createdisk FRA_DISK00 /dev/sdc5
oracleasm createdisk FRA_DISK01 /dev/sdc6
oracleasm createdisk FRA_DISK02 /dev/sdc7
oracleasm createdisk CRS_DISK00 /dev/sdc8
oracleasm createdisk CRS_DISK01 /dev/sdc9
oracleasm createdisk CRS_DISK02 /dev/sdc10
oracleasm createdisk ASM_DISK00 /dev/sdc11
oracleasm createdisk ASM_DISK01 /dev/sdc12
oracleasm createdisk ASM_DISK02 /dev/sdc13
oracleasm createdisk ASM_DISK03 /dev/sdc14
oracleasm createdisk ASM_DISK04 /dev/sdc15
pwd
ll /dev/oracleasm/disks
[root@rac1 ~]#
[root@rac1 ~]#


Scan disk on RAC-2:
[root@rac2 ~]# oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
Instantiating disk "FRA_DISK00"
Instantiating disk "FRA_DISK01"
Instantiating disk "FRA_DISK02"
Instantiating disk "CRS_DISK00"
Instantiating disk "CRS_DISK01"
Instantiating disk "CRS_DISK02"
Instantiating disk "ASM_DISK00"
Instantiating disk "ASM_DISK01"
Instantiating disk "ASM_DISK02"
Instantiating disk "ASM_DISK03"
Instantiating disk "ASM_DISK04"
[root@rac2 ~]#


================================================================================================================
Solaris Commands:
How to Verify Which SRU a System Is Running 

[root@rac2 ~]# pkg info entire
             Name: entire
          Summary: entire incorporation including Support Repository Update (Oracle Solaris 11.3.31.6.0).
      Description: This package constrains system package versions to the same
                   build.  WARNING: Proper system update and correct package
                   selection depend on the presence of this incorporation.
                   Removing this package will result in an unsupported system.
                   For more information see:
                   https://support.oracle.com/rs?type=doc&id=2045311.1
         Category: Meta Packages/Incorporations
            State: Installed
        Publisher: solaris
          Version: 0.5.11 (Oracle Solaris 11.3.31.6.0)
    Build Release: 5.11
           Branch: 0.175.3.31.0.6.0
   Packaging Date: April 14, 2018 04:25:28 PM
             Size: 5.46 kB
             FMRI: pkg://solaris/entire@0.5.11,5.11-0.175.3.31.0.6.0:20180414T162528Z
[root@rac2 ~]#
================================================================================================================
Tar backup in Solaris (12.2.9 EBS Application):
[root@rac2 ~]# tar Ecf - /u01/AHC/fs2/EBSapps | gzip -3 - > /u01/BKP/EBSapps.tar.gz

untar folder
[root@rac2 ~]# gunzip EBSapps.tar.gz
[root@rac2 ~]# tar -xvf EBSapps.tar

[root@rac2 ~]# tar -C /home/oracle/expdp/ -cvzf /home/oracle/expdp/AJAR_LIVE_27092021.dmp.tar.gz AJAR_LIVE_27092021.dmp    (to tar in different loc. & Exclude path /home/oracle/expdp while uncompress)

[root@rac2 ~]# tar -cvzf /root/dcs_`hostname`.tar.zip /opt/oracle/dcs/log
================================================================================================================
Find previous Command form History:
[root@rac2 ~]# history | grep key_word_to_find

add date and time setting for history commands:
Setting HISTTIMEFORMAT changes format for future commands, so that timestamp will be saved for them. Timestamps for commands fired before setting HISTTIMEFORMAT were not saved in histfile, so there's no way to show them.
echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile
source ~/.bash_profile

================================================================================================================
Searching File in UNIX Solaris if location of file unknown:
The find command will begin looking in the /dir/to/search/ and proceed to search through all accessible subdirectories. The filename is usually specified by the -name
Syntax: find /Directory_PATH/ -name *.mp4 -print
 
[root@rac2 ~]# find /u01/SC/fs2/ -name BankAccountEOImpl.class -print
/u01/SC/fs2/EBSapps/comn/java/classes/oracle/apps/ce/ispeed/bankaccount/server/BankAccountEOImpl.class
/u01/SC/fs2/EBSapps/comn/java/classes/oracle/apps/ce/bankaccount/server/BankAccountEOImpl.class

Find all the files whose name is EmpBankAccount.txt and contains both capital and small letters
Syntax: find /Directory_PATH/ -iname *bank*.txt 

To find all the files whic got created new in folders as of todays days format  (useful to find bkp)
Syntax: find /home/bkagent/db_backup_files/* -type f -newermt $(date +"%Y-%m-%d")

To find all Multi format files .req and .mgr Count total for EBS Application
cat $APPLCSF/log/find1rm.sh 
Syntax-1: Basic 
ls $APPLCSF/log |wc -l
ls $APPLCSF/log/*.req |wc -l         #--- (Count of all Req. logs)
ls -ltrh $APPLCSF/log/FND*           #--- (List of all FND logs)
ls -ltrh $APPLCSF/log/$TWO_TASK*     #--- (List of Internal manager logs for Non RAC)
ls: cannot access /oracle/PROD/apps/fs_ne/inst/PROD_prodapp01/logs/appl/conc/log/PROD_BALANCE*: No such file or directory
grep -i 's_dbSid\|s_systemname\|s_dbGlnam\|s_db_serv_sid\|twotask' $CONTEXT_FILE
ls -ltrh $APPLCSF/log/PROD_*.mgr     #--- (List of Internal manager logs for RAC)
ls -ltrh $APPLCSF/log/t*.mgr
ls -ltrh $APPLCSF/log/w*.mgr         #--- (List of all Standard Manager logs)
ls -ltrh $APPLCSF/log/c*.mgr         #--- (List of all Conflict Resolution Manager logs)
ls -ltrh $APPLCSF/log/FNDSM*.mgr     #--- (List of all Service Manager logs)
ls -ltrh $APPLCSF/log/FNDOPP*.txt    #--- (List of all Output Post Processor's log)
ls -ltrh $APPLCSF/log/FNDCPGSC*.txt  #--- (List of all Workflow Mailer logs)
Syntax-2: find $APPLCSF/log -type f \( -iname \*.log -o -iname \*.mgr \) -mtime +3 |wc -l
Syntax-3: find $APPLCSF/log -type f \( -iname \*.req -o -iname \*.mgr -o -iname \*.log -o -iname \*.txt \) -mtime +400 |wc -l
find $APPLCSF/log -type f \( -iname \*.req -o -iname \*.mgr \) -mtime +3 -exec rm {} \;
Syntax-4: find $INST_TOP/logs/ora/10.1.2/reports/cache/*.xml  -mtime +400 |wc -l


Find and delete all backup directories older than 15 days from backup location
Syntax: find /ext-backup/Daily_RMAN/EBS -type d -mtime +15 -exec rm -r {} +

Find all directories whose name is java in / directory
Syntax: find / -d -iname *zoo*

Other useful find commands:
To find all the files which are modified 50 days back.
Syntax: find / -mtime 50

To find all the files which are accessed 50 days back.
Syntax:  find / -atime 50

To find all the files which are modified more than 50 days back and less than 100 days.
Syntax:  find / -mtime +50 –mtime -100

To find all the files which are changed in the last 1 hour.
Syntax:  find / -cmin -60

To find all the files which are modified in the last 1 hour.
Syntax:  find / -mmin -60

To find all the files which are accessed in the last 1 hour.
Syntax:  find / -amin -60

To find latest 5 files in folder 
find $APPLCSF/log -type f -printf "%t - %p\n" | sort -n | tail -5


================================================================================================================
Counting number of files in Folder:

[root@rac2 ~]# ls -ltr $ORACLE_HOME/rdbms/audit/ | wc -l


Adding Installing Printer lpstat



================================================================================================================

3 comments:

  1. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
    AWS Online Training

    ReplyDelete
  2. Good post and informative. Thank you very much for sharing this good article, it was so good to read and useful to improve my knowledge as updated, keep blogging. Thank you for sharing wonderful information with us to get some idea about that content.
    oracle training in chennai

    oracle training institute in chennai

    oracle training in bangalore

    oracle training in hyderabad

    oracle training

    oracle online training

    hadoop training in chennai

    hadoop training in bangalore

    ReplyDelete