DEV Community

Bijay Kumar Pun
Bijay Kumar Pun

Posted on

Linux Test Session with $ps [unedited/notes]

The Linux Commandline

Chapter 3

$ man some_command
-Show manual

$whoami
-Show current user

$who
-whoami just with tty info and system start time

  • [-b] show system boot time

$ps

  • a SNAPSHOT of the current process
  • SNAPSHOT because it isn't live
  • use $top for live processes
  • $ps can have three different types of parameters;
  • Unix style : with the dash
  • BSD style : without the dash [Berkeley Software Distribution]
  • GNU style : with double dash

  • [-a] get all process except both session leaders and process not associated with a terminal

  • [-A or -e] get all processes

In Linux, every process has several IDs associated with it, including:

Process ID (PID)

This is an arbitrary number identifying the process. Every process has a unique ID, but after the process exits and the parent process has retrieved the exit status, the process ID is freed to be reused by a new process.

Parent Process ID (PPID)

This is just the PID of the process that started the process in question.

Process Group ID (PGID)

This is just the PID of the process group leader. If PID == PGID, then this process is a process group leader.

Session ID (SID)

This is just the PID of the session leader. If PID == SID, then this process is a session leader.

Enter fullscreen mode Exit fullscreen mode




Session leaders are those processes whose PID == SID


Alt Text

from above image
UID; The id of the user responsible for launching the process
*Use #$id# to check the current user id
PID : The process ID of the process
PPID: The process id of the parent process if started by another process
C : Processor utilization over the lifetime of the process
STIME: The system time when the process started
TTY; The terminal device rom which the process was launched
TIME : The comulative CPU time required to run the process
CMD : The name of the program that was started

Extra parameter
F; System lags assigned to the process by kernel
S: The state of the process ( O = running on processor; S = sleeing , R = runnable, waiting to run; Z = zombie, process terminated but parent not available, T = process stopped)
PRI : Priority of the process (higher numbers mean lower priority)
NI : Nice value, something used for determining the process
ADDR : The memory address of the process
SZ : Approx. amount of swap space required if process was swapped out
WCHAN : Adress of the kernel function where the process is sleeping


Alt Text

*from above image *
VSZ : The size in kilobytes of the process in memory
RSS : The physical memory that a process has used that isn't swapped out
STAT: A two character state code representing the current process stateps
(First character is like S in Unix style)
For second Character stat:
< : Process running in high priority
N: The process is running in low priority
L : The process has pages locked in memory
s: The process is a session leader
l: The process is multithreaded

  • : The process is running in the foreground

Top comments (0)