Processes Management

A process, in simple terms, is an instance of running program.

Whenever you issue a command in Linux, it creates or start a process.

Processes Types

When you issue a command (a process), there are two ways you can run it.

  • Foreground Process

  • Background Process

    The simplest way to start a background process is to add an ampersand (&) at the end of the command.

Checking Running Processes

It is easy to see your own processes by using the ps command.

In addition, you can see more information of the processes by adding the -f option along with the ps

1
2
3
4
5
6
$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
amrood 3662 3657 0 08:10:53 pts/6 0:00 -ksh
amrood 6892 3662 4 10:51:50 pts/6 0:00 ps -f

Here is the description of all the fields displayed by ps -f command −

Column & Description
UID User ID that this process belongs to (the person running it)
PID Process ID
PPID Parent process ID (the ID of the process that started it)
C CPU utilization of process
STIME Process start time
TTY Terminal type associated with the process
TIME CPU time taken by the process
CMD The command that started this process

Kill Processes

  1. kill the foreground processes

    Just by sending a CTRL + c keystroke, the foreground prosses exits.

  2. kill the background processes

    Firstly, you should get the PID of the background process using the ps command. After that, you can kill it with the kill command

    **If the process ignores the kill, you can use kill -9 followed by the PID. **