escape sequence play


#!/bin/bash


## color code const
readonly C_GREEN=32;
readonly C_YELLOW=33;
readonly C_BLUE=34;
readonly C_MAGENTA=35;
readonly C_CYAN=36;
readonly C_L_RED=91;
readonly C_L_GREEN=92;
readonly C_L_YELLOW=93;
readonly C_L_BLUE=94;
readonly C_L_MAGENTA=95;
readonly C_L_CYAN=96;

pre_color=$PS1

function f_c()
{
printf "\033[${1}m${2}\033[${1}m\n";
}

echo 'please input'
echo '1:GREEN 2:YELLOW 3:BLUE 4:MAGENTA 5:CYAN 6:L_RED 7:L_GREEN 8:L_YELLOW 9:L_BLUE 10:L_MAGENTA 11:L_CYAN'

read num

case "$num" in
1)
color=${C_GREEN}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
2)
color=${C_YELLOW}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
3)
color=${C_BLUE}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
4)
color=${C_MAGENTA}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
5)
color=${C_CYAN}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
6)
color=${C_L_RED}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
7)
color=${C_L_GREEN}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
8)
color=${C_L_YELLOW}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
9)
color=${C_L_BLUE}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
10)
color=${C_L_MAGENTA}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
11)
color=${C_L_CYAN}
f_c ${color} "#########################"
f_c ${color} "||     hello world!    ||"
f_c ${color} "#########################"
;;
*)
;;
esac

f_c ${pre_color} ""
[oracle@centos7 lesson]$

ssh centos7 enable


[oracle@centos7 ~]$ pwd
/home/oracle
[oracle@centos7 ~]$ ll
合計 4
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Desktop
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Documents
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Downloads
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Music
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Pictures
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Public
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Templates
drwxr-xr-x. 2 oracle docker    6 12月 23 14:59 Videos
drwxr-xr-x. 3 oracle docker   66 12月 23 17:12 docker
drwxrwxrwx. 4 oracle docker   32 12月 23 15:31 doclan
-rwxr-xr-x. 1 oracle docker 1299 12月 23 15:31 mkdir.sh
drwxr-xr-x. 2 oracle docker   24 12月 23 17:12 share
[oracle@centos7 ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_rsa): 
Created directory '/home/oracle/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/oracle/.ssh/id_rsa.
Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:uZjgdcQyJLlUXxdr1Z/bqnLmKQVWDwRF9LclCEUNDKo oracle@centos7
The key's randomart image is:
+---[RSA 2048]----+
|    .oo   =@@+.. |
|    oo o o o+=. .|
|   . .o =  .+oo =|
|    .  = .o.  .++|
|    . E S. .   .o|
|   . o + .  .  ..|
|    . o .  .   . |
|          o o..  |
|           *+.   |
+----[SHA256]-----+
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ ll -a
合計 40
drwx------. 21 oracle docker 4096 12月 27 20:43 .
drwxr-xr-x.  3 root   root     20 12月 23 14:28 ..
-rw-------.  1 oracle docker 1864 12月 23 15:45 .ICEauthority
-rw-------.  1 oracle docker 3392 12月 27 20:39 .bash_history
-rw-r--r--.  1 oracle docker   18  4月 11  2018 .bash_logout
-rw-r--r--.  1 oracle docker  193  4月 11  2018 .bash_profile
-rw-r--r--.  1 oracle docker  231  4月 11  2018 .bashrc
drwx------. 17 oracle docker 4096 12月 23 14:55 .cache
drwxr-xr-x. 19 oracle docker 4096 12月 24 00:02 .config
drwx------.  3 oracle docker   25 12月 23 14:41 .dbus
-rw-------.  1 oracle docker   16 12月 23 14:41 .esd_auth
drwx------.  3 oracle docker   18 12月 23 14:55 .gnome
drwx------.  3 oracle docker   19 12月 23 14:41 .local
drwxr-xr-x.  5 oracle docker   54 12月 23 14:48 .mozilla
drwx------.  3 oracle docker   19 12月 23 14:55 .pki
drwx------.  2 oracle docker   38 12月 27 20:43 .ssh
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Desktop
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Documents
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Downloads
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Music
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Pictures
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Public
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Templates
drwxr-xr-x.  2 oracle docker    6 12月 23 14:59 Videos
drwxr-xr-x.  3 oracle docker   66 12月 23 17:12 docker
drwxrwxrwx.  4 oracle docker   32 12月 23 15:31 doclan
-rwxr-xr-x.  1 oracle docker 1299 12月 23 15:31 mkdir.sh
drwxr-xr-x.  2 oracle docker   24 12月 23 17:12 share
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ cd .ssh
[oracle@centos7 .ssh]$ pwd
/home/oracle/.ssh
[oracle@centos7 .ssh]$ ll
合計 8
-rw-------. 1 oracle docker 1766 12月 27 20:43 id_rsa
-rw-r--r--. 1 oracle docker  396 12月 27 20:43 id_rsa.pub
[oracle@centos7 .ssh]$ 

サーバー側


[oracle@centos7 ~]$ ip route
default via 192.168.100.1 dev wlp7s0 proto static metric 600 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
192.168.100.0/24 dev wlp7s0 proto kernel scope link src 192.168.100.107 metric 600 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 
[oracle@centos7 ~]$ ll
合計 4
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Desktop
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Documents
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Downloads
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Music
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Pictures
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Public
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Templates
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Videos
drwxr-xr-x. 3 oracle docker   66 12月 23 15:21 docker
drwxrwxrwx. 4 oracle docker   32 12月 23 14:47 doclan
-rwxr-xr-x. 1 oracle docker 1302 12月 23 14:46 mkdir.sh
drwxr-xr-x. 2 oracle docker   42 12月 23 16:40 share
[oracle@centos7 ~]$ 

クライアント側


[oracle@centos7 .ssh]$ scp id_rsa.pub oracle@192.168.100.107:~
The authenticity of host '192.168.100.107 (192.168.100.107)' can't be established.
ECDSA key fingerprint is SHA256:lAUjRXceZduuHmiWxudjvCaspDoZb+klg+K1g40p/sI.
ECDSA key fingerprint is MD5:1d:f6:2b:f5:7e:8e:2d:b1:17:1d:b6:1b:b5:5d:c1:5f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.107' (ECDSA) to the list of known hosts.
oracle@192.168.100.107's password: 
id_rsa.pub                                                                                                    100%  396    43.1KB/s   00:00    
[oracle@centos7 .ssh]$ 

サーバー側


[oracle@centos7 ~]$ ll
合計 8
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Desktop
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Documents
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Downloads
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Music
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Pictures
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Public
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Templates
drwxr-xr-x. 2 oracle docker    6 12月 23 10:57 Videos
drwxr-xr-x. 3 oracle docker   66 12月 23 15:21 docker
drwxrwxrwx. 4 oracle docker   32 12月 23 14:47 doclan
-rw-r--r--. 1 oracle docker  396 12月 28 20:07 id_rsa.pub
-rwxr-xr-x. 1 oracle docker 1302 12月 23 14:46 mkdir.sh
drwxr-xr-x. 2 oracle docker   42 12月 23 16:40 share
[oracle@centos7 ~]$ 


[oracle@centos7 .ssh]$ ip route
default via 192.168.100.1 dev wlp2s0 proto static metric 600 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
192.168.100.0/24 dev wlp2s0 proto kernel scope link src 192.168.100.108 metric 600 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 
--ホスト名一緒やとぜんぜんわかね
[oracle@centos7 .ssh]$ ssh oracle@192.168.100.107
oracle@192.168.100.107's password: 
Last login: Fri Dec 28 20:22:43 2018 from 192.168.100.108
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ cd ~ && cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRelZ3eydODQTdFCzCZGd5DlH0SBUkWxkTodK30b1pk37D9WDsxDFF1iOTcFVZFsYlQzMUpn1R1fM2Dhjcu7WrBmwhxsfB09bpl+HK/ZlQNZgfysEnR1mOfilai30LioV84+VFKNdiQUP+4iG6pzXMNJaqyWytLFr9gYqWRgp0znakGB187XdOEhTkNWXcP4gQsHbrB02SSTPTn8Ern+bYAdzHfNEMm8yezJFOycF0vkWQbkYqg+uf5Ry/Cy3GB7Sf6H7q78vVR+6ambU0HDhYPY3dzQ02WQeab5clMy4A5zX8fDVqfV/mncNT1GxG1e8XInl4kHxqjWStm24S8sDr oracle@centos7
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ mkdir ~/.ssh
[oracle@centos7 ~]$ ll -at
合計 48
drwx------. 21 oracle docker 4096 12月 28 20:31 .
drwxr-xr-x.  2 oracle docker    6 12月 28 20:31 .ssh
-rw-------.  1 oracle docker 4925 12月 28 20:23 .bash_history
-rw-r--r--.  1 oracle docker  396 12月 28 20:07 id_rsa.pub
drwxr-xr-x. 19 oracle docker 4096 12月 23 21:56 .config
drwxr-xr-x.  2 oracle docker   42 12月 23 16:40 share
drwxr-xr-x.  3 oracle docker   66 12月 23 15:21 docker
-rw-------.  1 oracle docker 1554 12月 23 15:16 .ICEauthority
drwxrwxrwx.  4 oracle docker   32 12月 23 14:47 doclan
-rwxr-xr-x.  1 oracle docker 1302 12月 23 14:46 mkdir.sh
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Music
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Pictures
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Videos
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Documents
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Public
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Templates
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Desktop
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Downloads
drwx------.  3 oracle docker   18 12月 23 10:53 .gnome
drwx------.  3 oracle docker   19 12月 23 10:53 .pki
drwx------. 17 oracle docker 4096 12月 23 10:53 .cache
drwxr-xr-x.  5 oracle docker   54 12月 23 10:45 .mozilla
-rw-------.  1 oracle docker   16 12月 23 10:44 .esd_auth
drwx------.  3 oracle docker   19 12月 23 10:44 .local
drwx------.  3 oracle docker   25 12月 23 10:44 .dbus
drwxr-xr-x.  3 root   root     20 12月 23 10:39 ..
-rw-r--r--.  1 oracle docker   18  4月 11  2018 .bash_logout
-rw-r--r--.  1 oracle docker  193  4月 11  2018 .bash_profile
-rw-r--r--.  1 oracle docker  231  4月 11  2018 .bashrc
[oracle@centos7 ~]$ chmod 700 .ssh
[oracle@centos7 ~]$ ll -at
合計 48
drwx------. 21 oracle docker 4096 12月 28 20:31 .
drwx------.  2 oracle docker    6 12月 28 20:31 .ssh
-rw-------.  1 oracle docker 4925 12月 28 20:23 .bash_history
-rw-r--r--.  1 oracle docker  396 12月 28 20:07 id_rsa.pub
drwxr-xr-x. 19 oracle docker 4096 12月 23 21:56 .config
drwxr-xr-x.  2 oracle docker   42 12月 23 16:40 share
drwxr-xr-x.  3 oracle docker   66 12月 23 15:21 docker
-rw-------.  1 oracle docker 1554 12月 23 15:16 .ICEauthority
drwxrwxrwx.  4 oracle docker   32 12月 23 14:47 doclan
-rwxr-xr-x.  1 oracle docker 1302 12月 23 14:46 mkdir.sh
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Music
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Pictures
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Videos
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Documents
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Public
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Templates
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Desktop
drwxr-xr-x.  2 oracle docker    6 12月 23 10:57 Downloads
drwx------.  3 oracle docker   18 12月 23 10:53 .gnome
drwx------.  3 oracle docker   19 12月 23 10:53 .pki
drwx------. 17 oracle docker 4096 12月 23 10:53 .cache
drwxr-xr-x.  5 oracle docker   54 12月 23 10:45 .mozilla
-rw-------.  1 oracle docker   16 12月 23 10:44 .esd_auth
drwx------.  3 oracle docker   19 12月 23 10:44 .local
drwx------.  3 oracle docker   25 12月 23 10:44 .dbus
drwxr-xr-x.  3 root   root     20 12月 23 10:39 ..
-rw-r--r--.  1 oracle docker   18  4月 11  2018 .bash_logout
-rw-r--r--.  1 oracle docker  193  4月 11  2018 .bash_profile
-rw-r--r--.  1 oracle docker  231  4月 11  2018 .bashrc
[oracle@centos7 ~]$ 


[oracle@centos7 ~]$ cd .ssh
[oracle@centos7 .ssh]$ ll
合計 0
[oracle@centos7 .ssh]$ touch ~/.ssh/authorized_keys
[oracle@centos7 .ssh]$ ll
合計 0
-rw-r--r--. 1 oracle docker 0 12月 28 20:35 authorized_keys
[oracle@centos7 .ssh]$ chmod 600 ~/.ssh/authorized_keys
[oracle@centos7 .ssh]$ ll
合計 0
-rw-------. 1 oracle docker 0 12月 28 20:35 authorized_keys
[oracle@centos7 .ssh]$ 


[oracle@centos7 .ssh]$ ログアウト
Connection to 192.168.100.107 closed.
[oracle@centos7 .ssh]$ ip route
default via 192.168.100.1 dev wlp2s0 proto static metric 600 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
192.168.100.0/24 dev wlp2s0 proto kernel scope link src 192.168.100.108 metric 600 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 
[oracle@centos7 .ssh]$ 


[oracle@centos7 .ssh]$ ll
合計 12
-rw-------. 1 oracle docker 1766 12月 27 20:43 id_rsa
-rw-r--r--. 1 oracle docker  396 12月 27 20:43 id_rsa.pub
-rw-r--r--. 1 oracle docker  177 12月 28 20:07 known_hosts
[oracle@centos7 .ssh]$ cat known_hosts
192.168.100.107 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCVDRp3jReHwU4wAxBVo4Aat+UHtKLl4VVpKA3x8k+nTygk4odsn01Zrj8PDzSGd1zGT1DTXFZqYF2C+kYzkd3s=
[oracle@centos7 .ssh]$ 


[oracle@centos7 .ssh]$ ssh oracle@192.168.100.107
oracle@192.168.100.107's password: 
Last login: Fri Dec 28 20:23:22 2018 from 192.168.100.108
[oracle@centos7 ~]$ ifconfig
docker0: flags=4163  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        inet6 fe80::42:e6ff:fe51:a6d6  prefixlen 64  scopeid 0x20 	 	 	 	
        ether 02:42:e6:51:a6:d6  txqueuelen 0  (Ethernet)
        RX packets 72756  bytes 34705340 (33.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 133133  bytes 158851749 (151.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp25s0: flags=4099  mtu 1500
        ether fc:61:98:4f:19:5f  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17  

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 8138  bytes 614263 (599.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8138  bytes 614263 (599.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth24ff817: flags=4163  mtu 1500
        inet6 fe80::707d:b1ff:fe06:274b  prefixlen 64  scopeid 0x20 	 	 	 	
        ether 72:7d:b1:06:27:4b  txqueuelen 0  (Ethernet)
        RX packets 24877  bytes 18606254 (17.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 39457  bytes 38601382 (36.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:78:5b:56  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp7s0: flags=4163  mtu 1500
        inet 192.168.100.107  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 2001:268:c031:29e9:98e7:f562:4ec4:3  prefixlen 128  scopeid 0x0
        inet6 fe80::4bff:9d03:eef7:9a10  prefixlen 64  scopeid 0x20 	 	 	 	
        inet6 2001:268:c031:29e9:1a2b:1bda:f699:4627  prefixlen 64  scopeid 0x0
        ether 74:e5:0b:ba:d1:ac  txqueuelen 1000  (Ethernet)
        RX packets 917681  bytes 975680107 (930.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 599486  bytes 167522088 (159.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[oracle@centos7 ~]$ 


[oracle@centos7 .ssh]$ ll
合計 12
-rw-------. 1 oracle docker 1766 12月 27 20:43 id_rsa
-rw-r--r--. 1 oracle docker  396 12月 27 20:43 id_rsa.pub
-rw-r--r--. 1 oracle docker  177 12月 28 20:07 known_hosts
[oracle@centos7 .ssh]$ ssh -i id_rsa.pub oracle@192.168.100.107
oracle@192.168.100.107's password: 
Last login: Fri Dec 28 20:38:26 2018 from 192.168.100.108
[oracle@centos7 ~]$ ログアウト
Connection to 192.168.100.107 closed.

epel repo install & rlwrap install sqlplus

reference

[CentOS7]EPELリポジトリの簡単な追加方法



https://qiita.com/inomasa/items/391c025532db6b87a1d5
https://qiita.com/hrnrtmks/items/0643fa3cea4237a92a4b
http://discus-hamburg.cocolog-nifty.com/mac_de_oracle/2013/07/oracle-database.html


[oracle@centos7 ~]$ docker exec --interactive --tty --user root --workdir / orcl_12cr2 bash
bash-4.2# curl -O https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 15080  100 15080    0     0  11228      0  0:00:01  0:00:01 --:--:-- 11236
bash-4.2# ls -lt
total 16
-rw-r--r--.   1 root root 15080 Dec 26 14:59 epel-release-7-11.noarch.rpm
drwxrwxrwt.   1 root root    60 Dec 26 14:59 tmp
drwxr-xr-x.   1 root root     6 Dec 26 14:53 run
dr-xr-x---.   1 root root    59 Dec 26 11:48 root
drwxr-xr-x.   1 root root    67 Dec 26 11:44 var
drwxr-xr-x.   1 root root   167 Dec 26 11:44 etc
drwxr-xr-x.   5 root root   340 Dec 23 13:11 dev
dr-xr-xr-x. 323 root root     0 Dec 23 13:11 proc
drwxr-xr-x.   1 root root    20 Dec 23 09:05 opt
drwxr-xr-x.   1 root root    20 Dec 23 08:35 home
lrwxrwxrwx.   1 root root    19 Dec 23 08:20 docker-entrypoint-initdb.d -> /opt/oracle/scripts
dr-xr-xr-x.  13 root root     0 Dec 23 06:45 sys
drwxrwxrwx.   4 1000 1001    32 Dec 23 06:31 mnt
lrwxrwxrwx.   1 root root     7 Nov  6 08:58 bin -> usr/bin
lrwxrwxrwx.   1 root root     7 Nov  6 08:58 lib -> usr/lib
lrwxrwxrwx.   1 root root     9 Nov  6 08:58 lib64 -> usr/lib64
lrwxrwxrwx.   1 root root     8 Nov  6 08:58 sbin -> usr/sbin
drwxr-xr-x.   1 root root    54 Nov  6 08:58 usr
dr-xr-xr-x.   2 root root     6 Apr 11  2018 boot
drwxr-xr-x.   2 root root     6 Apr 11  2018 media
drwxr-xr-x.   2 root root     6 Apr 11  2018 srv
bash-4.2# rpm -ivh epel-release-7-11.noarch.rpm
warning: epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:epel-release-7-11                ################################# [100%]
bash-4.2# yum update
Loaded plugins: ovl
epel/x86_64/metalink                                                                                                           | 8.7 kB  00:00:00     
epel                                                                                                                           | 3.2 kB  00:00:00     
(1/3): epel/x86_64/group_gz                                                                                                    |  88 kB  00:00:08     
(2/3): epel/x86_64/updateinfo                                                                                                  | 944 kB  00:00:09     
(3/3): epel/x86_64/primary                                                                                                     | 3.6 MB  00:00:30     
epel                                                                                                                                      12770/12770
Resolving Dependencies
--> Running transaction check
---> Package tzdata.noarch 0:2018f-2.el7 will be updated
---> Package tzdata.noarch 0:2018g-1.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                          Arch                             Version                                 Repository                            Size
======================================================================================================================================================
Updating:
 tzdata                           noarch                           2018g-1.el7                             ol7_latest                           483 k

Transaction Summary
======================================================================================================================================================
Upgrade  1 Package

Total download size: 483 k
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
tzdata-2018g-1.el7.noarch.rpm                                                                                                  | 483 kB  00:00:07     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Updating   : tzdata-2018g-1.el7.noarch                                                                                                          1/2 
  Cleanup    : tzdata-2018f-2.el7.noarch                                                                                                          2/2 
  Verifying  : tzdata-2018g-1.el7.noarch                                                                                                          1/2 
  Verifying  : tzdata-2018f-2.el7.noarch                                                                                                          2/2 

Updated:
  tzdata.noarch 0:2018g-1.el7                                                                                                                         

Complete!
bash-4.2# cd /etc/yum.repos.d/
bash-4.2# pwd
/etc/yum.repos.d
bash-4.2# ls -lt
total 28
-rw-rw-r--. 1 root root 14370 Nov  6 08:59 public-yum-ol7.repo
-rw-r--r--. 1 root root  1050 Oct  2  2017 epel-testing.repo
-rw-r--r--. 1 root root   951 Oct  2  2017 epel.repo
-rw-rw-r--. 1 root root   230 Feb 12  2015 osquery-s3-centos7.repo
bash-4.2# vim /etc/yum.repos.d/epel.repo
bash-4.2# yum -y install rlwrap
Loaded plugins: ovl
Resolving Dependencies
--> Running transaction check
---> Package rlwrap.x86_64 0:0.43-1.el7 will be installed
--> Processing Dependency: perl(Data::Dumper) for package: rlwrap-0.43-1.el7.x86_64
--> Processing Dependency: /usr/bin/python3 for package: rlwrap-0.43-1.el7.x86_64
--> Running transaction check
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
---> Package python34.x86_64 0:3.4.9-1.el7 will be installed
--> Processing Dependency: python34-libs(x86-64) = 3.4.9-1.el7 for package: python34-3.4.9-1.el7.x86_64
--> Processing Dependency: libpython3.4m.so.1.0()(64bit) for package: python34-3.4.9-1.el7.x86_64
--> Running transaction check
---> Package python34-libs.x86_64 0:3.4.9-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                                  Arch                           Version                             Repository                          Size
======================================================================================================================================================
Installing:
 rlwrap                                   x86_64                         0.43-1.el7                          epel                               119 k
Installing for dependencies:
 perl-Data-Dumper                         x86_64                         2.145-3.el7                         ol7_latest                          47 k
 python34                                 x86_64                         3.4.9-1.el7                         epel                                51 k
 python34-libs                            x86_64                         3.4.9-1.el7                         epel                               8.3 M

Transaction Summary
======================================================================================================================================================
Install  1 Package (+3 Dependent packages)

Total download size: 8.5 M
Installed size: 30 M
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/epel/packages/rlwrap-0.43-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY00:01:10 ETA 
Public key for rlwrap-0.43-1.el7.x86_64.rpm is not installed
(1/4): rlwrap-0.43-1.el7.x86_64.rpm                                                                                            | 119 kB  00:00:01     
(2/4): python34-3.4.9-1.el7.x86_64.rpm                                                                                         |  51 kB  00:00:03     
(3/4): perl-Data-Dumper-2.145-3.el7.x86_64.rpm                                                                                 |  47 kB  00:00:09     
(4/4): python34-libs-3.4.9-1.el7.x86_64.rpm                                                                                    | 8.3 MB  00:00:12     
------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                 707 kB/s | 8.5 MB  00:00:12     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) "
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-11.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python34-libs-3.4.9-1.el7.x86_64                                                                                                   1/4 
  Installing : python34-3.4.9-1.el7.x86_64                                                                                                        2/4 
  Installing : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                                3/4 
  Installing : rlwrap-0.43-1.el7.x86_64                                                                                                           4/4 
  Verifying  : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                                1/4 
  Verifying  : python34-3.4.9-1.el7.x86_64                                                                                                        2/4 
  Verifying  : python34-libs-3.4.9-1.el7.x86_64                                                                                                   3/4 
  Verifying  : rlwrap-0.43-1.el7.x86_64                                                                                                           4/4 

Installed:
  rlwrap.x86_64 0:0.43-1.el7                                                                                                                          

Dependency Installed:
  perl-Data-Dumper.x86_64 0:2.145-3.el7                python34.x86_64 0:3.4.9-1.el7                python34-libs.x86_64 0:3.4.9-1.el7               

Complete!
bash-4.2# yum list | grep  rlwrap
rlwrap.x86_64                           0.43-1.el7                   @epel      
bash-4.2# which rlwrap
/usr/bin/rlwrap

rootでinstallしたので、oracleユーザーからは見えなかった。。


[oracle@609a69bc0b21 ~]$ sudo curl -O https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
[sudo] password for oracle: 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 15080  100 15080    0     0  11244      0  0:00:01  0:00:01 --:--:-- 11253
[oracle@609a69bc0b21 ~]$ ls -lt
total 16
-rw-r--r--. 1 root root 15080 Dec 26 16:17 epel-release-7-11.noarch.rpm
lrwxrwxrwx. 1 root root    26 Dec 23 08:35 setPassword.sh -> /opt/oracle/setPassword.sh
[oracle@609a69bc0b21 ~]$ sudo rpm -ivh epel-release-7-11.noarch.rpm
Preparing...                          ################################# [100%]
	package epel-release-7-11.noarch is already installed
[oracle@609a69bc0b21 ~]$ sudo yum -y install rlwrap
Loaded plugins: ovl
Resolving Dependencies
--> Running transaction check
---> Package rlwrap.x86_64 0:0.43-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                            Arch                               Version                                 Repository                        Size
======================================================================================================================================================
Installing:
 rlwrap                             x86_64                             0.43-1.el7                              epel                             119 k

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

Total download size: 119 k
Installed size: 281 k
Downloading packages:
rlwrap-0.43-1.el7.x86_64.rpm                                                                                                   | 119 kB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : rlwrap-0.43-1.el7.x86_64                                                                                                           1/1 
  Verifying  : rlwrap-0.43-1.el7.x86_64                                                                                                           1/1 

Installed:
  rlwrap.x86_64 0:0.43-1.el7                                                                                                                          

Complete!
[oracle@609a69bc0b21 ~]$ sudo which rlwrap
/bin/rlwrap
[oracle@609a69bc0b21 ~]$ rlwrap
Usage: rlwrap [options] command ...

Options:
  -a[password prompt]        --always-readline[=password prompt]
  -A                         --ansi-colour-aware
  -b                  --break-chars=
  -c                         --complete-filenames
  -C                 --command-name=
  -D  <0|1|2>                --history-no-dupes=<0|1|2>
  -e                --extra-char-after-completion=
  -f        --file=
  -g                 --forget-matching=
  -h                         --help
  -H                   --history-filename=
  -i                         --case-insensitive
  -I                         --pass-sigint-as-sigterm
  -l                   --logfile=
  -m[newline substitute]     --multi-line[=newline substitute]
  -M  <.ext>                 --multi-line-ext=<.ext>
  -n                         --no-warnings
  -N                         --no-children
  -o                         --one-shot
  -O                 --only-cook=
  -p[colour]                 --prompt-colour[=colour]
  -P                  --pre-given=
  -q                  --quote-characters=
  -r                         --remember
  -R                         --renice
  -s                      --histsize= (negative: readonly)
  -S                 --substitute-prompt=
  -t                   --set-term-name=
  -U                         --mirror-arguments
  -v                         --version
  -w                      --wait-before-prompt= (msec, <0  : patient mode)
  -W                         --polling
  -z         --filter= ('rlwrap -z listing' writes a list of installed filters)

bug reports, suggestions, updates:
https://github.com/hanslub42/rlwrap
[oracle@609a69bc0b21 ~]$ 


[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

[oracle@609a69bc0b21 ~]$ rlwrap -pRed sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Wed Dec 26 16:21:55 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

@> 
[oracle@609a69bc0b21 ~]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Wed Dec 26 16:22:41 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

@> 


[oracle@609a69bc0b21 ~]$ sqlplus sys/ORACLE_PWD as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed Dec 26 16:24:07 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@ORCL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ~]$ 
[oracle@609a69bc0b21 ~]$ rlwrap -pRed sqlplus sys/ORACLE_PWD as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed Dec 26 16:24:36 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@ORCL> select instance_name from v$instance;

INSTANCE_NAME
----------------
ORCL

1 row selected.

Elapsed: 00:00:00.02
SYS@ORCL> select instance_name from v$instance;

INSTANCE_NAME
----------------
ORCL

1 row selected.

Elapsed: 00:00:00.00
SYS@ORCL> 


# .bashrc

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

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
alias sqlplus='rlwrap -pRed sqlplus'


[oracle@centos7 ~]$ docker exec -it orcl_12cr2 /bin/bash
[oracle@609a69bc0b21 ~]$ rlwrap -pRed sqlplus sys/ORACLE_PWD as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed Dec 26 16:28:00 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@ORCL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ~]$ sqlplus sys/ORACLE_PWD as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed Dec 26 16:28:13 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@ORCL> 


[oracle@609a69bc0b21 ~]$ ll
total 16
-rw-r--r--. 1 root root 15080 Dec 26 16:17 epel-release-7-11.noarch.rpm
lrwxrwxrwx. 1 root root    26 Dec 23 08:35 setPassword.sh -> /opt/oracle/setPassword.sh
[oracle@609a69bc0b21 ~]$ mkdir rlwrap-extensions
[oracle@609a69bc0b21 ~]$ ll
total 16
-rw-r--r--. 1 root   root     15080 Dec 26 16:17 epel-release-7-11.noarch.rpm
drwxr-xr-x. 2 oracle oinstall     6 Dec 26 16:29 rlwrap-extensions
lrwxrwxrwx. 1 root   root        26 Dec 23 08:35 setPassword.sh -> /opt/oracle/setPassword.sh
[oracle@609a69bc0b21 ~]$ cd rlwrap-extensions
[oracle@609a69bc0b21 rlwrap-extensions]$ pwd
/home/oracle/rlwrap-extensions
[oracle@609a69bc0b21 rlwrap-extensions]$ wget http://www.linuxification.at/download/rlwrap-extensions-V12-0.05.tar.gz
bash: wget: command not found
[oracle@609a69bc0b21 rlwrap-extensions]$ curl -O http://www.linuxification.at/download/rlwrap-extensions-V12-0.05.tar.gz  
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 57847  100 57847    0     0  28254      0  0:00:02  0:00:02 --:--:-- 28273
[oracle@609a69bc0b21 rlwrap-extensions]$ tar xvfz rlwrap-extensions-V12-0.05.tar.gz
adrci
asm+
asmcmd
dgmgrl
README
README.english
rman
sql+
sql.functions
sqlplus
sqlplus.all
sqlplus.cdb
sqlplus.dba
sqlplus.dbms_packages
sqlplus.functions
sqlplus.gvdollar
sqlplus.init
sqlplus._init
sqlplus.packages
sqlplus.rman
sqlplus.tables
sqlplus.user
sqlplus.utl_packages
sqlplus.vdollar
[oracle@609a69bc0b21 rlwrap-extensions]$ 


@> SELECT * FROM v$
Display all 104 possibilities? (y or n)
ABORT          CONNECT        DROP           INCREMENT      MAXEXTENTS     OPTION         REVOKE         STARTUP        VALIDATE
ACCESS         CREATE         ELSE           INDEX          MINUS          ORDER          ROWID          SUCCESSFUL     VALUES
ALTER          CURRENT        EXCLUSIVE      INITIAL        MLSLABEL       PAGESIZE       ROWNUM         SYNONYM        VARCHAR
ARCHIVE        DATABASE       EXISTS         INSERT         MODE           PARAMETER      ROWS           TABLE          VARCHAR2
AUDIT          DATE           FILE           INTEGER        MODIFY         PCTFREE        SELECT         TABLESPACE     VIEW
BETWEEN        DECIMAL        FLOAT          INTERSECT      NOAUDIT        PLUGGABLE      SESSION        THEN           WHENEVER
CHAR           DEFAULT        FROM           INTO           NOCOMPRESS     PRIOR          SHARE          TRANSACTIONAL  WHERE
CHECK          DEFERRABLE     GRANT          LEVEL          NOWAIT         PRIVILEGES     SHUTDOWN       TRIGGER        WITH
CLUSTER        DEFERRED       GROUP          LIKE           NULL           PUBLIC         SIZE           UNION          
COLUMN         DELETE         HAVING         LINESIZE       NUMBER         QUIESCE        SMALLINT       UNIQUE         
COMMENT        DESC           IDENTIFIED     LOCK           OFFLINE        RENAME         SPOOL          UNQUIESCE      
COMPRESS       DISTINCT       IMMEDIATE      LONG           ONLINE         RESOURCE       START          UPDATE         
@> SELECT * FROM v$IN
INCREMENT  INDEX      INITIAL    INSERT     INTEGER    INTERSECT  INTO       


# .bashrc

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

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
alias sqlplus='rlwrap -pRed -if ~/rlwrap-extensions/sqlplus sqlplus'


[oracle@609a69bc0b21 ~]$ sqlplus sys/ORACLE_PWD as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Wed Dec 26 16:45:15 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@ORCL> select instance_name from v$instance;

INSTANCE_NAME
----------------
ORCL

1 row selected.

Elapsed: 00:00:00.01
SYS@ORCL> SELECT 
Display all 104 possibilities? (y or n)
ABORT          CONNECT        DROP           INCREMENT      MAXEXTENTS     OPTION         REVOKE         STARTUP        VALIDATE
ACCESS         CREATE         ELSE           INDEX          MINUS          ORDER          ROWID          SUCCESSFUL     VALUES
ALTER          CURRENT        EXCLUSIVE      INITIAL        MLSLABEL       PAGESIZE       ROWNUM         SYNONYM        VARCHAR
ARCHIVE        DATABASE       EXISTS         INSERT         MODE           PARAMETER      ROWS           TABLE          VARCHAR2
AUDIT          DATE           FILE           INTEGER        MODIFY         PCTFREE        SELECT         TABLESPACE     VIEW
BETWEEN        DECIMAL        FLOAT          INTERSECT      NOAUDIT        PLUGGABLE      SESSION        THEN           WHENEVER
CHAR           DEFAULT        FROM           INTO           NOCOMPRESS     PRIOR          SHARE          TRANSACTIONAL  WHERE
CHECK          DEFERRABLE     GRANT          LEVEL          NOWAIT         PRIVILEGES     SHUTDOWN       TRIGGER        WITH
CLUSTER        DEFERRED       GROUP          LIKE           NULL           PUBLIC         SIZE           UNION          
COLUMN         DELETE         HAVING         LINESIZE       NUMBER         QUIESCE        SMALLINT       UNIQUE         
COMMENT        DESC           IDENTIFIED     LOCK           OFFLINE        RENAME         SPOOL          UNQUIESCE      
COMPRESS       DISTINCT       IMMEDIATE      LONG           ONLINE         RESOURCE       START          UPDATE         
SYS@ORCL> SELECT sysdate from dual;

SYSDATE
---------
26-DEC-18

1 row selected.

Elapsed: 00:00:00.01
SYS@ORCL> 

sudo user add docker oracle


[oracle@centos7 ~]$ docker exec -it orcl_12cr2 /bin/bash
[oracle@609a69bc0b21 ~]$ id
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)
[oracle@609a69bc0b21 ~]$ 

[oracle@centos7 ~]$ docker exec --interactive --tty --user root --workdir / orcl_12cr2 bash
bash-4.2# visudo
bash-4.2# exit

#--これはいけない
## Allows people in group wheel to run all commands
#%wheel ALL=(ALL)       ALL
oinstall ALL=(ALL)      ALL
#--これはいけるはず
## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL
oracle          ALL=(ALL)       ALL

[oracle@centos7 ~]$ docker exec -it orcl_12cr2 /bin/bash
[oracle@609a69bc0b21 ~]$ whoami
oracle
[oracle@609a69bc0b21 ~]$ id
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)
[oracle@609a69bc0b21 ~]$ sudo echo "hey"
[sudo] password for oracle: 
hey
[oracle@609a69bc0b21 ~]$ 

docker oracle passwd install


[oracle@centos7 ~]$ docker exec --interactive --tty --user root --workdir / orcl_12cr2 bash
bash-4.2# whereis passwd
passwd: /etc/passwd
bash-4.2# passwd
bash: passwd: command not found
bash-4.2# yum install -y passwd
Loaded plugins: ovl
Resolving Dependencies
--> Running transaction check
---> Package passwd.x86_64 0:0.79-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                          Arch                             Version                                 Repository                            Size
======================================================================================================================================================
Installing:
 passwd                           x86_64                           0.79-4.el7                              ol7_latest                           104 k

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

Total download size: 104 k
Installed size: 420 k
Downloading packages:
passwd-0.79-4.el7.x86_64.rpm                                                                                                   | 104 kB  00:00:03     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : passwd-0.79-4.el7.x86_64                                                                                                           1/1 
  Verifying  : passwd-0.79-4.el7.x86_64                                                                                                           1/1 

Installed:
  passwd.x86_64 0:0.79-4.el7                                                                                                                          

Complete!
bash-4.2# whereis passwd
passwd: /usr/bin/passwd /etc/passwd
bash-4.2# 

sudo package install docker oracle


[oracle@centos7 ~]$ docker exec --interactive --tty --user root --workdir / orcl_12cr2 bash
bash-4.2# yum list installed | grep sudo
bash-4.2# yum install -y sudo
Loaded plugins: ovl
Resolving Dependencies
--> Running transaction check
---> Package sudo.x86_64 0:1.8.23-3.el7 will be installed
--> Processing Dependency: /usr/bin/vi for package: sudo-1.8.23-3.el7.x86_64
--> Running transaction check
---> Package vim-minimal.x86_64 2:7.4.160-5.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                             Arch                           Version                                  Repository                          Size
======================================================================================================================================================
Installing:
 sudo                                x86_64                         1.8.23-3.el7                             ol7_latest                         841 k
Installing for dependencies:
 vim-minimal                         x86_64                         2:7.4.160-5.el7                          ol7_latest                         436 k

Transaction Summary
======================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 1.2 M
Installed size: 3.9 M
Downloading packages:
(1/2): vim-minimal-7.4.160-5.el7.x86_64.rpm                                                                                    | 436 kB  00:00:04     
(2/2): sudo-1.8.23-3.el7.x86_64.rpm                                                                                            | 841 kB  00:00:04     
------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                 283 kB/s | 1.2 MB  00:00:04     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 2:vim-minimal-7.4.160-5.el7.x86_64                                                                                                 1/2 
  Installing : sudo-1.8.23-3.el7.x86_64                                                                                                           2/2 
  Verifying  : 2:vim-minimal-7.4.160-5.el7.x86_64                                                                                                 1/2 
  Verifying  : sudo-1.8.23-3.el7.x86_64                                                                                                           2/2 

Installed:
  sudo.x86_64 0:1.8.23-3.el7                                                                                                                          

Dependency Installed:
  vim-minimal.x86_64 2:7.4.160-5.el7                                                                                                                  

Complete!
bash-4.2# yum list installed | grep sudo
sudo.x86_64                    1.8.23-3.el7             @ol7_latest             
bash-4.2# 

osquery install docker

https://osquery.io/docs/tables/

[oracle@centos7 ~]$ docker exec --interactive --tty --user root --workdir / orcl_12cr2 bash
bash-4.2# whoami
root
bash-4.2# yum -y install https://osquery-packages.s3.amazonaws.com/centos7/noarch/osquery-s3-centos7-repo-1-0.0.noarch.rpm
Loaded plugins: ovl
osquery-s3-centos7-repo-1-0.0.noarch.rpm                                                                                       | 5.7 kB  00:00:00     
Examining /var/tmp/yum-root-e42ejR/osquery-s3-centos7-repo-1-0.0.noarch.rpm: osquery-s3-centos7-repo-1-0.0.noarch
Marking /var/tmp/yum-root-e42ejR/osquery-s3-centos7-repo-1-0.0.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package osquery-s3-centos7-repo.noarch 0:1-0.0 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                                  Arch                    Version                Repository                                              Size
======================================================================================================================================================
Installing:
 osquery-s3-centos7-repo                  noarch                  1-0.0                  /osquery-s3-centos7-repo-1-0.0.noarch                  3.2 k

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

Total size: 3.2 k
Installed size: 3.2 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : osquery-s3-centos7-repo-1-0.0.noarch                                                                                               1/1 
  Verifying  : osquery-s3-centos7-repo-1-0.0.noarch                                                                                               1/1 

Installed:
  osquery-s3-centos7-repo.noarch 0:1-0.0                                                                                                              

Complete!
bash-4.2# yum -y install osquery
Loaded plugins: ovl
ol7_UEKR4                                                                                                                      | 1.2 kB  00:00:00     
ol7_latest                                                                                                                     | 1.4 kB  00:00:00     
osquery-s3-centos7-repo                                                                                                        |  951 B  00:00:00     
osquery-s3-centos7-repo/x86_64/primary                                                                                         | 6.7 kB  00:00:01     
osquery-s3-centos7-repo                                                                                                                         69/69
Resolving Dependencies
--> Running transaction check
---> Package osquery.x86_64 0:3.2.6-1.linux will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================
 Package                       Arch                         Version                               Repository                                     Size
======================================================================================================================================================
Installing:
 osquery                       x86_64                       3.2.6-1.linux                         osquery-s3-centos7-repo                       8.0 M

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

Total download size: 8.0 M
Installed size: 23 M
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/osquery-s3-centos7-repo/packages/osquery-3.2.6-1.linux.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID c9d8b80b: NOKEY
Public key for osquery-3.2.6-1.linux.x86_64.rpm is not installed
osquery-3.2.6-1.linux.x86_64.rpm                                                                                               | 8.0 MB  00:00:21     
Retrieving key from file:///etc/pki/rpm-gpg/OSQUERY-S3-RPM-REPO-GPGKEY
Importing GPG key 0xC9D8B80B:
 Userid     : "osquery (osquery) "
 Fingerprint: 1484 120a c4e9 f8a1 a577 aeee 97a8 0c63 c9d8 b80b
 Package    : osquery-s3-centos7-repo-1-0.0.noarch (installed)
 From       : /etc/pki/rpm-gpg/OSQUERY-S3-RPM-REPO-GPGKEY
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : osquery-3.2.6-1.linux.x86_64                                                                                                       1/1 
  Verifying  : osquery-3.2.6-1.linux.x86_64                                                                                                       1/1 

Installed:
  osquery.x86_64 0:3.2.6-1.linux                                                                                                                      

Complete!
bash-4.2# 

bash-4.2# osqueryi
Using a virtual database. Need help, type '.help'
osquery> .help
Welcome to the osquery shell. Please explore your OS!
You are connected to a transient 'in-memory' virtual database.

.all [TABLE]     Select all from a table
.bail ON|OFF     Stop after hitting an error
.echo ON|OFF     Turn command echo on or off
.exit            Exit this program
.features        List osquery's features and their statuses
.headers ON|OFF  Turn display of headers on or off
.help            Show this message
.mode MODE       Set output mode where MODE is one of:
                   csv      Comma-separated values
                   column   Left-aligned columns see .width
                   line     One value per line
                   list     Values delimited by .separator string
                   pretty   Pretty printed SQL results (default)
.nullvalue STR   Use STRING in place of NULL values
.print STR...    Print literal STRING
.quit            Exit this program
.schema [TABLE]  Show the CREATE statements
.separator STR   Change separator used by output mode
.socket          Show the osquery extensions socket path
.show            Show the current values for various settings
.summary         Alias for the show meta command
.tables [TABLE]  List names of tables
.width [NUM1]+   Set column widths for "column" mode
.timer ON|OFF      Turn the CPU timer measurement on or off
osquery> 

osquery> select name,version from os_version;
+---------------------------------+-----------------------------------------------------+
| name                            | version                                             |
+---------------------------------+-----------------------------------------------------+
| Red Hat Enterprise Linux Server | Red Hat Enterprise Linux Server release 7.6 (Maipo) |
+---------------------------------+-----------------------------------------------------+
osquery> 


osquery> select hostname, cpu_brand, hardware_vendor, hardware_model from system_info; 
+--------------+----------------------------------------+-----------------+----------------+
| hostname     | cpu_brand                              | hardware_vendor | hardware_model |
+--------------+----------------------------------------+-----------------+----------------+
| 609a69bc0b21 | Intel(R) Celeron(R) CPU B800 @ 1.50GHz |                 |                |
+--------------+----------------------------------------+-----------------+----------------+
osquery> 


osquery> select * from users;
+-------+-------+------------+------------+-----------------+----------------------------+------------------+----------------+------+
| uid   | gid   | uid_signed | gid_signed | username        | description                | directory        | shell          | uuid |
+-------+-------+------------+------------+-----------------+----------------------------+------------------+----------------+------+
| 0     | 0     | 0          | 0          | root            | root                       | /root            | /bin/bash      |      |
| 1     | 1     | 1          | 1          | bin             | bin                        | /bin             | /sbin/nologin  |      |
| 2     | 2     | 2          | 2          | daemon          | daemon                     | /sbin            | /sbin/nologin  |      |
| 3     | 4     | 3          | 4          | adm             | adm                        | /var/adm         | /sbin/nologin  |      |
| 4     | 7     | 4          | 7          | lp              | lp                         | /var/spool/lpd   | /sbin/nologin  |      |
| 5     | 0     | 5          | 0          | sync            | sync                       | /sbin            | /bin/sync      |      |
| 6     | 0     | 6          | 0          | shutdown        | shutdown                   | /sbin            | /sbin/shutdown |      |
| 7     | 0     | 7          | 0          | halt            | halt                       | /sbin            | /sbin/halt     |      |
| 8     | 12    | 8          | 12         | mail            | mail                       | /var/spool/mail  | /sbin/nologin  |      |
| 11    | 0     | 11         | 0          | operator        | operator                   | /root            | /sbin/nologin  |      |
| 12    | 100   | 12         | 100        | games           | games                      | /usr/games       | /sbin/nologin  |      |
| 14    | 50    | 14         | 50         | ftp             | FTP User                   | /var/ftp         | /sbin/nologin  |      |
| 99    | 99    | 99         | 99         | nobody          | Nobody                     | /                | /sbin/nologin  |      |
| 192   | 192   | 192        | 192        | systemd-network | systemd Network Management | /                | /sbin/nologin  |      |
| 81    | 81    | 81         | 81         | dbus            | System message bus         | /                | /sbin/nologin  |      |
| 32    | 32    | 32         | 32         | rpc             | Rpcbind Daemon             | /var/lib/rpcbind | /sbin/nologin  |      |
| 29    | 29    | 29         | 29         | rpcuser         | RPC Service User           | /var/lib/nfs     | /sbin/nologin  |      |
| 65534 | 65534 | 65534      | 65534      | nfsnobody       | Anonymous NFS User         | /var/lib/nfs     | /sbin/nologin  |      |
| 54321 | 54321 | 54321      | 54321      | oracle          |                            | /home/oracle     | /bin/bash      |      |
+-------+-------+------------+------------+-----------------+----------------------------+------------------+----------------+------+
osquery> 


osquery> select * from cpu_time; 
+------+---------+-------+---------+----------+--------+-----+---------+-------+-------+------------+
| core | user    | nice  | system  | idle     | iowait | irq | softirq | steal | guest | guest_nice |
+------+---------+-------+---------+----------+--------+-----+---------+-------+-------+------------+
| 0    | 1579161 | 10306 | 1155039 | 17294224 | 20470  | 0   | 8705    | 0     | 0     | 0          |
| 1    | 1628500 | 23079 | 1157443 | 52210    | 248    | 0   | 5020    | 0     | 0     | 0          |
+------+---------+-------+---------+----------+--------+-----+---------+-------+-------+------------+
osquery> 


osquery> select * from crontab;
+-------+--------+------+--------------+-------+-------------+---------------------------------+---------------------+
| event | minute | hour | day_of_month | month | day_of_week | command                         | path                |
+-------+--------+------+--------------+-------+-------------+---------------------------------+---------------------+
|       | 01     | *    | *            | *     | *           | root run-parts /etc/cron.hourly | /etc/cron.d/0hourly |
|       | */10   | *    | *            | *     | *           | root /usr/lib64/sa/sa1 1 1      | /etc/cron.d/sysstat |
|       | 53     | 23   | *            | *     | *           | root /usr/lib64/sa/sa2 -A       | /etc/cron.d/sysstat |
+-------+--------+------+--------------+-------+-------------+---------------------------------+---------------------+
osquery> 



osquery> select * from process_events;
W1226 11:58:28.851143 28937 virtual_table.cpp:565] Table process_events is event-based but events are disabled
W1226 11:58:28.851416 28937 virtual_table.cpp:572] Please see the table documentation: https://osquery.io/schema/#process_events
osquery> select * from routes;
+-----------------+---------+------------+------------+-------+-----------+-----+--------+-----------+
| destination     | netmask | gateway    | source     | flags | interface | mtu | metric | type      |
+-----------------+---------+------------+------------+-------+-----------+-----+--------+-----------+
| 0.0.0.0         | 0       | 172.17.0.1 |            | 0     | eth0      | 0   | 0      | gateway   |
| 172.17.0.0      | 16      |            | 172.17.0.2 | 0     | eth0      | 0   | 0      | gateway   |
| 127.0.0.0       | 0       |            | 127.0.0.1  | 0     | lo        | 0   | 0      | broadcast |
| 127.0.0.0       | 8       |            | 127.0.0.1  | 0     | lo        | 0   | 0      | local     |
| 127.0.0.1       | 0       |            | 127.0.0.1  | 0     | lo        | 0   | 0      | local     |
| 127.255.255.255 | 0       |            | 127.0.0.1  | 0     | lo        | 0   | 0      | broadcast |
| 172.17.0.0      | 0       |            | 172.17.0.2 | 0     | eth0      | 0   | 0      | broadcast |
| 172.17.0.2      | 0       |            | 172.17.0.2 | 0     | eth0      | 0   | 0      | local     |
| 172.17.255.255  | 0       |            | 172.17.0.2 | 0     | eth0      | 0   | 0      | broadcast |
| 0.0.0.0         | 0       |            |            | 0     | lo        | 0   | -1     | other     |
| 0.0.0.0         | 0       |            |            | 0     | lo        | 0   | -1     | other     |
+-----------------+---------+------------+------------+-------+-----------+-----+--------+-----------+
osquery> 



osquery> select * from processes;
+-------+---------------+-------------------+---------------------------------------------------------------------+-------+-----+------+-------+-------+-------+-------+-------+-------+---------+------------+---------------+------------+-----------+-------------+-----------------+--------------------+------------+--------+--------+---------+------+------------------+---------------+---------------+---------------+---------------+----------------+---------------+
| pid   | name          | path              | cmdline                                                             | state | cwd | root | uid   | gid   | euid  | egid  | suid  | sgid  | on_disk | wired_size | resident_size | total_size | user_time | system_time | disk_bytes_read | disk_bytes_written | start_time | parent | pgroup | threads | nice | cgroup_namespace | ipc_namespace | mnt_namespace | net_namespace | pid_namespace | user_namespace | uts_namespace |
+-------+---------------+-------------------+---------------------------------------------------------------------+-------+-----+------+-------+-------+-------+-------+-------+-------+---------+------------+---------------+------------+-----------+-------------+-----------------+--------------------+------------+--------+--------+---------+------+------------------+---------------+---------------+---------------+---------------+----------------+---------------+
| 1     | runOracle.sh  |                   | /bin/bash /opt/oracle/runOracle.sh                                  | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 624000        | 11688000   | 26        | 179         |                 | 0                  | 23181      | 0      | 1      | 1       | 0    |                  |               |               |               |               |                |               |
| 2491  | ora_pmon_orcl |                   | ora_pmon_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 17108000      | 2007792000 | 563       | 1683        |                 | 0                  | 24198      | 1      | 2491   | 1       | 0    |                  |               |               |               |               |                |               |
| 2493  | ora_clmn_orcl |                   | ora_clmn_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 14272000      | 2007796000 | 229       | 547         |                 | 0                  | 24198      | 1      | 2493   | 1       | 0    |                  |               |               |               |               |                |               |
| 2495  | ora_psp0_orcl |                   | ora_psp0_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 14240000      | 2007792000 | 1071      | 5086        |                 | 0                  | 24198      | 1      | 2495   | 1       | 0    |                  |               |               |               |               |                |               |
| 2497  | ora_vktm_orcl |                   | ora_vktm_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 13708000      | 2007796000 | 2514      | 4127        |                 | 0                  | 24199      | 1      | 2497   | 1       | 0    |                  |               |               |               |               |                |               |
| 2501  | ora_gen0_orcl |                   | ora_gen0_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 47668000      | 2009652000 | 1551      | 1791        |                 | 0                  | 24200      | 1      | 2501   | 1       | 0    |                  |               |               |               |               |                |               |
| 2503  | ora_mman_orcl |                   | ora_mman_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 450452000     | 2007792000 | 394       | 519         |                 | 0                  | 24200      | 1      | 2503   | 1       | 0    |                  |               |               |               |               |                |               |
| 2507  | ora_scmn_orcl |                   | ora_gen1_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 31160000      | 2228732000 | 6520      | 5162        |                 | 0                  | 24200      | 1      | 2507   | 3       | 0    |                  |               |               |               |               |                |               |
| 2511  | ora_diag_orcl |                   | ora_diag_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 17800000      | 2007888000 | 997       | 720         |                 | 0                  | 24200      | 1      | 2511   | 1       | 0    |                  |               |               |               |               |                |               |
| 2513  | ora_scmn_orcl |                   | ora_ofsd_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 15924000      | 2228728000 | 304       | 444         |                 | 0                  | 24200      | 1      | 2513   | 3       | 0    |                  |               |               |               |               |                |               |
| 2517  | ora_dbrm_orcl |                   | ora_dbrm_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 152736000     | 2024748000 | 11850     | 11669       |                 | 0                  | 24200      | 1      | 2517   | 1       | 0    |                  |               |               |               |               |                |               |
| 2519  | ora_vkrm_orcl |                   | ora_vkrm_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 17064000      | 2007796000 | 3890      | 3349        |                 | 0                  | 24200      | 1      | 2519   | 1       | 0    |                  |               |               |               |               |                |               |
| 2521  | ora_svcb_orcl |                   | ora_svcb_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 13812000      | 2008304000 | 652       | 1036        |                 | 0                  | 24200      | 1      | 2521   | 1       | 0    |                  |               |               |               |               |                |               |
| 2523  | ora_pman_orcl |                   | ora_pman_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 14236000      | 2007796000 | 3417      | 1872        |                 | 0                  | 24200      | 1      | 2523   | 1       | 0    |                  |               |               |               |               |                |               |
| 2525  | ora_dia0_orcl |                   | ora_dia0_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 24396000      | 2010936000 | 22581     | 65          |                 | 0                  | 24200      | 1      | 2525   | 1       | 0    |                  |               |               |               |               |                |               |
| 2527  | ora_dbw0_orcl |                   | ora_dbw0_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 292272000     | 2019436000 | 1481      | 1061        |                 | 0                  | 24200      | 1      | 2527   | 1       | 0    |                  |               |               |               |               |                |               |
| 2529  | ora_lgwr_orcl |                   | ora_lgwr_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 23624000      | 2008316000 | 1322      | 2007        |                 | 0                  | 24200      | 1      | 2529   | 1       | 0    |                  |               |               |               |               |                |               |
| 2531  | ora_ckpt_orcl |                   | ora_ckpt_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 40204000      | 2008316000 | 3984      | 3215        |                 | 0                  | 24200      | 1      | 2531   | 1       | 0    |                  |               |               |               |               |                |               |
| 2533  | ora_lg00_orcl |                   | ora_lg00_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 21800000      | 2007800000 | 361       | 799         |                 | 0                  | 24200      | 1      | 2533   | 1       | 0    |                  |               |               |               |               |                |               |
| 2535  | ora_smon_orcl |                   | ora_smon_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 57756000      | 2010724000 | 701       | 71          |                 | 0                  | 24200      | 1      | 2535   | 1       | 0    |                  |               |               |               |               |                |               |
| 2537  | ora_lg01_orcl |                   | ora_lg01_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 18636000      | 2007800000 | 159       | 296         |                 | 0                  | 24201      | 1      | 2537   | 1       | 0    |                  |               |               |               |               |                |               |
| 2539  | ora_smco_orcl |                   | ora_smco_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 15388000      | 2007800000 | 1157      | 1071        |                 | 0                  | 24201      | 1      | 2539   | 1       | 0    |                  |               |               |               |               |                |               |
| 2541  | ora_reco_orcl |                   | ora_reco_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 35844000      | 2009624000 | 242       | 114         |                 | 0                  | 24201      | 1      | 2541   | 1       | 0    |                  |               |               |               |               |                |               |
| 25441 | ora_w002_orcl |                   | ora_w002_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 56816000      | 2010364000 | 21        | 12          |                 | 0                  | 197432     | 1      | 25441  | 1       | 0    |                  |               |               |               |               |                |               |
| 2545  | ora_lreg_orcl |                   | ora_lreg_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 23716000      | 2013516000 | 897       | 487         |                 | 0                  | 24201      | 1      | 2545   | 1       | 0    |                  |               |               |               |               |                |               |
| 2549  | ora_pxmn_orcl |                   | ora_pxmn_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 14572000      | 2007792000 | 249       | 457         |                 | 0                  | 24201      | 1      | 2549   | 1       | 0    |                  |               |               |               |               |                |               |
| 2553  | ora_mmon_orcl |                   | ora_mmon_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 183800000     | 2032004000 | 54770     | 5823        |                 | 0                  | 24201      | 1      | 2553   | 1       | 0    |                  |               |               |               |               |                |               |
| 2555  | ora_mmnl_orcl |                   | ora_mmnl_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 33552000      | 2008604000 | 6256      | 854         |                 | 0                  | 24201      | 1      | 2555   | 1       | 0    |                  |               |               |               |               |                |               |
| 2557  | ora_d000_orcl |                   | ora_d000_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 12636000      | 2010596000 | 216       | 207         |                 | 0                  | 24201      | 1      | 2557   | 1       | 0    |                  |               |               |               |               |                |               |
| 2559  | ora_s000_orcl |                   | ora_s000_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 12468000      | 2009892000 | 178       | 186         |                 | 0                  | 24201      | 1      | 2559   | 1       | 0    |                  |               |               |               |               |                |               |
| 2561  | ora_tmon_orcl |                   | ora_tmon_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 14528000      | 2007796000 | 127       | 314         |                 | 0                  | 24201      | 1      | 2561   | 1       | 0    |                  |               |               |               |               |                |               |
| 2571  | ora_tt00_orcl |                   | ora_tt00_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 22740000      | 2030972000 | 66        | 377         |                 | 0                  | 24206      | 1      | 2571   | 1       | 0    |                  |               |               |               |               |                |               |
| 2573  | ora_tt01_orcl |                   | ora_tt01_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 13748000      | 2007792000 | 131       | 204         |                 | 0                  | 24206      | 1      | 2573   | 1       | 0    |                  |               |               |               |               |                |               |
| 2575  | ora_tt02_orcl |                   | ora_tt02_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 14064000      | 2007792000 | 628       | 561         |                 | 0                  | 24206      | 1      | 2575   | 1       | 0    |                  |               |               |               |               |                |               |
| 2577  | ora_aqpc_orcl |                   | ora_aqpc_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 24408000      | 2009620000 | 147       | 247         |                 | 0                  | 24208      | 1      | 2577   | 1       | 0    |                  |               |               |               |               |                |               |
| 2581  | ora_p000_orcl |                   | ora_p000_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 320548000     | 2017456000 | 13959     | 1685        |                 | 0                  | 24210      | 1      | 2581   | 1       | 0    |                  |               |               |               |               |                |               |
| 2583  | ora_p001_orcl |                   | ora_p001_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 480856000     | 2017460000 | 13912     | 1773        |                 | 0                  | 24210      | 1      | 2583   | 1       | 0    |                  |               |               |               |               |                |               |
| 2585  | ora_p002_orcl |                   | ora_p002_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 236996000     | 2013472000 | 11400     | 2277        |                 | 0                  | 24210      | 1      | 2585   | 1       | 0    |                  |               |               |               |               |                |               |
| 2587  | ora_p003_orcl |                   | ora_p003_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 241076000     | 2012904000 | 10077     | 1944        |                 | 0                  | 24210      | 1      | 2587   | 1       | 0    |                  |               |               |               |               |                |               |
| 2589  | ora_p004_orcl |                   | ora_p004_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 87560000      | 2010716000 | 1681      | 363         |                 | 0                  | 24210      | 1      | 2589   | 1       | 0    |                  |               |               |               |               |                |               |
| 2591  | ora_p005_orcl |                   | ora_p005_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 109820000     | 2012892000 | 1721      | 357         |                 | 0                  | 24210      | 1      | 2591   | 1       | 0    |                  |               |               |               |               |                |               |
| 2593  | ora_p006_orcl |                   | ora_p006_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 96940000      | 2010680000 | 1791      | 302         |                 | 0                  | 24210      | 1      | 2593   | 1       | 0    |                  |               |               |               |               |                |               |
| 2595  | ora_p007_orcl |                   | ora_p007_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 98428000      | 2010680000 | 1802      | 266         |                 | 0                  | 24210      | 1      | 2595   | 1       | 0    |                  |               |               |               |               |                |               |
| 26    | tnslsnr       |                   | /opt/oracle/product/12.2.0.1/dbhome_1/bin/tnslsnr LISTENER -inherit | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 5120000       | 215568000  | 169       | 817         |                 | 0                  | 23182      | 1      | 26     | 2       | 0    |                  |               |               |               |               |                |               |
| 2648  | ora_cjq0_orcl |                   | ora_cjq0_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 197876000     | 2019032000 | 38740     | 20810       |                 | 0                  | 24212      | 1      | 2648   | 1       | 0    |                  |               |               |               |               |                |               |
| 2753  | ora_qm02_orcl |                   | ora_qm02_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 18016000      | 2007792000 | 165       | 312         |                 | 0                  | 24219      | 1      | 2753   | 1       | 0    |                  |               |               |               |               |                |               |
| 2770  | ora_q003_orcl |                   | ora_q003_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 19396000      | 2008308000 | 169       | 220         |                 | 0                  | 24221      | 1      | 2770   | 1       | 0    |                  |               |               |               |               |                |               |
| 28502 | ora_q005_orcl |                   | ora_q005_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 22464000      | 2007792000 | 2         | 4           |                 | 0                  | 276912     | 1      | 28502  | 1       | 0    |                  |               |               |               |               |                |               |
| 28661 | bash          |                   | bash                                                                | S     |     |      | 0     | 0     | 0     | 0     | 0     | 0     | -1      | 0          | 1748000       | 11820000   | 6         | 1           |                 | 0                  | 277073     | 0      | 28661  | 1       | 0    |                  |               |               |               |               |                |               |
| 28802 | ora_w007_orcl |                   | ora_w007_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 24632000      | 2007804000 | 1         | 2           |                 | 0                  | 277196     | 1      | 28802  | 1       | 0    |                  |               |               |               |               |                |               |
| 28804 | ora_w001_orcl |                   | ora_w001_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 27044000      | 2008308000 | 2         | 3           |                 | 0                  | 277199     | 1      | 28804  | 1       | 0    |                  |               |               |               |               |                |               |
| 28814 | ora_w005_orcl |                   | ora_w005_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 27636000      | 2009332000 | 2         | 2           |                 | 0                  | 277223     | 1      | 28814  | 1       | 0    |                  |               |               |               |               |                |               |
| 28816 | ora_w000_orcl |                   | ora_w000_ORCL                                                       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 27764000      | 2009328000 | 2         | 2           |                 | 0                  | 277226     | 1      | 28816  | 1       | 0    |                  |               |               |               |               |                |               |
| 28937 | osqueryi      | /usr/bin/osqueryd | osqueryi                                                            | R     | /   | /    | 0     | 0     | 0     | 0     | 0     | 0     | 1       | 0          | 10880000      | 200624000  | 10        | 7           | 2433024         | 24576              | 277409     | 28661  | 28937  | 4       | 0    |                  | 4026532482    | 4026532480    | 4026532485    | 4026532483    | 4026531837     | 4026532481    |
| 2913  | tail          |                   | tail -f /opt/oracle/diag/rdbms/orcl/ORCL/trace/alert_ORCL.log       | S     |     |      | 54321 | 54321 | 54321 | 54321 | 54321 | 54321 | -1      | 0          | 116000        | 4400000    | 223       | 683         |                 | 0                  | 24252      | 1      | 1      | 1       | 0    |                  |               |               |               |               |                |               |
+-------+---------------+-------------------+---------------------------------------------------------------------+-------+-----+------+-------+-------+-------+-------+-------+-------+---------+------------+---------------+------------+-----------+-------------+-----------------+--------------------+------------+--------+--------+---------+------+------------------+---------------+---------------+---------------+---------------+----------------+---------------+
osquery>

osquery> select * from listening_ports;
+-------+-------+----------+--------+-----------+----+----------+----------------------------+---------------+
| pid   | port  | protocol | family | address   | fd | socket   | path                       | net_namespace |
+-------+-------+----------+--------+-----------+----+----------+----------------------------+---------------+
| -1    | 1521  | 6        | 2      | 0.0.0.0   | -1 | 352599   |                            | 0             |
| -1    | 33371 | 6        | 2      | 0.0.0.0   | -1 | 383090   |                            | 0             |
| -1    | 5500  | 6        | 2      | 0.0.0.0   | -1 | 384079   |                            | 0             |
| -1    | 38365 | 17       | 2      | 0.0.0.0   | -1 | 384521   |                            | 0             |
| -1    | 46666 | 17       | 2      | 127.0.0.1 | -1 | 383085   |                            | 0             |
| -1    | 42601 | 17       | 2      | 0.0.0.0   | -1 | 25442397 |                            | 0             |
| -1    | 34923 | 17       | 2      | 127.0.0.1 | -1 | 383100   |                            | 0             |
| -1    | 55504 | 17       | 2      | 127.0.0.1 | -1 | 382554   |                            | 0             |
| -1    | 37303 | 17       | 2      | 0.0.0.0   | -1 | 25443523 |                            | 0             |
| -1    | 0     | 0        | 1      |           | -1 | 0        | /var/tmp/.oracle/sEXTPROC1 | 0             |
| -1    | 0     | 0        | 1      |           | -1 | 0        | /var/tmp/.oracle/s#26.1    | 0             |
| -1    | 0     | 0        | 1      |           | -1 | 0        | /var/tmp/.oracle/s#26.2    | 0             |
| 28937 | 0     | 0        | 1      |           | 7  | 0        | /root/.osquery/shell.em    | 0             |
| -1    | 1521  | 6        | 2      | 0.0.0.0   | -1 | 352599   |                            | 4026532485    |
| -1    | 33371 | 6        | 2      | 0.0.0.0   | -1 | 383090   |                            | 4026532485    |
| -1    | 5500  | 6        | 2      | 0.0.0.0   | -1 | 384079   |                            | 4026532485    |
| -1    | 38365 | 17       | 2      | 0.0.0.0   | -1 | 384521   |                            | 4026532485    |
| -1    | 46666 | 17       | 2      | 127.0.0.1 | -1 | 383085   |                            | 4026532485    |
| -1    | 42601 | 17       | 2      | 0.0.0.0   | -1 | 25442397 |                            | 4026532485    |
| -1    | 34923 | 17       | 2      | 127.0.0.1 | -1 | 383100   |                            | 4026532485    |
| -1    | 55504 | 17       | 2      | 127.0.0.1 | -1 | 382554   |                            | 4026532485    |
| -1    | 37303 | 17       | 2      | 0.0.0.0   | -1 | 25443523 |                            | 4026532485    |
| -1    | 0     | 0        | 1      |           | -1 | 0        | /var/tmp/.oracle/sEXTPROC1 | 4026532485    |
| -1    | 0     | 0        | 1      |           | -1 | 0        | /var/tmp/.oracle/s#26.1    | 4026532485    |
| -1    | 0     | 0        | 1      |           | -1 | 0        | /var/tmp/.oracle/s#26.2    | 4026532485    |
| 28937 | 0     | 0        | 1      |           | 7  | 0        | /root/.osquery/shell.em    | 4026532485    |
+-------+-------+----------+--------+-----------+----+----------+----------------------------+---------------+
osquery> 








sql oracle clone pluggable database


[oracle@609a69bc0b21 ~]$ cd $ORACLE_BASE
[oracle@609a69bc0b21 oracle]$ ll
total 40
drwxr-x---. 3 oracle oinstall   18 Dec 23 13:11 admin
drwxr-x---. 2 oracle oinstall    6 Dec 23 13:11 audit
drwxr-x---. 4 oracle oinstall   34 Dec 23 13:22 cfgtoollogs
-rwxrwxrwx. 1 oracle dba      1148 Dec  8 00:58 checkDBStatus.sh
drwxr-xr-x. 2 oracle dba         6 Dec 23 08:52 checkpoints
-rwxrwxrwx. 1 oracle dba      2953 Dec  8 00:58 createDB.sh
-rwxrwxrwx. 1 oracle dba      9204 Dec  8 00:58 dbca.rsp.tmpl
drwxrwxr-x. 1 oracle dba        34 Dec 23 08:52 diag
drwxrwx---. 1 oracle dba        89 Dec 23 08:52 oraInventory
drwxr-xr-x. 4 oracle dba        34 Dec 23 13:29 oradata
drwxr-xr-x. 1 oracle dba        22 Dec 23 08:20 product
-rwxrwxrwx. 1 oracle dba      6526 Dec  8 00:58 runOracle.sh
-rwxrwxrwx. 1 oracle dba      1015 Dec  8 00:58 runUserScripts.sh
drwxr-xr-x. 1 oracle dba        34 Dec 23 08:20 scripts
-rwxrwxrwx. 1 oracle dba       758 Dec  8 00:58 setPassword.sh
-rwxrwxrwx. 1 oracle dba       678 Dec  8 00:58 startDB.sh
[oracle@609a69bc0b21 oracle]$ cd oradata
[oracle@609a69bc0b21 oradata]$ ll
total 0
drwxr-x---. 5 oracle oinstall 239 Dec 25 12:14 ORCL
drwxr-xr-x. 3 oracle oinstall  18 Dec 23 13:29 dbconfig
[oracle@609a69bc0b21 oradata]$ cd ORCL
[oracle@609a69bc0b21 ORCL]$ ll
total 2263508
drwxr-x---. 2 oracle oinstall       104 Dec 23 13:29 PDB1
drwxr-x---. 2 oracle oinstall       104 Dec 25 12:14 PDB2
-rw-r-----. 1 oracle oinstall  18726912 Dec 25 14:29 control01.ctl
-rw-r-----. 1 oracle oinstall  18726912 Dec 25 14:29 control02.ctl
drwxr-x---. 2 oracle oinstall       111 Dec 23 13:18 pdbseed
-rw-r-----. 1 oracle oinstall 209715712 Dec 25 00:05 redo01.log
-rw-r-----. 1 oracle oinstall 209715712 Dec 25 14:28 redo02.log
-rw-r-----. 1 oracle oinstall 209715712 Dec 24 22:06 redo03.log
-rw-r-----. 1 oracle oinstall 597696512 Dec 25 14:25 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 849354752 Dec 25 14:27 system01.dbf
-rw-r-----. 1 oracle oinstall 137371648 Dec 25 00:45 temp01.dbf
-rw-r-----. 1 oracle oinstall  73408512 Dec 25 14:27 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   5251072 Dec 25 00:10 users01.dbf
[oracle@609a69bc0b21 ORCL]$ pwd
/opt/oracle/oradata/ORCL
[oracle@609a69bc0b21 ORCL]$ sqlplus sys/ORACLE_PWD as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:30:43 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@ORCL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SYS@ORCL> show pdbs

CON_ID CON_NAME                       OPEN MODE  RESTRICTED
------------- ------------------------------ ---------- ----------
2 PDB$SEED                       READ ONLY  NO
3 PDB1                           READ WRITE NO
4 PDB2                           READ WRITE NO
SYS@ORCL> create pluggable database PDB3 from PDB1 FILE_NAME_CONVERT=('/opt/oracle/oradata/ORCL/PDB1','/opt/oracle/oradata/ORCL/PDB3');

Pluggable database created.

Elapsed: 00:00:09.26
SYS@ORCL> create pluggable database PDB4 from PDB1 FILE_NAME_CONVERT=('/opt/oracle/oradata/ORCL/PDB1','/opt/oracle/oradata/ORCL/PDB4');

Pluggable database created.

Elapsed: 00:00:10.38
SYS@ORCL> show pdbs

CON_ID CON_NAME                       OPEN MODE  RESTRICTED
------------- ------------------------------ ---------- ----------
2 PDB$SEED                       READ ONLY  NO
3 PDB1                           READ WRITE NO
4 PDB2                           READ WRITE NO
5 PDB3                           MOUNTED
6 PDB4                           MOUNTED
SYS@ORCL> alter pluggable database all open;

Pluggable database altered.

Elapsed: 00:00:25.74
SYS@ORCL> show pdbs

CON_ID CON_NAME                       OPEN MODE  RESTRICTED
------------- ------------------------------ ---------- ----------
2 PDB$SEED                       READ ONLY  NO
3 PDB1                           READ WRITE NO
4 PDB2                           READ WRITE NO
5 PDB3                           READ WRITE NO
6 PDB4                           READ WRITE NO
SYS@ORCL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ sqlplus sys/ORACLE_PWD@pdb3 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:37:14 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified

Enter user-name: [oracle@609a69bc0b21 ORCL]$
[oracle@609a69bc0b21 ORCL]$ find / -name tnsnames.ora -type f 2>/dev/null
/opt/oracle/product/12.2.0.1/dbhome_1/network/admin/samples/tnsnames.ora
/opt/oracle/oradata/dbconfig/ORCL/tnsnames.ora
[oracle@609a69bc0b21 ORCL]$ vim /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/tnsnames.ora

ORCL=localhost:1521/ORCL
PDB1=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB1)
)
)
PDB2=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB2)
)
)
PDB3=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB3)
)
)
PDB4=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB4)
)
)

[oracle@609a69bc0b21 ORCL]$ sqlplus sys/ORACLE_PWD@pdb3 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:40:02 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@pdb3> show con_name

CON_NAME
------------------------------
PDB3
SYS@pdb3> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ sqlplus sys/ORACLE_PWD@pdb4 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:40:30 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@pdb4> show con_name

CON_NAME
------------------------------
PDB4
SYS@pdb4> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ sqlplus aine/ORACLE_PWD@pdb3

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:41:10 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Tue Dec 25 2018 11:50:03 +00:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

AINE@pdb3> select * from warehouse_mst;

WAREHOUSE_CODE           SHIPPING_PERMISSION_OVER_DAYS
------------------------ -----------------------------
w_BS98                                              25
w_DIX4                                              28
w_C5MN                                              29

3 rows selected.

Elapsed: 00:00:00.07
AINE@pdb3> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ sqlplus aine/ORACLE_PWD@pdb4

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 14:41:38 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Tue Dec 25 2018 11:50:03 +00:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

AINE@pdb4> select * from warehouse_mst;

WAREHOUSE_CODE           SHIPPING_PERMISSION_OVER_DAYS
------------------------ -----------------------------
w_BS98                                              25
w_DIX4                                              28
w_C5MN                                              29

3 rows selected.

Elapsed: 00:00:00.06
AINE@pdb4> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@609a69bc0b21 ORCL]$ ll
total 2263564
drwxr-x---. 2 oracle oinstall       104 Dec 23 13:29 PDB1
drwxr-x---. 2 oracle oinstall       104 Dec 25 12:14 PDB2
drwxr-x---. 2 oracle oinstall       104 Dec 25 14:33 PDB3
drwxr-x---. 2 oracle oinstall       104 Dec 25 14:33 PDB4
-rw-r-----. 1 oracle oinstall  18726912 Dec 25 14:41 control01.ctl
-rw-r-----. 1 oracle oinstall  18726912 Dec 25 14:41 control02.ctl
drwxr-x---. 2 oracle oinstall       111 Dec 23 13:18 pdbseed
-rw-r-----. 1 oracle oinstall 209715712 Dec 25 00:05 redo01.log
-rw-r-----. 1 oracle oinstall 209715712 Dec 25 14:41 redo02.log
-rw-r-----. 1 oracle oinstall 209715712 Dec 24 22:06 redo03.log
-rw-r-----. 1 oracle oinstall 597696512 Dec 25 14:41 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 849354752 Dec 25 14:41 system01.dbf
-rw-r-----. 1 oracle oinstall 137371648 Dec 25 14:36 temp01.dbf
-rw-r-----. 1 oracle oinstall  73408512 Dec 25 14:41 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   5251072 Dec 25 00:10 users01.dbf
[oracle@609a69bc0b21 ORCL]$

sql oracle 12cr2 dblink

[oracle@b51cf2f967ec ~]$ find / -name tnsnames.ora -type f 2>/dev/null
/opt/oracle/product/12.2.0.1/dbhome_1/network/admin/samples/tnsnames.ora
/opt/oracle/oradata/dbconfig/ORCL/tnsnames.ora
[oracle@b51cf2f967ec ~]$ cd /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/
[oracle@b51cf2f967ec admin]$ pwd
/opt/oracle/product/12.2.0.1/dbhome_1/network/admin
[oracle@b51cf2f967ec admin]$ ll
total 4
lrwxrwxrwx. 1 oracle oinstall   46 Dec 24 14:00 listener.ora -> /opt/oracle/oradata/dbconfig/ORCL/listener.ora
drwxr-xr-x. 1 oracle dba         6 Dec 25 20:21 samples
-rw-r--r--. 1 oracle dba      1441 Aug 28  2015 shrept.lst
lrwxrwxrwx. 1 oracle oinstall   44 Dec 24 14:00 sqlnet.ora -> /opt/oracle/oradata/dbconfig/ORCL/sqlnet.ora
lrwxrwxrwx. 1 oracle oinstall   46 Dec 24 14:00 tnsnames.ora -> /opt/oracle/oradata/dbconfig/ORCL/tnsnames.ora
[oracle@b51cf2f967ec admin]$ vim tnsnames.ora


ORCL=localhost:1521/ORCL
PDB1=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB1)
)
)
RMTPDB2=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.108)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = PDB2)
)
)

[oracle@b51cf2f967ec admin]$ sqlplus sys/ORACLE_PWD@pdb1 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 23:18:50 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@pdb1> grant create database link to aine;

Grant succeeded.

Elapsed: 00:00:00.05
SYS@pdb1> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@b51cf2f967ec admin]$ sqlplus aine/ORACLE_PWD@pdb1

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 23:19:35 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Tue Dec 25 2018 22:39:49 +09:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

AINE@pdb1> CREATE DATABASE LINK testlink CONNECT TO aine IDENTIFIED BY ORACLE_PWD USING 'RMTPDB2';
CREATE DATABASE LINK testlink CONNECT TO aine IDENTIFIED BY ORACLE_PWD USING 'RMTPDB2'
*
ERROR at line 1:
ORA-02011: duplicate database link name

Elapsed: 00:00:00.01
AINE@pdb1> drop database link testlink;

Database link dropped.

Elapsed: 00:00:00.01
AINE@pdb1> CREATE DATABASE LINK testlink CONNECT TO aine IDENTIFIED BY ORACLE_PWD USING 'RMTPDB2';

Database link created.

Elapsed: 00:00:00.01
AINE@pdb1> select * from warehouse_mst@testlink;

WAREHOUSE_CODE           SHIPPING_PERMISSION_OVER_DAYS
------------------------ -----------------------------
w_BS98                                              25
w_DIX4                                              28
w_C5MN                                              29
w_9999                                              25

4 rows selected.

Elapsed: 00:00:00.35
AINE@pdb1>