Frequently Used Linux Commands for System & Oracle DBA Operations

As an Oracle DBA or Linux system administrator, we frequently perform operational tasks such as checking port usage, cleaning old files, troubleshooting network issues, and monitoring disk space.

This post documents commonly used Linux commands that are extremely helpful in day-to-day DBA activities, along with examples for better understanding.

1. How to Check Port Availability


Using lsof

This command identifies which process is using a specific TCP port.

lsof -i tcp:8031

Sample Output:

java 24567 oracle 123u IPv4 987654 TCP *:8031 (LISTEN)

Using netstat

This command displays active network connections and listening ports.

netstat -putan | grep 8031

netstat -an |grep <Port_Number>

Sample Output:

tcp 0 0 0.0.0.0:8031 0.0.0.0:* LISTEN 24567/java

2. Renaming Multiple Characters in a File

This method is useful when you want to replace a specific word throughout a file.

Syntax

perl -pi -e 's/OLD_VALUE/NEW_VALUE/g' <FILE_NAME>

Example

perl -pi -e 's/DEV/TEST/g' initTEST.ora

This command replaces all occurrences of DEV with TEST in the file.


3. Checking Connection Issues


DNS Resolution Check

Used to verify hostname-to-IP resolution.

nslookup dbserver.example.com

Sample Output:

Name: dbserver.example.com Address: 10.x.x.x

Oracle Listener Connectivity Check

tnsping ORCL

Sample Output:

OK (20 msec)

4. Searching Multiple Parameters in a Single Command

Useful for validating applied Oracle patches.

$ORACLE_HOME/OPatch/opatch lsinventory | egrep -w 'PATCH1|PATCH2|PATCH3' | grep "applied on"

Sample Output:

Patch PATCH1 applied on Tue Jan 02 10:15:30 IST 2025

5. Tar Command (Archive and Extract Files)


Create Archive

tar -cvzf software_backup.tar.gz software_dir/

Sample Output:

software_dir/ software_dir/file1 software_dir/file2

Extract Archive

tar -xvzf software_backup.tar.gz

6. Nohup Command

The nohup command allows a process to continue running even after you log out.

nohup tar -cvf software_backup.tar.gz software_dir/ &

Sample Output:

[1] 23456 nohup: ignoring input and appending output to nohup.out

Monitor Running Jobs

jobs -l

7. Deleting Old or Large Files


List Files Older Than 5 Days

find . -type f -mtime +5

Delete Files Older Than 5 Days

find . -type f -mtime +5 -exec rm -vf {} \;

Sample Output:

removed './old_log_01.log' removed './old_log_02.log'

8. Moving Old Files to Another Directory


List Files Older Than 4 Days

find . -type f -mtime +4

Move Files

find . -type f -mtime +4 -exec mv {} /backup/archive_dir/ \;

9. Find Top Disk Space Consuming Files

du -sh * | sort -rh | head -n 5

Sample Output:

133G request_01.req 104G request_02.req 37G request_03.req

10. Network Connectivity Testing


Using Netcat

nc -zv 10.x.x.x 1521

Sample Output:

Ncat: No route to host

Using Telnet

telnet 10.x.x.x 1521

Using Curl

curl -v telnet://10.x.x.x:1521

11. Advanced find Command Examples


Find Files Larger Than 1GB

find . -type f -size +1G

Delete Log Files Older Than 7 Days

find . -name "*.log" -mtime +7 -exec rm -f {} \;

Find Files Modified Today

find . -type f -mtime 0

12. SCP Command (Secure Copy)


Copy File to Remote Server

scp file_name user@remote_host:/remote/path/

Copy Directory Recursively

scp -r source_dir user@remote_host:/remote/path/

Copy File From Remote Server

scp user@remote_host:/remote/path/file_name /local/path/

Releted Posts:

Comments

Popular posts from this blog

How to troubleshoot long running concurrent request in R12.2

How to run Gather Schema Statistics in R12.2

JSP Compilation in R12.2