How to Identify Unknown Commands Hogging CPU in Linux

Abstract: Resolve high CPU usage caused by unknown or malicious processes in Linux by identifying, inspecting, and terminating them.

Created: 2026-08-03 by

Identifying unknown commands hogging CPU in Linux requires using htop or top to locate high-resource processes, then inspecting their command lines with ps aux and checking open files via lsof. If the process is malicious or orphaned, terminate it immediately with kill -9 and investigate logs for the root cause.

Immediate Identification with htop

The first step in troubleshooting excessive CPU usage is visualizing which process is responsible. The htop utility provides a more intuitive interface than the traditional top command, making it easier to spot anomalies quickly. Open your terminal and run htop. You will see a list of running processes sorted by CPU usage by default. Look for any entry that shows a high percentage in the CPU% column, especially if the name is unfamiliar or appears as a hash or random string. If you do not have htop installed, use sudo apt install htop on Debian-based systems or sudo yum install htop on Red Hat-based systems. Once installed, press F2 to enter settings and ensure that the Tree view is enabled. This allows you to see parent-child relationships, which is crucial when dealing with scripts or daemons that spawn multiple threads. Press F4 to filter processes by name if you suspect a specific service, but leave it blank to scan everything. Identify the Process ID (PID) of the suspicious process. Note this number down, as you will need it for subsequent diagnostic steps. If the process is consuming 100% of a core, it is likely stuck in an infinite loop or performing heavy computation without yielding. Do not kill it yet; first, gather enough information to understand what it is doing.

Detailed Inspection with ps and lsof

Once you have the PID, you need to determine exactly what command was executed to start that process. The ps command provides detailed information about running processes. Run ps -fp [PID], replacing [PID] with the actual process ID. Look at the COMMAND column. If it shows a simple binary like /usr/bin/python3, it might be a legitimate script. However, if it shows a long, obfuscated string or a path to a temporary directory like /tmp/.hidden/script.sh, it is highly suspicious. To dig deeper, check which files the process has open. Malicious or buggy processes often leak file descriptors or interact with unexpected network ports. Use lsof -p [PID] to list all open files and connections for that process. Pay attention to the TYPE and NAME columns. If you see connections to external IP addresses on unusual ports, or if the process is reading/writing to sensitive system directories, this confirms it is active and potentially harmful. You can also check the environment variables associated with the process using cat /proc/[PID]/environ | tr '\0' '\n'. This might reveal hidden configuration flags or paths that were passed to the executable. Combine these findings with the output from ps to build a complete picture of the process's behavior. If you are unsure whether the process is part of a known service, cross-reference the binary path with your package manager using dpkg -S or rpm -qf.

Termination and Prevention

If the process is confirmed to be unknown and unnecessary, you must terminate it. Start with a graceful termination signal using kill [PID]. This sends SIGTERM, allowing the process to clean up resources before exiting. Wait a few seconds and check if the process is still running with ps -p [PID]. If it persists, escalate to a forceful kill with kill -9 [PID]. This sends SIGKILL, which cannot be ignored by the process, ensuring immediate termination. After killing the process, investigate how it started. Check your cron jobs with crontab -l and review systemd services with systemctl list-units --type=service. Look for entries that reference the binary or script you identified. If it was spawned by a scheduled task, remove or disable that job. If it was part of a misconfigured service, correct the configuration file. For ongoing prevention, consider implementing resource limits. Use ulimit to restrict CPU time for specific users or services. Additionally, monitor your system with tools like nmon or integrate htop alerts into your monitoring stack. Regularly updating your system and auditing startup scripts reduces the risk of unknown processes gaining access to your server. For related issues involving daemon processes, you may find our guide on resolving high CPU usage by a daemon in Plesk VPS helpful.

Common Symptoms and Diagnostics

Sometimes the symptoms are subtle. High CPU usage might not always mean 100% utilization; it could be consistent 50-60% usage that prevents other tasks from running smoothly. In such cases, use mpstat -P ALL 1 to see per-core statistics. If one core is consistently busy while others are idle, it indicates a single-threaded bottleneck, which is common in poorly optimized scripts or single-threaded malware. Another symptom is increased I/O wait. If CPU usage appears low but the system feels sluggish, check I/O wait with iostat -x 1. A high %iowait value suggests the CPU is waiting for disk operations, which might be caused by a process logging excessively or scanning large directories. In these cases, identifying the process via iotop is more effective than htop.

Security Implications

Unknown processes hogging CPU are often signs of crypto-miners or botnet clients. These programs typically hide their names or mimic legitimate system processes. If you find a process named something like kthreadd but located in /tmp, it is almost certainly malicious. Clean up the file and block the associated IP addresses at your firewall level. Always change passwords and audit SSH keys after such incidents, as the attacker likely gained initial access through weak credentials.

Frequently Asked Questions

What should I do if I cannot identify the process owner?

Check the USER column in ps aux; if it is root, the process has elevated privileges. If it is a regular user, check their home directory and crontabs. If the user does not exist, it may be a zombie process or a compromised system account. Investigate the binary location to determine its origin.

Can I recover a process that was accidentally killed?

No, once a process is terminated with kill -9, its memory space is reclaimed and the state is lost. You must restart the service or re-run the script from its source. Ensure you have backups of any data the process was handling to prevent loss during restart.

How do I prevent unknown processes from starting automatically?

Audit your systemd services and cron jobs regularly. Disable unnecessary services with systemctl disable and review crontabs with crontab -e. Implement strict permissions on startup directories like /etc/init.d and /usr/local/bin to prevent unauthorized script placement.

Is htop better than top for finding CPU hogs?

Yes, htop offers interactive sorting, color coding, and tree views that make identifying high-CPU processes faster. While top is universally available, htop provides a more user-friendly experience for real-time monitoring and quick identification of anomalies.

What if the process restarts immediately after killing it?

This indicates a watchdog or a persistent service. Check for systemd timers, cron jobs, or init scripts that trigger the process. Use systemctl status or grep in /etc/cron* directories to find the restart mechanism. Stop the parent service before killing the child process to prevent respawn.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More