🐧 Essential Linux Commands for Oracle DBAs
Posted: Fri Feb 07, 2025 4:28 pm
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:
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
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>
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
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
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;
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;
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
Here are some must-know Linux commands every DBA should use daily:
Monitor CPU, memory, and disk usage to ensure optimal database performance.
top
or
mpstat 1 5
free -m
df -h
Find and manage running Oracle database processes.
ps -ef | grep pmon
kill -9 <PID>
Ensure that the Oracle Listener is running.
lsnrctl status
lsnrctl start
lsnrctl stop
Find logs, manage backups, and monitor database files.
find /u01/app/oracle/diag/rdbms/ -name alert_*.log
tail -100f /u01/app/oracle/diag/rdbms/DB_NAME/trace/alert_DB_NAME.log
grep -i "ORA-" alert_DB_NAME.log
Start, stop, and check the database instance.
sqlplus / as sysdba
SELECT status FROM v$instance;
sqlplus / as sysdba
sql
STARTUP;
sql
SHUTDOWN IMMEDIATE;
bash
CopyEdit
sqlplus / as sysdba
sql
SELECT username, sid, serial#, status FROM v$session WHERE status='ACTIVE';
sql
SELECT blocking_session, sid, serial#, wait_class FROM v$session WHERE blocking_session IS NOT NULL;
Automate backups, monitoring scripts, and routine maintenance tasks.
crontab -e
bash
CopyEdit
0 0 * * * /u01/app/oracle/scripts/backup.sh
crontab -l