Operations 6 min read

Essential Linux Commands for Database Monitoring and System Management

A concise collection of Linux command‑line snippets helps you query Oracle client IPs, kill specific processes, count connections, summarize traffic, find large files, measure copy time, and monitor CPU and memory usage, all useful for DB and system administrators.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Essential Linux Commands for Database Monitoring and System Management

Querying Oracle client connections

Use netstat combined with grep and awk to list client IPs that are connected to a specific Oracle SID or listening on port 1521:

netstat -anpT | grep oracleSID | awk '{print $5}' | grep -o -E '1.*:' | awk -F ':' '{print $1}' | sort
netstat -anpT | grep 1521 | awk '{print $5}' | grep -o -E '1.*:' | awk -F ':' '{print $1}' | sort

Killing unwanted processes

Terminate processes that are connected to a given Oracle SID:

kill -9 `ps -ef | grep oracleSID | grep LOCAL=NO | grep -v grep | awk '{print $2}'`

Or kill all processes owned by a specific user (e.g., userA):

pkill -9 -u userA

Counting connections and processes

Number of processes listening on port 1521: netstat -pan | grep 1521 | wc -l Number of processes coming from a particular host (e.g., 192.168.21.15):

netstat -pan | grep 192.168.21.15 | wc -l

Summarizing client IP traffic on port 1521

Two equivalent pipelines produce a ranked list of client IPs and their connection counts:

netstat -apnT | grep 1521 | awk '{print $5}' | sort -u | grep -v 1521 | grep -v '*' | awk -F ':' '{print $4}' | uniq -c | sort -nr
netstat -anpT | grep 1521 | awk '{print $5}' | grep -o -E '1.*:' | awk -F ':' '{print $1}' | sort | uniq -c | sort -nr

File system size checks

Show the top 10 largest files or directories in the current folder: du -s * | sort -nr | head Calculate total size of log files created on a specific date (example for 2016‑05‑09):

ls --full-time `find ./* -name "log_*.bak"` | grep '2016-05-09' | awk '{print $9}' | xargs du -ck

Delete files older than a given number of days (e.g., 150 days) or matching a pattern:

find /mitac/mds/arch/ -ctime +150 -exec rm -rf {} \;
find /mitac/mds/arch/ -name '*836701255.dbf' -ctime +150 -exec rm -rf {} \;

Process resource usage

Top 10 CPU‑intensive processes:

ps auxw | head -1; ps auxw | sort -rn -k3 | head -10

Top 10 memory‑intensive processes:

ps auxw | head -1; ps auxw | sort -rn -k4 | head -10

Top 10 processes using the most virtual memory:

ps auxw | head -1; ps auxw | sort -rn -k5 | head -10

In top, press 1 to view per‑CPU stats, Shift+P to sort by CPU, and Shift+M to sort by memory.

Useful one‑liners

Replace all occurrences of 1 with 2 in vi: :%s/1/2/g Display I/O statistics every second for three intervals, with values in MB: iostat -d -x -m 1 3 Measure how long it takes to copy a file: time cp file1 /u01/ Show CPU usage between 07:00 and 10:00 using sar:

sar -s 07:00:00 -e 10:00:00
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

monitoringperformancedatabaseSysadmincommands
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.