$ command-helper

Linux: processes and resources

Finding and killing processes, CPU and memory, open ports and files, background jobs.

Requires Google sign-in

Processes

All processes
ps aux
Find a process by name
pgrep -af <name>
Process tree
ps auxf

Or pstree -p if it is installed.

Top 10 processes by memory
ps aux --sort=-%mem | head -11
Top 10 processes by CPU
ps aux --sort=-%cpu | head -11
Interactive monitor
htop

top is always available; htop is friendlier.

Stopping processes

Gracefully stop a process (SIGTERM)
kill <pid>
Force kill (SIGKILL)
kill -9 <pid>

The process can't clean up after itself — use only when SIGTERM doesn't help.

Kill all processes matching a name
pkill -f <name>
Kill whatever listens on a portadvanced
kill $(lsof -t -i :<port>)

Ports and files

Who listens on a port
lsof -i :<port>
All listening TCP ports with processes
sudo ss -tlnp
Files opened by a processadvanced
lsof -p <pid>
Deleted files still held open (disk not freed)advanced
sudo lsof +L1

Memory and load

Memory usage
free -h
Uptime and load average
uptime
CPU, memory and IO every secondadvanced
vmstat 1
Why a process was OOM-killedadvanced
sudo dmesg -T | grep -i -E 'killed process|out of memory'

Background jobs

Run a command immune to logout
nohup <command> > output.log 2>&1 &
List jobs of the current shell
jobs -l
Bring a job to the foreground
fg %1

Ctrl+Z suspends the current command, bg resumes it in the background.

Repeat a command every 2 seconds
watch -n 2 '<command>'