Linux – Install rlwrap from epel (Extra Packages for Enterprise Linux )

What is rlwrap?

rlwrap (readline wrapper) is a utility that provides command history and editing of commands for programs such as sqlplus, rman.

 

Red Hat Linux 7 and OEL 7

Execute the commands as root.

Get Extended Packages for Enterprise Linux (EPEL)

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Install EPEL

rpm -ivh epel-release-latest-7.noarch.rpm

Install rlwrap

yum install rlwrap

 

Red Hat Linux 6 and OEL 6

Execute the commands as root.

Get Extended Packages for Enterprise Linux (EPEL)

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

Install EPEL

rpm -ivh epel-release-latest-6.noarch.rpm

Install rlwrap

yum install rlwrap

Locking Problems (Red Hat Linux 7)

Connect as root

Stop packagekitd service if it is running (to stop locks on yum)

systemctl disable packagekitd.service

The processes:

root     13447     1  0 Jan02 ?        00:07:13 /usr/libexec/packagekitd
root     17522 13447 33 10:46 ?        00:01:23 /usr/bin/python /usr/share/PackageKit/helpers/yum/yumBackend.py get-updates none

hold a lock on yum – had to kill 13447

 

Example Session (with Oracle Enterprise Linux 6)

[root@oel6]# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
--2018-10-24 06:07:00--  https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
Resolving dl.fedoraproject.org... 209.132.181.25, 209.132.181.24, 209.132.181.23
Connecting to dl.fedoraproject.org|209.132.181.25|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14540 (14K) [application/x-rpm]
Saving to: “epel-release-latest-6.noarch.rpm”

100%[=================================================================================================================================>] 14,540      88.7K/s   in 0.2s

2018-10-24 06:07:01 (88.7 KB/s) - “epel-release-latest-6.noarch.rpm” saved [14540/14540]

[root@oel6]# rpm -ivh epel-release-latest-6.noarch.rpm
warning: epel-release-latest-6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
[root@oel6 network-scripts]# yum install rlwrap
epel/metalink                                                                                                                                       |  26 kB     00:00
epel                                                                                                                                                | 3.2 kB     00:00
epel/primary                                                                                                                                        | 3.2 MB     00:02
epel                                                                                                                                                           12516/12516
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package rlwrap.x86_64 0:0.42-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================
 Package                                 Arch                                    Version                                       Repository                             Size
===========================================================================================================================================================================
Installing:
 rlwrap                                  x86_64                                  0.42-1.el6                                    epel                                   93 k

Transaction Summary
===========================================================================================================================================================================
Install       1 Package(s)

Total download size: 93 k
Installed size: 203 k
Is this ok [y/N]: y
Downloading Packages:
rlwrap-0.42-1.el6.x86_64.rpm                                                                                                                        |  93 kB     00:00
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Importing GPG key 0x0608B895:
 Userid : EPEL (6) <epel@fedoraproject.org>
 Package: epel-release-6-8.noarch (installed)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : rlwrap-0.42-1.el6.x86_64                                                                                                                                1/1
  Verifying  : rlwrap-0.42-1.el6.x86_64                                                                                                                                1/1

Installed:
  rlwrap.x86_64 0:0.42-1.el6

Complete!
[root@oel6]#

 

Linux – grep

Display filenames only:

grep -l dba *.trc          (lowercase letter l as switch)

Display filenames and matches

grep -H dba *.trc

Recursively find files and executes grep on each:

find . -name “*.trc*” -exec -l dba {} \;               — space required between closing brace and backslash

 

Display the SQL statement that a Linux Process is Executing

-- get the process id from Linux (use top or ps)
-- the process id is spid in v$process
select sql_id from v$session where paddr in (select addr from v$process where spid in (4567))

-- put the sql_id from v$session into v$sqlarea/v$sql_text/v$sql
select sql_text from v$sqlarea where sql_id = 'ap3qms77rt67k'
-- this will display the sql that the process is executing

-- In one query
select sql_text
from v$sqlarea
where sql_id = 
(select sql_id from 
 v$session where paddr in 
 (select addr from v$process where spid = 1820)
);