Identify resource-hungry processes, validate what is actually running, and take controlled action to stabilize the system. Use standard tools to inspect, terminate, and reprioritize workloads, and manage background jobs safely.
A Linux host is running slowly and user sessions feel laggy. You need to identify a process that is consuming excessive CPU, confirm system state using both snapshot and live views, terminate the runaway workload safely, and ensure you can manage shell jobs and scheduling priority without making the system worse.
This is the workflow you use before escalating to “the server is slow” tickets or guessing. You validate what is running, prove which process is responsible, and take the smallest safe corrective action.
nice.
ps aux and targeted output filtering with head.
top to confirm CPU-heavy workloads in real time.
kill (SIGTERM) for controlled shutdown.
jobs and fg.
nice to reduce impact on system responsiveness.
ps aux | head -n 5
ps aux
provides a wide process listing including %CPU and %MEM. Piping into
head
gives you a quick baseline view without flooding the terminal. This is useful for confirming the machine is not “empty”
and spotting obvious outliers.
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 167936 1104 ? Ss Jul18 0:02 /sbin/init
root 402 0.1 0.3 98720 3128 ? Ss 08:01 0:00 /lib/systemd/systemd-journald
root 711 0.0 0.2 72960 2140 ? Ss 08:01 0:00 /usr/sbin/cron -f
lab 1357 25.3 4.1 248112 42280 ? Rl 12:45 1:37 /usr/bin/python3 script.py
top
top
gives a real-time view of CPU, memory, and per-process usage. Use this to confirm that the same PID is consistently consuming CPU,
not just spiking briefly. This reduces the chance you terminate the wrong process.
top - 12:48:33 up 2:47, 1 user, load average: 2.23, 2.10, 1.76
Tasks: 188 total, 2 running, 186 sleeping, 0 stopped, 0 zombie
%Cpu(s): 38.6 us, 3.1 sy, 0.0 ni, 57.9 id, 0.1 wa, 0.0 hi, 0.3 si, 0.0 st
MiB Mem : 7860.0 total, 1180.5 free, 2387.2 used, 4292.3 buff/cache
MiB Swap: 2048.0 total, 2048.0 free, 0.0 used. 4970.1 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1357 lab 20 0 248.1m 41.3m 5.1m R 98.3 0.5 1:39.21 python3
(Press 'q' to quit top)
kill 1357
kill
without a signal defaults to SIGTERM, which requests a graceful shutdown. This is a safe first move because it allows the process
to exit cleanly. If a process ignores SIGTERM, you can escalate, but start here.
bash: sent SIGTERM to PID 1357
jobs
Job control is shell-scoped. jobs shows what you have running in the background in your current session.
This matters when you need to recover control of a long-running script, pause work, or bring a task back into focus.
[1]- Running ./bigjob.sh &
fg %1
fg
resumes a background job in the foreground so you can interact with it directly. If there are multiple jobs, targeting by job spec
(like %1) prevents you from foregrounding the wrong task.
./bigjob.sh
(running in foreground; press Ctrl+Z to background)
nice -n 10 ./backup.sh
nice
runs a command with an adjusted niceness value. Higher niceness generally means lower CPU scheduling priority, which helps keep the system
responsive while background work runs. This is a common operator move when you need work to complete without impacting interactive users.
started './backup.sh' with nice value +10 (lower priority)
ps aux
: Snapshot of all processes with user, CPU, memory, and full command details.
head -n <N>
: Prints only the first N lines of output to keep listings readable.
top
: Interactive, live view of system load and per-process CPU/memory usage.
kill <PID>
: Sends a signal to a process (defaults to SIGTERM) for controlled termination.
jobs
: Lists jobs started from the current shell session.
fg
: Brings a background job to the foreground (use fg %<job> to target).
nice -n <value> <command>
: Starts a command with an adjusted niceness (higher value usually means lower priority).