Costa Rica
Last updated: 2025-08-04
This is a summary based on References
pid: process ID
When you start a process (run a command), two ways of do it:
- Foreground Processes
- Background Processes
By default, every process that you start runs in the foreground. It gets its input from the keyboard and sends its output to the screen.
While a program is running in the foreground and is time-consuming, no other commands can be run (start any other processes) because the prompt would not be available until the program finishes processing and comes out.
A background process runs without being connected to your keyboard. If the background process requires any keyboard input, it waits.
The advantage of running a process in the background is that you can run other commands; you do not have to wait until it completes to start another!
The simplest way to start a background process is to add an ampersand (&) at the end of the command.
It is easy to see your own processes by running the
ps(process status) command
One of the most commonly used flags for ps is the -f ( f for full) option, which provides more information as shown:
$ps -f
UID PID PPID C STIME TTY TIME CMD
UID: User ID that this process belongs to (the person running it)PID: Process IDPPID: Parent process ID (the ID of the process that started it)C: CPU utilization of processSTIME: Process start timeTTY: Terminal type associated with the processTIME: CPU time taken by the processCMD: The command that started this process
There are other options which can be used along with ps command:
-a: Shows information about all users-x: Shows information about processes without terminals-u: Shows additional information like -f option-e: Displays extended information
Sending a CTRL + C keystroke (the default interrupt character) will exit the command.
If a process is running in the background, you should get its Job ID using the ps command. After that, you can use the kill command to kill the process, example:
$ps -f
UID PID PPID C STIME TTY TIME CMD
amrood 6738 3662 0 10:23:03 pts/6 0:00 first_one
amrood 6739 3662 0 10:22:54 pts/6 0:00 second_one
$kill 6738
Or forced:
$kill -9 6738
Each unix process has two ID numbers assigned to it:
- Process ID (pid)
- Parent process ID (ppid).
Each user process in the system has a parent process. Most of the commands that you run have the shell as their parent.
Normally, when a child process is killed, the parent process is updated via a SIGCHLD signal. Then the parent can do some other task or restart a new child as needed. However, sometimes the parent process is killed before its child is killed. In this case, the "parent of all processes," the init process, becomes the new PPID (parent process ID). In some cases, these processes are called orphan processes.
When a process is killed, a ps listing may still show the process with a Z state. This is a zombie or defunct process. The process is dead and not being used. These processes are different from the orphan processes. They have completed execution but still find an entry in the process table.
Daemons are system-related background processes that often run with the permissions of root and services requests from other processes.
A daemon has no controlling terminal. It cannot open /dev/tty. If you do a "ps -ef" and look at the tty field, all daemons will have a ? for the tty.
To be precise, a daemon is a process that runs in the background, usually waiting for something to happen that it is capable of working with. For example, a printer daemon waiting for print commands.
If you have a program that calls for lengthy processing, then it’s worth to make it a daemon and run it in the background.
Background and suspended processes are usually manipulated via job number (job ID). This number is different from the process ID and is used because it is shorter.
A job can consist of multiple processes running in a series or at the same time, in parallel. Using the job ID is easier than tracking individual processes.
[1] From https://www.tutorialspoint.com/unix/unix-processes.htm