What is a process in Linux?
A process is a task that your Linux machine is currently working on. For example, when you open a browser, your machine creates a process for it.
Let’s try to understand this by running a simple command such as ps. Here’s the syntax:
ps [options]
When you run ps in your shell, it will give you the following output.
PID TTY TIME CMD
8 tty1 00:00:00 bash
71 tty1 00:00:00 ps
Explanation
ps gives you information about active processes. By default, it displays all processes associated with the same effective user.
It displays the:
- Process ID
PID - The terminal linked to the process
TTY - The cumulated CPU
TIMEinhh:mm:ssformat - The executable name
CMD
Output is unsorted by default.
For more information on the processes, you can use the ps aux command.
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 8936 100 ? Ssl Sep27 0:00 /init
root 7 0.0 0.0 8936 96 tty1 Ss Sep30 0:00 /init
kedar 8 0.0 0.0 18076 2464 tty1 S Sep30 0:00 -bash
kedar 81 0.0 0.0 18664 1896 tty1 R 00:53 0:00 ps aux
Explanation
In the command aux:
arepresents all usersurepresents the user/ownerxdisplays processes executed outside of the terminal
It also displays some extra fields in results as compared to our previous command, which are:
-
USERrepresents the user that initiated the process. -
%CPUis the CPU utilization of the process. -
%MEMshows the memory usage. -
VSZmeans the virtual memory size of the process in KiB. -
RSSis the non-swapped physical memory that a process has used (in kilobytes). -
STATshows the process state. -
STARTrepresents the time at which the command started.
To stop the process, you can use the kill command. Here’s the syntax:
kill PID
For example, kill 20.
To learn more about the ps command or any other commands in Linux, I encourage you to try the man (manual) command.
The syntax is as follows:
man command