0% found this document useful (0 votes)
4 views

Processes in Unix-7

Uploaded by

nitesh.codeace
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Processes in Unix-7

Uploaded by

nitesh.codeace
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Processes in Unix

A program/command when executed, a special instance is provided by the system to the process.
This instance consists of all the services/resources that may be utilized by the process under execution.

Whenever a command is issued in Unix/Linux, it creates/starts a new process.


For example, pwd when issued which is used to list the current directory location the user is in, a
process starts.
Through a 5 digit ID number Unix/Linux keeps an account of the processes, this number is called process
ID or PID.
Each process in the system has a unique PID.

 Used up pid’s can be used in again for a newer process since all the possible combinations are
used.
 At any point of time, no two processes with the same pid exist in the system because it is the pid
that Unix uses to track each process.

Initializing a process
A process can be run in two ways:
Method 1: Foreground Process : Every process when started runs in foreground by default, receives
input from the keyboard, and sends output to the screen.
When issuing pwd command
$pwd
When a command/process is running in the foreground and is taking a lot of time, no other processes
can be run or started because the prompt would not be available until the program finishes processing
and comes out.
Method 2: Background Process: It runs in the background without keyboard input and waits till
keyboard input is required. Thus, other processes can be done in parallel with the process running in the
background since they do not have to wait for the previous process to be completed.
Adding & along with the command starts it as a background process .

$ pwd &
Since pwd does not want any input from the keyboard, it goes to the stop state until moved to the
foreground and given any data input. Thus, on pressing Enter:
Output:

[1] + Done pwd


$
That first line contains information about the background process – the job number and the process ID.
It tells you that the ls command background process finishes successfully. The second is a prompt for
another command.

Tracking ongoing processes


ps (Process status) can be used to see/list all the running processes.
1)$ ps

PID TTY TIME CMD


19 pts/1 00:00:00 sh
24 pts/1 00:00:00 ps
2)ps –e It shows all processes.
3)ps –efIt shows full listing of all processes.

Top Command
We can use top command to see processes with consumed resources like memory and cpu utilization.
use 'q' to come out of top command.

Killing a Process
Suppose the terminal has hung due to certain reasons which can be some indefinite loops running in
your system or too many processes running in background.Hence we kill that process by using their
processed.

 Kill -9 processid(-9 terminates process forcibly)

You might also like