Loading date…
Gear We Use:
SATURDAY
00 : 00 : 00
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Linux htop Command Cheat Sheet: Spot Hidden Threats in Seconds

Linux htop terminal screen showing color-coded process list and tree view used for threat hunting and incident response

Linux htop Command Cheat Sheet: How SOC Analysts Use It for Process Monitoring and Threat Hunting

Last verified: October 15, 2026. Some htop options and shortcuts vary by version, so check htop --help on your own system.

It is 2:40 a.m. and a monitoring alert says a production Linux web server has been pinned at 98% CPU for an hour. Nobody deployed anything. The first question in any Linux incident response is simple: what is actually running on this box? That is where htop earns its place on a responder's toolbelt. It will not replace endpoint detection and response (EDR) tooling, but within seconds it shows what is consuming resources, who owns it, and what spawned it.

This guide turns a standard htop cheat sheet into a practitioner's workflow. You get the commands, the shortcuts, and the defensive habits that separate quick triage from an accidental evidence-destroying panic.

Table of Contents

Why htop Matters in Security Work

The classic top command gives you a flat, scrolling list. htop adds color, a tree view, mouse support, and in-place sorting and filtering, which makes patterns easier to see. When you are scanning a compromised or suspect host, those patterns matter. A web server worker spawning a shell, a single process using all your cores, or a binary running under an unfamiliar user all stand out visually.

One limitation to keep in mind: htop reads from /proc. Sophisticated malware, such as rootkits, can hide from user-space tools. Treat htop as a fast first look, not a verdict. A clean htop screen does not prove a clean system.

Installing htop on Major Linux Distributions

htop is available in the default repositories of most distributions. Use your package manager:

# Debian / Ubuntu
sudo apt update && sudo apt install htop

# Fedora
sudo dnf install htop

# Arch Linux
sudo pacman -S htop

# Alpine Linux
sudo apk add htop

Confirm the install and check which version you have, since features differ between releases:

htop --version
htop --help

Expected output is a version string and a list of the options your build supports. On locked-down servers, install tools only through your approved change process, and prefer your distribution's official repositories.

Startup Options Worth Knowing

You can launch htop with flags that narrow the view immediately. This is useful when a host is busy and you already have a lead.

# Start the interactive monitor
htop

# Refresh every 2 seconds (the value is in tenths of a second)
htop -d 20

# Watch one process by PID
htop -p 1234

# Watch several PIDs
htop -p 1234,5678

# Show only one user's processes
htop -u username

# Show only your own processes
htop -u "$USER"

# Disable mouse support (version-dependent)
htop --no-mouse

What they do and when to use them: -d 20 slows the refresh to two seconds, which makes it easier to read fast-changing processes during triage. -p is the right choice once you have a suspect PID from an alert or a log. -u helps when an account is under investigation, for example a service account that should never be running interactive tools. The expected output in each case is the same interactive screen, filtered to match.

A note on -K: some cheat sheets list htop -K as a way to show kernel threads. That flag is not consistently documented across versions. Inside htop, pressing K toggles kernel thread visibility and H toggles user threads, so rely on those or on your version's setup screen.

Interactive Shortcuts Cheat Sheet

Most of the investigative value lives inside the interface. These are the keys SOC analysts reach for most. Behavior can differ slightly by version.

KeyActionSecurity use
F2Setup screenAdd columns, adjust meters and colors
F3SearchJump to a process or command string
F4FilterShow only matching processes (a filter, not a reverse search)
F5Tree viewReveal parent-child relationships
F6Sort by columnRank by CPU%, MEM%, or RES
uFilter by userIsolate a suspect or service account
lList open filesSee files and sockets a process holds (needs lsof)
eShow environmentInspect launch context (may expose secrets)
F9Send signalContain a process (see the warning below)
F10 / qQuitExit the viewer

Navigate the list with the Up and Down arrow keys. If mouse support is enabled, you can also click a column header to sort or click a function button at the bottom of the screen.

Linux Threat Hunting with htop: What Suspicious Looks Like

Back to the 2:40 a.m. server. Here is how an analyst might work through it, using htop to form a hypothesis rather than to confirm a guess.

Step 1: Sort by CPU, then by memory

Press F6 and choose CPU%. Sustained, near-total CPU use by a single unfamiliar process is a classic sign of unauthorized cryptocurrency mining, though a runaway legitimate job can look identical. Then sort by MEM% to catch memory-hungry processes that might be staging or handling data.

Step 2: Switch to tree view

Press F5. Parent-child relationships often tell the story better than resource numbers. Ask whether each branch makes sense. A database daemon has no business spawning a shell. A web server worker launching a scripting interpreter deserves scrutiny, especially if the web application has a known vulnerability. Tree view does not prove malice, but it narrows where to look.

Step 3: Check the owner

Press u and review which accounts own the suspect processes. Unexpected ownership, such as a service account running something interactive, is worth documenting and escalating.

Step 4: Read the command column

Widen the view if needed and look at the full command line. Red flags include binaries running from world-writable locations like /tmp or /dev/shm, names that imitate system processes with small spelling differences, and long encoded arguments. Each is a lead, not a conclusion.

Step 5: Confirm with other tools

Select the process and press l to see open files and network sockets if lsof is installed. You can also verify what binary is really running:

ls -l /proc/1234/exe

Replace 1234 with the PID in question. This shows the path of the executable. If the output ends with "(deleted)", the file was removed from disk after launch. That is a common pattern worth escalating, though some legitimate software updates produce it too. Expect either a symlink to a normal path or the deleted marker.

Capturing Evidence Before You Act

Responders under pressure often kill the suspicious process first. That can destroy volatile evidence and tip off an attacker. Capture a snapshot first, using the text tools alongside htop:

ps -eo pid,ppid,user,%cpu,%mem,comm --sort=-%cpu | head -n 15

This prints the top 15 processes by CPU in a clean text table, with parent PIDs so you can reconstruct lineage later.

free -h
uptime

free -h shows total, used, and available memory plus swap. uptime shows how long the system has been up and the 1-, 5-, and 15-minute load averages. Together they give you context: whether load is climbing, steady, or recovering.

ps aux > process-report.txt
chmod 600 process-report.txt

This saves a full process listing for the case file. The chmod step matters because command lines frequently contain passwords, tokens, or API keys. Store the report in your approved evidence location, not on the suspect host's shared directories, and follow your organization's chain-of-custody procedures. The same caution applies to the environment view (e) in htop: environment variables can hold secrets, so avoid screen-sharing or pasting that output into tickets.

Using Signals Safely

htop lets you select a process, press F9, and choose a signal. Two matter most:

  • SIGTERM asks the process to shut down cleanly. It is the safer first choice for a legitimate service that has gone haywire.
  • SIGKILL terminates the process immediately with no cleanup.

Warning: killing a process on a production or suspected-compromised system can cause outages, corrupt data, or destroy forensic evidence. Do not terminate anything until you have captured your snapshot, confirmed what the process is, and, in a regulated or enterprise environment, followed your incident response plan. If the process is malicious, killing it is rarely enough on its own. Persistence mechanisms may restart it, and the initial access path is still open.

Prevention and Visibility Hardening

htop is a reactive tool. These habits reduce how often you need it in an emergency:

  • Alert on resource anomalies. Pair host monitoring with alerts for sustained CPU and memory spikes so you find problems before users do.
  • Deploy EDR on Linux servers. Many organizations still cover Windows endpoints well and leave Linux thinly monitored. Process creation telemetry is far more reliable than catching something live in htop.
  • Restrict execution from temp directories. Mounting /tmp with the noexec option, where your workloads allow it, makes dropped binaries harder to run.
  • Limit process visibility between users. Mounting /proc with the hidepid option reduces what unprivileged users can see about other users' processes. Test this carefully, since some monitoring agents depend on that visibility.
  • Patch internet-facing services. Many Linux compromises begin with a vulnerable web application, which is why a worker process spawning a shell is such an important signal.
  • Centralize logs. Local process views vanish on reboot. Forward authentication and audit logs off-host.

These measures reduce risk but do not guarantee protection against every attack.

Expert Tips

  • Save your preferred column layout in the F2 setup screen so every triage session starts the same way.
  • Run htop with enough privileges to see all processes. As a regular user you may miss details on processes owned by others.
  • Establish a baseline. Know what normal looks like on your critical servers, because "suspicious" is relative to normal.
  • Treat short-lived processes with suspicion: htop refreshes on an interval, so quick-running tasks can be missed entirely. Audit logging catches what polling misses.
  • Document timestamps, PIDs, and parent PIDs as you go. Notes written during triage are far more reliable than memory afterward.

FAQ

What is the difference between htop and top?

Both show running processes, but htop offers a color interface, tree view, mouse support, and interactive filtering and signaling, which makes triage faster.

Can htop detect malware?

Not by itself. It shows process behavior, which can hint at malicious activity such as unexplained CPU use or strange process lineage, but it has no signature or behavior engine. Use it alongside EDR and log analysis.

How do I filter htop by user?

Start it with htop -u username, or press u inside the interface and select an account.

How do I search versus filter in htop?

F3 searches and jumps between matches. F4 filters the list so only matching processes are shown.

Is it safe to kill a process from htop?

It can be, but on production or suspected-compromised systems, capture evidence first and follow your incident response process. SIGTERM is gentler than SIGKILL.

Why can't I see open files when I press l?

That feature relies on lsof. Install it if it is missing, and make sure you have sufficient privileges.

Does htop work on Alpine and other minimal distributions?

Yes. htop is packaged for Alpine, Arch, Fedora, and Debian-based systems, though available features can vary by build.

Conclusion

htop is a deceptively simple tool that rewards analysts who use it with discipline. Sort to find the outliers, use tree view to understand lineage, check ownership, then confirm with ps, lsof, and /proc. Above all, capture evidence before you terminate anything. Combined with proper logging and endpoint monitoring, these habits make the difference between a clean investigation and a confusing one at 2:40 in the morning.

Analysis based on SOC monitoring experience and review of public Linux documentation.

Shubham Chaudhary

Shubham Chaudhary is a cybersecurity specialist and founder of Xpert4Cyber. He shares practical tutorials, guides and the latest news on Networking, Windows Server, Linux Server, Ethical Hacking, Digital Forensics, Malware Analysis, Threat Hunting and Monitoring, OSINT, Cloud Computing and AI, with a focus on defense and security awareness. Educational and defensive use only.

Post a Comment

Previous Post Next Post
ADVERTISEMENT
ADVERTISEMENT