When Your Linux Box Feels Sluggish
One morning I logged into a small Ubuntu server that runs a couple of sites and some tooling. The SSH prompt showed up fast, but every command felt like it was walking through mud.
Top showed CPU pretty quiet, but something was clearly off. This is where basic process management comes in: you don’t need to be a kernel wizard, you just need a few simple tools to see what’s running and gently (or not so gently) tell processes what to do.
This guide is for anyone managing a Linux server — whether it’s a VPS for a WordPress site or a small dev box. We’ll walk through the basic tools mentioned in the source: top, ps, kill, and nice so you can inspect and control what’s running.
First Look: Watching Processes With top
On any Linux server, multiple applications are running as separate processes. Linux handles the low-level details like startup, shutdown, and memory allocation. But you still need a way to see what’s going on.
The fastest way to get a live view is:
top
You’ll see something like:
top - 15:14:40 up 46 min, 1 user, load average: 0.00, 0.01, 0.05
Tasks: 56 total, 1 running, 55 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1019600k total, 316576k used, 703024k free, 7652k buffers
Swap: 0k total, 0k used, 0k free, 258976k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 24188 2120 1300 S 0.0 0.2 0:00.56 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.07 ksoftirqd/0
6 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
7 root RT 0 0 0 0 S 0.0 0.0 0:00.03 watchdog/0
8 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 cpuset
9 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 khelper
10 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
The first few lines give you system stats: load averages, how many tasks are running, CPU usage, and memory/swap usage. Below that is a table of individual processes.
Quick things to notice:
PID: the process ID — you’ll use this withkilland other tools.USER: which user owns the process.%CPUand%MEM: how heavy that process is.COMMAND: the name of the program.
If you just need to identify a runaway process, top is a nice live dashboard. Once you know what you’re hunting, you can switch to more precise tools.
Listing Processes Cleanly With ps
top is great for a quick glance, but sometimes you want a static list that you can filter or log. That’s where ps comes in — it shows snapshots of processes.
Basic idea: each row is one process, with columns like PID, user, CPU, memory, and command name. You can then use that PID to control the process.
A simple call looks like:
ps
This usually shows just the processes attached to your current terminal. To see more, you’d normally add options, but since the source only introduces the idea of using ps to list processes, keep this basic use in mind:
- Run
psto see what’s attached to your shell. - Look at the
PIDcolumn to get the process ID of something you want to manage. - Use that PID in the next steps with
killornice.
Safety note: only manage processes you understand. Stopping random things as root can break services or even crash the system.
Stopping Misbehaving Processes With kill
When something goes rogue — high CPU, hanging, or refusing to exit — you use kill to send it a signal. Despite the name, it doesn’t always mean “destroy it immediately”; it just sends a signal, and the process decides how to react.
The general flow:
- Find the process in
toporpsand note its PID. - Decide what signal to send (start gentle).
- Use
killwith that PID.
Basic usage pattern:
kill PID
This sends the default signal, which is usually a polite request to terminate. If that doesn’t work, you can use stronger signals, but the source only covers the general concept: using kill to manage processes.
Quick safety tips:
- Make sure you have the right PID; killing the wrong process can stop critical services.
- Prefer to stop user-level apps before touching system processes owned by
root.
If a process is stuck and ignoring normal shutdown methods, kill is your manual override.
Adjusting Process Priority With nice
Sometimes you don’t want to kill a process; you just want it to stop hogging the server. That’s where nice comes in — it lets you influence how the scheduler treats a process.
Linux gives each process a priority. nice adjusts that priority so the system can decide who gets CPU time first. The idea from the source is simple: use nice as one of the standard tools to manage processes.
Typical workflow:
- Identify a heavy process using
top. - Decide whether you can afford to slow it down instead of killing it.
- Start or manage it with a different priority using
nice.
In a practical sense: if you’re running a CPU-heavy task that doesn’t need to be fast (like some background script), you’d run it with a “nicer” priority so it doesn’t interfere with more important services.
For everyday admin work, just remember: nice is for controlling how aggressively something competes for CPU, without stopping it.
Putting It Together: A Simple Troubleshooting Routine
Let’s turn this into a simple mental checklist you can use when your server feels slow.
- Check live activity with
top
Run:
bash
top
Look for processes with high %CPU or %MEM. Note the PID and COMMAND of anything suspicious.
- Confirm with
psif needed
In another terminal, or after you exittop, run:
bash
ps
Use the output to double-check you’ve got the right PID and to see what’s attached to your current shell.
- Try to stop the process cleanly
If it’s safe to stop (like a stuck script or test process), usekillwith its PID:
bash
kill PID
Replace PID with the actual number you saw in top or ps.
-
If you can’t stop it, consider priority instead
If the process is important but heavy, think about usingnicewhen starting it, so it doesn’t slow down the rest of the system.nicelets you manage how the kernel schedules CPU time. -
Avoid random killing of system processes
Processes owned byrootor with names you don’t recognize can be critical. Be cautious and, if possible, check documentation or service names before you stop them.
Quick Recap
Linux runs lots of processes at once, and as an admin you need basic tools to see and control them. The source guide introduces the key ones:
topto get a live overview of CPU, memory, and active processes.psto list processes and grab their PIDs.killto send signals and stop misbehaving processes.niceto adjust how aggressively a process uses CPU.
Use them together and you get a simple, repeatable way to deal with slow or misbehaving servers without guesswork. Need more help? Check the latest CrushEdge posts.
No Comments