0% found this document useful (0 votes)
54 views3 pages

Linux Process Management

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views3 pages

Linux Process Management

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Linux Process Management

In simple words a process is a naming convention used by Linux to assume role of a


running program/command.
States of Process
 Foreground processes (also referred to as interactive processes) – these are
initialized and controlled through a terminal session. In other words, there has to be
a user connected to the system to start such processes; they haven’t started
automatically as part of the system functions/services.
 Background processes (also referred to as non-interactive/automatic processes) –
are processes not connected to a terminal; they don’t expect any user input.

Notation for State of Process:

 R: running or runnable, it is just waiting for the CPU to process it


 S: Interruptible sleep, waiting for an event to complete, such as input from the
terminal
 D: Uninterruptible sleep, processes that cannot be killed or interrupted with a signal,
usually to make them go away you have to reboot or fix the issue
 Z: Zombie, we discussed in a previous lesson that zombies are terminated processes
that are waiting to have their statuses collected
 T: Stopped, a process that has been suspended/stopped

Tty(Teletype Terminal)
Linux operating system represents everything in a file system, the hardware devices
that we attach are also represented as a file. The terminal is also represented as a
file. There a command exists called tty which displays information related
to terminal. The tty command of terminal basically prints the file name of the
terminal connected to standard input. tty is short of teletype, but popularly known
as a terminal it allows you to interact with the system by passing on the data (you
input) to the system, and displaying the output produced by the system.
#tty [to know the terminal]
There are more than 50 ttys.

Commands to Manage the Processes in Linux:


#ps command
#ps
#ps ax
#ps aux [display the process owner]
#ps ax | grep httpd [search particular process is running or not]
#top command
The top command displays a real-time list of processes that are running on the
system.
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

PID:- Process ID
USER: Process owner
PR : Priority
NI: Nice value
VIRT: The amount of virtual memory the process uses
RES : The amount of non-swapped physical memory the process uses
SHR : The amount of shared memory the process uses
S: Process state
%CPU : The percentage of the CPU
%MEM : The percentage of the RAM
TIME+ : The accumulated CPU time
COMMAND : The name of the executable file

Top command options


1. Top output keep refreshing until you press ‘q‘. With below command top
command will automatically exit after 20 number of repetitions.
#top –n 20
2. Display Specific User Process
#top –u Praful
3.Highlight Running Process in Top
Press ‘z‘ option in running top command will display running process in colour
which may help you to identified running process easily
4.Shows Absolute Path of Processes
Press ‘c‘ option in running top command, it will display absolute path of running
process

5.Sort by CPU Utilisation:


Press (Shift+P) to sort processes as per CPU utilization.

6.To check PID of particular process


# pidof <process name>
Example: #pidof top
How to Kill the Process
# kill -9 <PID>

Signals of Process:
 SIGHUP 1 – sent to a process when its controlling terminal is closed.
 SIGINT 2 – sent to a process by its controlling terminal when a user interrupts
the process by pressing [Ctrl+C].
 SIGQUIT 3 – sent to a process if the user sends a quit signal [Ctrl+D].
 SIGKILL 9 – this signal immediately terminates (kills) a process and the process
will not perform any clean-up operations.
 SIGTERM 15 – this a program termination signal (kill will send this by default).
SIGTSTP 20 – sent to a process by its controlling terminal to request it to stop
(terminal stop); initiated by the user pressing [Ctrl+Z].

Renice the Process

How to change the priority of linux process


#renice -n <nice value 19 to -20 > -p <pid>

How to change the priority for all processes belonging to group


# renice -n <nice value> -g <group name>

How to change the priority for all processes belonging to User


#renice -n <nice value> -g <username name>

 Nice value in between -20 to 19.


 The lower the number the more priority that task gets.
 The greater the number the less priority that task gets.
 If the niceness value is high number like 19 the task will be set to the lowest
priority.
 If the lowest value is a high number like -20 the task will be set to the highest
priority.
 The default nice value is zero.

You might also like