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

Active Process

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

Active Process

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

Question: Which Tools Are Used For Reporting

Statistics In Linux?
Some of the popular and frequently used system resource generating tools available
on the
Linux platform are
vmstat
netstat
iostat
ifstat
mpstat.
These are used for reporting statistics from different system components such as
virtual
memory, network connections and interfaces, CPU, input/output devices and more.
Question: What Is Dstat In Linux?
dstat is a powerful, flexible and versatile tool for generating Linux system
resource
statistics, that is a replacement for all the tools mentioned in above question.
31/71
It comes with extra features, counters and it is highly extensible, users with
Python
knowledge can build their own plugins.
Features of dstat:
1. Joins information from vmstat, netstat, iostat, ifstat and mpstat tools
2. Displays statistics simultaneously
3. Orders counters and highly-extensible
4. Supports summarizing of grouped block/network devices
5. Displays interrupts per device
6. Works on accurate timeframes, no timeshifts when a system is stressed
7. Supports colored output, it indicates different units in different colors
8. Shows exact units and limits conversion mistakes as much as possible
9. Supports exporting of CSV output to Gnumeric and Excel documents
Question: Types Of Processes In Linux?
There are fundamentally two types of processes in Linux:
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.
Question: Creatin Of Processes In Linux?
A new process is normally created when an existing process makes an exact copy of
itself
in memory.
The child process will have the same environment as its parent, but only the
process ID
number is different.
There are two conventional ways used for creating a new process in Linux:
Using The System() Function – this method is relatively simple, however, it’s
inefficient and has significantly certain security risks.
Using fork() and exec() Function – this technique is a little advanced but offers
greater flexibility, speed, together with security.
Question: Creation Of Processes In Linux?
32/71
Because Linux is a multi-user system, meaning different users can be running
various
programs on the system, each running instance of a program must be identified
uniquely
by the kernel.
And a program is identified by its process ID (PID) as well as it’s parent
processes ID
(PPID), therefore processes can further be categorized into:
Parent processes – these are processes that create other processes during runtime.
Child processes – these processes are created by other processes during run-time.
Question: What Is Init Process Linux?
lnit process is the mother (parent) of all processes on the system, it’s the first
program that
is executed when the Linux system boots up; it manages all other processes on the
system. It is started by the kernel itself, so in principle it does not have a
parent process.
The init process always has process ID of 1. It functions as an adoptive parent for
all
orphaned processes.
You can use the pidof command to find the ID of a process:
# pidof systemd
# pidof top
# pidof httpd
Find Linux Process ID
To find the process ID and parent process ID of the current shell, run:
$ echo $$
$ echo $PPID
Question: What Are Different States Of A
Processes In Linux?
During execution, a process changes from one state to another depending on its
environment/circumstances. In Linux, a process has the following possible states:
Running – here it’s either running (it is the current process in the system) or
it’s
ready to run (it’s waiting to be assigned to one of the CPUs).
Waiting – in this state, a process is waiting for an event to occur or for a system
resource. Additionally, the kernel also differentiates between two types of waiting
processes; interruptible waiting processes – can be interrupted by signals and
uninterruptible waiting processes – are waiting directly on hardware conditions and
cannot be interrupted by any event/signal.
Stopped – in this state, a process has been stopped, usually by receiving a signal.
For instance, a process that is being debugged.
33/71
Zombie – here, a process is dead, it has been halted but it’s still has an entry in
the
process table.
Question: How To View Active Processes In Linux?
There are several Linux tools for viewing/listing running processes on the system,
the two
traditional and well known are ps and top commands:
1. ps Command
It displays information about a selection of the active processes on the system as
shown
below:
#ps
#ps -e ] head
2. top – System Monitoring Tool
top is a powerful tool that offers you a dynamic real-time view of a running system
as shown
in the screenshot below:
#top
3. glances – System Monitoring Tool
glances is a relatively new system monitoring tool with advanced features:
#glances
Question: How To Control Process?
Linux also has some commands for controlling processes such as kill, pkill, pgrep
and
killall, below are a few basic examples of how to use them:
$ pgrep -u tecmint top
$ kill 2308
$ pgrep -u tecmint top
$ pgrep -u tecmint glances
$ pkill glances
$ pgrep -u tecmint glances
Question: Can We Send signals To Processes In
Linux?
The fundamental way of controlling processes in Linux is by sending signals to
them. There
are multiple signals that you can send to a process, to view all the signals run:
34/71
$ kill -l
List All Linux Signals
To send a signal to a process, use the kill, pkill or pgrep commands we mentioned
earlier
on. But programs can only respond to signals if they are programmed to recognize
those
signals.
And most signals are for internal use by the system, or for programmers when they
write
code. The following are signals which are useful to a system user:
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] .

You might also like