Process Management


Connection status:

Not Connected



A process is the instance of a computer program that is executed by one or many threads. Processes have a parent-child relationship, meaning one process gives rise to another. Each process has an unique process ID or PID.
The types of processes are:

Reading process information

The ps command shows the snapshot of the current processes running on the system with their PIDs. Here there is a field called STAT which shows the process status. We will use ps -ef where the ‘e’ flag directs to show the processes started by other users too and ‘f’ flag stands for full.

Here there is a field called STAT which shows the process status. The different forms include:

For finding a process in the list, use the grep command. It is to be remembered that in UNIX based operating systems, everything is treated a file or a directory. Including processes. Hence, another way to view all processes can be viewing the directory which stores the processes as files or subdirectories. (This directory is virtual and doe not reside on the disk). The directory is ‘/proc’ and to view the contents, we can simply run
ls -l /proc

It is to be noted that here, each process is represented as a directory and the resources it is using as subdirectories. Hence, you can ‘cd’ into a process and ‘ls’ the contents. Otherwise, if you have ‘tree’ installed, you can see the directory structure of the the directory by running
tree /proc

Each process directory has a file inside with the name ‘status’ that contains the current status of the file. To view the status of a process, run
cat /proc/<PID>/status

Run Command /proc/ /status


Signals

There are a lot of signals that we can send the processes. These signals are labelled with the names starting with SIG. For example, the SIGTERM. In linux, we can terminate a process by sending it the SIGTERM signal by pressing Ctrl+C key combination.
Signals:


Process management

To kill a process, we use the kill command. This sends a SIGTERM signal to the process
kill <PID>
However, we can use the ‘KILL’ flag to send a SIGKILL signal as well. However, this should be the last resort to killing a process.
kill -KILL <PID>
Similarly, to put a process to suspended state, we need the SIGSTP signal. This can be done by using the ‘TSTP’ flag with kill command.
kill -TSTP <PID>
To resume a suspended process, we need the SIGCONT signal. This can be done by using the ‘CONT’ flag with kill command.
kill -CONT <PID>
The results of these commands can be seen by viewing the process table with ps -ef command.

Run Command

Resource Monitoring

The command to see the system utilization in real time is the ‘top’ command. The ‘uptime’ command gives information about the current time, how long the machine is running, number of users logged in and the load average. The load average is in 1, 5 and 15 minutes interval.

The ‘lsof’ command lists open files and what processes are using them.