Author: Arina Püvi A21
Improved: Epp Maaten, AK21 2015/16
Translated: Christopher Carr, C11 2016/17
Last Change: 08.05.2017
Operation systems track system processes and resources. A process is an instance of a program that is being executed, which has been allocated processor and memory (address space) resources. 
ps (process status) is a program, which in UNIX-based operation systems shows information about running processes. In Windows PowerShell the command Get-Process (whose alias is also pre-defined as ps) essentially serves the same purpose. . For tracking processes in a graphical user interface, TaskManager (Windows) and Activity Monitor (MacOSX) is used.
Data about processes are held in the process table. Each process has an identificator PID. A process may start other processes. A process, which started a second process is called a parent process. Processes form a process tree, the top of which is the first executed process. A process tree can be shown with the command pstree.
- input stream STDIN
- output stream STDOUT
- error stream STDERR
The ps utility shall write information about processes, subject to having appropriate privileges to obtain information about those processes. By default, ps shall select all processes with the same effective user ID as the current user and the same controlling terminal as the invoker. 
The utility ps usually displays information about each process on a separate line. The process description line includes the PID (process identificator), the invoking terminal, CPU time and command tied to the process. With different parameters it is possible to change the ps command and filter processes you are searching for. If the command contains more than one sort order parameter, the processes will be sorted based on the last sorting option which was specified. [BSD General Commands Manual]
ps PID TTY TIME CMD 2643 pts/o 00:00:00 su 2644 pts/0 00:00:00 bash 3092 pts/0 00:00:00 ps
All running processes have unique identificators (PID), which by default are in the range 1 - 32767. Every new process is assigned the next available PID. When a process finishes its job (or is killed), its PID is freed. Reaching the maximal PID, the next process PID will be selected as the smallest available PID and so on.
The column TTY describes the terminal from which the process was invoked. With no extra parameters, a simple ps command shows only the list of processes invoked in the running terminal, so the information in the TTY column is the same for all lines. The column TIME indicates the amount of time the process has used CPU (central processing unit) resources. This is NOT the time that the process was initiated! The TIME column should show as small a time as possible. If the time is too large, this can point to errors. In the column CMD, the processes own name is listed.
Extended process table elements
|parent process identificator
|process priority, which is used by process scheduler
|process start time
|the terminal, with which the given process is bound to
|time, that the given process has used CPU resources
|the command that invoked the given process
|the state of the process. The state is displayed as a sequence of symbols, for example RWNA. The first symbol (R) shows the process is running.
Process state characteristical parameters
|Marks a runnable process.
|Marks a process that is sleeping for less than about 20 seconds.
|Marks a process that is idle (sleeping for longer than about 20 seconds).
|Marks a process in disk (or other short term, uninterruptible) wait.
|Marks a dead process (a zombie).
|Marks a stopped process.
|Marks an idle interrupt thread.
|The process has raised CPU scheduling priority.
|The process has reduced CPU scheduling priority
|The process has pages locked in core (for example, for raw I/O).
[BSD General Commands Manual]
- Command syntax
- ps [options]
Adding the following options to the command ps, we receive the next reports:
|Display information for all processes.
|Display information about other users' processes as well as your own (excluding processes which do not have a controlling terminal).
|Display the environment as well.
|Sort by current CPU usage, instead of the combination of controlling terminal and process ID.
|When displaying processes matched by other options, include processes which do not have a controlling terminal.
|Show commandline and environment information about swapped out processes. This option is honored only if the UID of the user is 0
|Print information associated with the following keywords: user, pid, ppid, pgid, sid, jobc, state, tt, time, and command.
|Display information associated with the following keywords: uid, pid, ppid, cpu, pri, nice, vsz, rss, mwchan, state, tt, time, and command.
|List the set of keywords available for the -O and -o options.
|Display information about processes which match the specified process IDs.
|Display information about processes which are running with the specified real group IDs.
|Extract the name list from the specified system instead of the default, which is the kernel image the system has booted from.
|Display information according to the format specification.
|Display information about processes which match the specified process ID-s.
|Display a list of all session leaders specified in sidlist.
|Display information about processes attached to the specified terminal devices.
|Display information associated with the following keywords: user, pid, %cpu, %mem, vsz, rss, tt, state, start, time, and command.
|Display the processes belonging to the specified usernames.
[BSD General Commands Manual]
Using the correct option, you can display a complete list of processes in the user's system.
ps ax PID TTY STAT TIME COMMAND 1 ? S 0:01 init  2 ? SN 0:00 [ksoftirqd/0] 3 ? S< 0:00 [events/0] 4 ? S< 0:00 [khelper] 5 ? S< 0:00 [kblockd/0] 29 ? S 0:00 [pdflush]
Complete information about every process at a given time: ps -ef
Even more detailed information about the running processes can be seen by running the command ps aux.
With this option you can, for example, search for more information, which user started the process, how much they use system resources (columns CPU, MEM, VSZ and RSS) and when the process was started. 
- An alternative to the ps command is top which displays ever-updating information about processes. However, the information you can display using top is limited to the size of the window, so any information that does not fit on screen is just ignored.
- The ps command is convenient to use with the less utility, so one can use the up and down arrows to scroll through the information, for example ps ax | less.
- Using the grep utility is convenient to search and display only necessary processes, for exmaple ps ax | grep smbd.
Process must be managed so that the computer could work effectively and optimally use the memory allocated to it. Processes must also sometimes be terminated (killed). To manage processes it is necessary to have knowledge of the ps command's many opportunities, to be able to gather necessary information about processes and know how to analyse it using the various options of the ps command.
Command manual BSD General Commands Manual