Identify CPU- and memory-intensive processes and kill and manage processes

4. Operate Running Systems

πŸ“˜Red Hat Certified System Administrator (RHCSA – EX200)


This topic is very important for the RHCSA exam. You must know how to:

  • View running processes
  • Identify high CPU usage
  • Identify high memory usage
  • Kill unwanted or problematic processes
  • Manage processes (foreground, background, priorities)

Everything in this section is done using command-line tools.


1. Understanding What a Process Is

A process is a running program.

Examples in an IT environment:

  • A web server running (httpd)
  • A database service running (mysqld)
  • A backup job running
  • A script running in the background

Each running program:

  • Has a PID (Process ID)
  • Uses CPU
  • Uses Memory (RAM)
  • Belongs to a user

2. Viewing Running Processes

2.1 Using ps Command

The ps command shows process information.

Basic usage:

ps aux

Important columns:

  • USER – Who started the process
  • PID – Process ID
  • %CPU – CPU usage
  • %MEM – Memory usage
  • COMMAND – Program name

Show processes in full format:

ps -ef

Filter a specific process:

ps aux | grep httpd

You must know how to find a process by name using grep.


3. Real-Time Process Monitoring

3.1 Using top

top

This shows real-time system activity.

Important areas in top:

Top Section:

  • Load average
  • CPU usage
  • Total memory
  • Used memory
  • Free memory

Process Section:

Columns:

  • PID
  • USER
  • %CPU
  • %MEM
  • COMMAND

Inside top, useful keys:

  • P β†’ Sort by CPU usage
  • M β†’ Sort by memory usage
  • k β†’ Kill a process
  • q β†’ Quit

You must know how to:

  • Identify high CPU process
  • Identify high memory process
  • Kill process from inside top

3.2 Using htop (if available)

htop is not required but may exist. It is more visual than top.


4. Identifying CPU-Intensive Processes

CPU-intensive processes:

  • Backup compression
  • Database queries
  • Infinite loops in scripts
  • Misconfigured applications

To identify:

Method 1:

top

Sort by CPU using P

Method 2:

ps aux --sort=-%cpu

This shows highest CPU at the top.


5. Identifying Memory-Intensive Processes

Memory-intensive processes:

  • Java applications
  • Databases
  • Virtual machines
  • Memory leak in applications

Method 1:

top

Sort using M

Method 2:

ps aux --sort=-%mem

6. Understanding Process States

Process states include:

  • R – Running
  • S – Sleeping
  • D – Uninterruptible sleep
  • T – Stopped
  • Z – Zombie

You may see these in ps output.

Zombie processes:

  • Finished but not cleaned up
  • Usually fixed by restarting parent process

7. Killing and Managing Processes

This is a very important RHCSA skill.

7.1 Using kill

Syntax:

kill PID

Example:

kill 1234

This sends default signal SIGTERM (15).

What is SIGTERM?

  • Politely asks process to stop
  • Allows cleanup

7.2 Force Kill (If Normal Kill Does Not Work)

kill -9 PID

This sends SIGKILL (9).

  • Immediate stop
  • No cleanup
  • Use only if necessary

Exam tip:
Always try normal kill first before using -9.


7.3 Kill by Name – pkill

pkill httpd

Kills all processes with that name.


7.4 Kill by Name – killall

killall httpd

Kills all processes matching name.


8. Process Priorities (Nice and Renice)

Linux uses priority levels.

Lower nice value β†’ Higher priority
Higher nice value β†’ Lower priority

Nice range:

-20 (highest priority)
to
19 (lowest priority)

Default nice value = 0


8.1 Start Process with Nice Value

nice -n 10 command

Example:

nice -n 10 tar -czf backup.tar.gz /data

This lowers priority so it does not affect system performance.


8.2 Change Priority of Running Process

renice 5 PID

Example:

renice 10 1234

Only root can set negative nice values.


9. Background and Foreground Processes

9.1 Run in Background

Add & at the end:

sleep 100 &

Check jobs:

jobs

9.2 Bring Job to Foreground

fg %1

9.3 Stop a Process Temporarily

Press:

Ctrl + Z

Then:

bg

To continue in background.


10. Using free to Check Memory

free -h

Shows:

  • Total memory
  • Used memory
  • Free memory
  • Swap usage

Important for identifying memory problems.


11. Using uptime

uptime

Shows:

  • How long system running
  • Load average

Load average:

  • 1 minute
  • 5 minutes
  • 15 minutes

High load average may indicate CPU problem.


12. Practical Exam Skills You Must Know

For RHCSA, you must be able to:

βœ… Use ps to find a process
βœ… Use top to identify CPU usage
βœ… Use top to identify memory usage
βœ… Kill a process using PID
βœ… Use kill -9 when necessary
βœ… Use pkill or killall
βœ… Start process in background
βœ… Use jobs, fg, bg
βœ… Change process priority using nice
βœ… Modify priority using renice


13. Common IT Scenarios in Real Environments

Scenario 1 – Web Server Overloading CPU

  • Use top
  • Identify process (e.g., httpd)
  • Check PID
  • Restart service or kill process

Scenario 2 – Backup Job Using Too Much CPU

  • Identify process
  • Use renice to reduce priority
  • Do NOT kill if it is critical

Scenario 3 – Application Hung

  • Try: kill PID
  • If not working: kill -9 PID

14. Important Exam Tips

  • Always check process using ps or top
  • Do not randomly kill system processes
  • Try normal kill before force kill
  • Remember nice range (-20 to 19)
  • Practice using top sorting
  • Know how to background and foreground jobs
  • Be comfortable using only terminal (no GUI)

Final Summary

For RHCSA EX200 Section 4.4, you must fully understand:

  • What processes are
  • How to monitor CPU and memory
  • How to identify heavy processes
  • How to kill processes safely
  • How to adjust priorities
  • How to manage foreground/background jobs

If you master these commands:

ps
top
kill
kill -9
pkill
killall
nice
renice
jobs
fg
bg
free
uptime

You will be fully prepared for this objective in the RHCSA exam.

Buy Me a Coffee