Page 1 of 1

🐧 Essential Linux Commands for Oracle DBAs

Posted: Fri Feb 07, 2025 4:28 pm
by valgonzalez
As an Oracle DBA, mastering Linux commands is just as important as knowing SQL and PL/SQL. Your database runs on Linux, and efficient command-line skills can save time, improve troubleshooting, and enhance database performance.

Here are some must-know Linux commands every DBA should use daily:
📌 1️⃣ Checking System Resources
Monitor CPU, memory, and disk usage to ensure optimal database performance.
✅ Check CPU Usage:

top
or
mpstat 1 5

✅ Check Memory Usage:
free -m

✅ Check Disk Space Usage:

df -h

📌 2️⃣ Managing Oracle Processes
Find and manage running Oracle database processes.
✅ List all Oracle processes:

ps -ef | grep pmon
✅ Kill a stuck process (use with caution!):

kill -9 <PID>

📌 3️⃣ Checking Database Listener Status
Ensure that the Oracle Listener is running.
✅ Check listener status:

lsnrctl status

✅ Start the listener:

lsnrctl start

✅ Stop the listener:

lsnrctl stop

📌 4️⃣ Navigating and Managing Files
Find logs, manage backups, and monitor database files.
✅ Find alert logs:

find /u01/app/oracle/diag/rdbms/ -name alert_*.log

✅ View last 100 lines of the alert log in real-time:

tail -100f /u01/app/oracle/diag/rdbms/DB_NAME/trace/alert_DB_NAME.log
✅ Search logs for errors:

grep -i "ORA-" alert_DB_NAME.log

📌 5️⃣ Managing Oracle Services
Start, stop, and check the database instance.
✅ Check database status:

sqlplus / as sysdba

SELECT status FROM v$instance;
✅ Start the database:

sqlplus / as sysdba
sql

STARTUP;

✅ Shutdown the database:
sql

SHUTDOWN IMMEDIATE;

📌 6️⃣ Monitoring Active Sessions & Blocking Locks
✅ Check active database sessions:
bash
CopyEdit
sqlplus / as sysdba
sql

SELECT username, sid, serial#, status FROM v$session WHERE status='ACTIVE';

✅ Check for blocking locks:
sql


SELECT blocking_session, sid, serial#, wait_class FROM v$session WHERE blocking_session IS NOT NULL;

📌 7️⃣ Scheduling Jobs with Cron
Automate backups, monitoring scripts, and routine maintenance tasks.
✅ Edit the cron job list:

crontab -e

✅ Schedule a backup job to run daily at midnight:
bash
CopyEdit
0 0 * * * /u01/app/oracle/scripts/backup.sh

✅ View scheduled cron jobs:

crontab -l