Skip to content

How to List Processes in Linux: A Beginner’s Guide

January 30, 2023
Listing Processes in Linux

This beginner’s guide will teach you how to list processes in Linux using the ps, top, and htop commands. You’ll learn how to view all running processes, filter the list of processes, and sort the list by different criteria

Processes in Linux

A process is an executing program with several components and properties, including a memory context, priority, and environment. The Linux kernel tracks every aspect of a process by its PID under /proc/PID.

List Running Processes in Linux

To list running processes, use the pstophtop, and atop Linux commands. You can also combine the ps command with the pgrep command to identify individual processes.

List Running Processes in Linux by Using the ps Command.

The ps Linux command creates a snapshot of currently running processes. Unlike the other commands on this list, ps presents the output as a static list, not updated in real time.

  • ps [options]
    • -A, -e shows all processes
    • -a all with tty, except session leaders
    • a all with tty, including other users.
    • -d all except session leaders
    • -N, --deselect negate selection
    • r only running processes
    • T all processes on this terminal
    • x processes without controlling ttys
    • -u user shows all processes by user
    • -F prints extra information
    • -f full-format, including command lines
    • -H Show process hierarchy
    • -o PROPERTY1, PROPERTY2,…. prints custom information:
      • pid, comm, %cpu, %mem, state, tty, euser, ruser, etc.
        • Example:-
          • Print Custom information
          • ps -eo pid,%cpu,comm
  • Example Syntax:
    • Print Custom information
      • ps -eo pid,%cpu,comm
    • To see every process on the system using standard syntax:
      • ps -e
      • ps -ef
      • ps -eF
      • ps -ely
    • To see every process on the system using BSD syntax:
      • ps ax
      • ps axu
    • To print a process tree:
      • ps -ejH
      • ps -axjf
    • To get info about threads:
      • ps -elf
      • ps axms
    • To get security info:
      • ps -eo euser,ruser,suser,fuser,f,comm,label
      • ps axZ
      • ps -eM
    • To see every process running as root (real & effective ID) in user format:
      • ps -U root -u root u
    • To see every process with a user-defined format:
      • ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
      • ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
      • ps -Ao pid,tt,user,fname,tmout,f,wchan
    • Print only the process IDs of syslogd:
      • ps -C syslogd -o pid=
    • Print only the name of PID 42:
      • ps -q 42 -o comm=

Note:
You can check complete list of ps command options by using man ps command

Run ps command without option

List Processes in Linux

By default, ps‘s output includes only: –

  • PID : Process ID
  • TTY: The Terminal it is attached to, if any
  • TIME: The amount of time the processor has spent working on this process behalf.
  • CMD: The name of executable that created the process.

To see every process on the system by using command: –

ps aux
List Processes in Linux

Expanded output include: –

  • USER: The name of user.
  • %CPU: The CPU usage percentage.
  • %MEM: The memory usage percentage.
  • VSZ: Total swap space used by the process, in kilobytes.
  • RSS: The amount of RAM being used by the process.
  • STAT: The current process state.
  • START: The time the process was started

To Print the process Tree: –

ps -axjf
List Processes in Linux