H
10Corp Premium Hosting

The ps and kill Commands — Managing Processes

Last Updated: 2025-01-01 3 min read

Overview

Managing processes is a core part of Linux server administration. The ps command shows what’s currently running, and the kill command lets you stop processes that are stuck, consuming too many resources, or no longer needed.

The ps Command

Basic Usage

ps

This shows only processes in your current terminal session — usually not very informative.

View All Processes (Most Common)

ps aux

This displays every running process on the system with detailed information:

USER       PID %CPU %MEM    VSZ   RSS TTY   STAT START   TIME COMMAND
root         1  0.0  0.1 169316 11752 ?     Ss   Jan01   0:05 /sbin/init
mysql     1234  2.5 12.0 1286452 245680 ?   Sl   Jan01  45:12 /usr/sbin/mysqld
www-data  5678  0.3  1.2  456780 24560 ?    S    08:15   0:02 /usr/sbin/apache2

Understanding the Columns

ColumnDescription
USERThe user who owns the process
PIDProcess ID — the unique identifier you need for kill
%CPUCPU usage percentage
%MEMMemory usage percentage
VSZVirtual memory size (KB)
RSSResident set size — actual physical memory used (KB)
TTYTerminal associated with the process (? means no terminal)
STATProcess state (see below)
STARTWhen the process started
TIMETotal CPU time consumed
COMMANDThe command that launched the process

Common Process States (STAT)

StateMeaning
RRunning or runnable
SSleeping (waiting for an event)
DUninterruptible sleep (usually I/O)
ZZombie — process finished but not cleaned up by parent
TStopped

Finding a Specific Process

Combine ps with grep:

ps aux | grep apache
ps aux | grep mysql
ps aux | grep php

Show only your processes

ps -u username

The kill Command

Basic Usage

kill PID

This sends a SIGTERM (signal 15) — a polite request for the process to shut down gracefully.

Force Kill

If a process ignores SIGTERM:

kill -9 PID

SIGKILL (signal 9) immediately terminates the process. Use this as a last resort — it gives the process no chance to clean up.

Kill by Name

killall process_name

Example:

killall php-cgi

This kills all processes matching that name.

Alternative: pkill

pkill -f "python3 script.py"

The -f flag matches against the full command line, not just the process name.

Common Kill Signals

SignalNumberPurpose
SIGHUP1Reload configuration
SIGTERM15Graceful termination (default)
SIGKILL9Forced termination
SIGSTOP19Pause the process
SIGCONT18Resume a paused process

Reload a service without stopping it

kill -HUP PID

Useful for making services like Apache or Nginx reload their configuration.

Practical Hosting Examples

Find and kill a stuck PHP process

ps aux | grep php
# Note the PID from the output
kill 12345

Kill all user processes (emergency reset)

killall -u username

Check if MySQL is running

ps aux | grep mysql

Find zombie processes

ps aux | grep 'Z'

Tips

  • Always try kill PID (SIGTERM) before resorting to kill -9 PID.
  • Use ps aux --sort=-%cpu | head -20 to see the top 20 CPU-consuming processes.
  • Use ps aux --sort=-%mem | head -20 to see the top 20 memory-consuming processes.
  • On shared hosting, you typically can only kill your own processes. Contact your hosting provider for system-level issues.
Tags: ssh linux processes ps kill

Still need help?

Our support team is available 24/7 to assist you.