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

Linux Process Commands file4

The document provides an overview of various Linux commands related to process management, including 'ps', 'top', 'nice', 'renice', 'fuser', 'kill', 'bg', 'free', 'sar', and 'vmstat'. Each command is explained with its purpose, syntax, and examples, focusing on how they help in monitoring and managing system processes and resources. Key functionalities include viewing process status, adjusting process priorities, and monitoring system memory and CPU usage.

Uploaded by

prashantsutar024
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Linux Process Commands file4

The document provides an overview of various Linux commands related to process management, including 'ps', 'top', 'nice', 'renice', 'fuser', 'kill', 'bg', 'free', 'sar', and 'vmstat'. Each command is explained with its purpose, syntax, and examples, focusing on how they help in monitoring and managing system processes and resources. Key functionalities include viewing process status, adjusting process priorities, and monitoring system memory and CPU usage.

Uploaded by

prashantsutar024
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

Process Commands

( ps, top, nice, renice, f-user, kill, bg, free, sar, vmstat ) 10
===================================================================================
============================================
56) PS - Process Status

- In Linux, a process is a running instance of a program.


- When you execute a program, it becomes a process, an independent, executing
entity with its own memory space.
- Each process is assigned a unique identifier, the Process ID (PID).
- Processes are fundamental to the functioning of the operating system and
play a crucial role in multitasking,
allowing the computer to execute multiple tasks concurrently.

The ps top command provides a information of the current processes on your


system.
Syntax:
ps [options]

Example:
ps

output:
PID TTY TIME CMD
1021 pts/0 00:00:00 bash
1022 pts/0 00:00:00 ps

-->
PID - The Unique process ID
TTY - Terminal type that the user is logged in
TIME - The amount of CPU in minutes & seconds that the process has been
running
CMD - Name of the command that launched the process.

-- Sometimes when we execute ps command, it shows TIME as 00:00:00.


It is nothing but the total accumulated CPU utilization time for any
process and 00:00:00 indicates no CPU time has been
given by the kernel till now.
In above example we found that, for bash no CPU time has been given.
This is because bash is just a parent process for different processes
which needs bash for their execution and bash itself
is not utilizing any CPU time till now.

Options

a--> List all running processes for all users.


-A,-e --> Lists all processes on the entire system, offering a complete
overview of running tasks and programs.
r --> Only lists running processes, useful for monitoring system performance.
u --> Expands the output to include additional information like CPU and
memory usage.
x --> Includes processes without a TTY, showing background processes not tied
to a specific terminal session.

===================================================================================
============================================

57) top
- top command is used to show the Linux processes.
- It provides a dynamic real-time view of the running system.
- Usually, this command shows the summary information of the system and the
list of processes or threads which are currently
managed by the Linux Kernel.
- As soon as you will run this command it will open an interactive command
mode where the top half portion will contain the
statistics of processes and resource usage. And Lower half contains a list
of the currently running processes.

- One of the strengths of the top command is its ability to dynamically


update the displayed information at regular intervals.
- This real-time monitoring capability enables users to observe changes in
system activity, identify spikes in resource usage,
and quickly respond to performance issues.

To launch the top command, open a terminal window and simply type:

top

This will display a continuously updating screen showing various system


metrics.
By default, processes are sorted by CPU usage in descending order, with the
most resource-intensive processes listed at the top.

(Combination of uptime, free & ps commmands)

First half output-

When you first open the top command, the initial line, often referred to as
the header or summary line,
displays information similar to what you see when you use the uptime
command. It shows:

System Time: The current time on the system.


Uptime: How long the system has been running since the last boot.
Users: The number of users currently logged into the system.
Load Average: This is shown in three numbers separated by commas.

These numbers represent the average number of processes waiting for CPU time
over the last 1 minute, 5 minutes, and 15 minutes, respectively.
A value of 1.0 means the system’s CPU is fully utilized; higher values
indicate potential overloading.

Tasks: This section provides an overview of the total number of processes


currently managed by the system.
total: Indicates the total count of processes currently being tracked by the
system.
running: Represents the number of processes currently actively using CPU
time.
sleeping: Refers to processes that are currently idle and waiting for a
signal to wake up.
stopped: Denotes processes that have been manually stopped, typically through
a signal.
zombie: Indicates processes that have completed execution but still have an
entry in the process table.

The %Cpu(s) line in the top command provides information about CPU usage and
statistics on a Linux system. It typically includes:

us: Percentage of CPU time spent running user processes.


sy: Percentage of CPU time spent running kernel (system) processes.
ni: Percentage of CPU time spent running processes with a nice value
(priority adjusted).
id: Percentage of CPU time spent idle (no work being done).
wa: Percentage of CPU time spent waiting for I/O operations to complete.
hi: Percentage of CPU time spent servicing hardware interrupts.
si: Percentage of CPU time spent servicing software interrupts.
st: Percentage of CPU time stolen from this virtual machine by the hypervisor
(if virtualized).

The “MiB Memory” line in the top command provides information about memory
usage and statistics on a Linux system. It typically includes:

total: Total amount of physical memory (RAM) available in MiB.


used: Amount of RAM currently in use by processes and the kernel.
free: Amount of RAM not being used at all.
buff/cache: Amount of memory used for buffering data and caching filesystems.
available: Estimate of how much memory is available for starting new
applications without swapping.

The “MiB Swap” line in the top command provides information about swap usage
and statistics on a Linux system. It typically includes:

total: Total amount of swap space available in MiB.


used: Amount of swap space currently in use.
free: Amount of swap space that is not being used.
cached: Amount of swap space used for caching swap pages.

----------------------------------------------------------------
Second half output

PID: Shows task’s unique process id.


USER: User name of owner of task.
PR: The process’s priority. The lower the number, the higher the priority.
NI: Represents a Nice Value of task. A Negative nice value implies higher
priority, and positive Nice value means lower priority.
VIRT: Total virtual memory used by the task.
RES: How much physical RAM the process is using, measured in kilobytes.
SHR: Represents the Shared Memory size (kb) used by a task.
%CPU: Represents the CPU usage.
%MEM: Shows the Memory usage of task.
TIME+: CPU Time, the same as ‘TIME’, but reflecting more granularity through
hundredths of a second.
COMMAND: The name of the command that started the process.

===================================================================================
============================================

58) nice & renice

- In Linux, managing process priority is crucial for optimizing system


performance, especially in environments where multiple
processes compete for CPU resources. The nice and renice commands allow
users to adjust the scheduling priority of processes,
influencing how the Linux kernel allocates CPU time among them.
- ‘nice’ Command:
- This command is used to start a new process with a specific priority,
known as the “nice value.”
- A higher nice value lowers the process’s priority, while a lower
(negative) nice value increases it.
- Processes with higher priority receive more CPU time.

Syntax:
nice value process_name

Ex:
To set the priority of a process
To start a new process with a specific nice value

nice -10 process_name

- ‘renice’ Command:
- Unlike nice, which sets the priority when starting a process, renice
modifies the priority of an already running process.
- This flexibility allows system administrators to manage process
priorities based on the current system load dynamically.

Syntax:
renice value process_name

Ex:
Changing priority of the running process.
To modify the priority of an already running process, use the ‘renice’
command with the process ID (PID):

renice -n 15 -p 77982

===================================================================================
============================================

59) fuser

- fuser is a command line utility in Linux. fuser can identify the process
using the files or sockets.
- This command can be also used to kill the process.

Syntax:
fuser [options] [file|socket]

--> While using the fuser command, always mention the filename or path of the
filename with the fuser command.

===================================================================================
============================================

60) kill

- It is used to terminate processes manually.


- kill command sends a signal to a process that terminates the process

Syntax :
n
u87u kill PID

PID = The `kill` command requires the process ID (PID) of the process we want
to terminate.

===================================================================================
============================================

61) bg

- bg command in linux is used to place foreground jobs in background.

Syntax:

bg [job_spec ...]

===================================================================================
============================================

62) free

- The `free` command in Linux is the one that facilitates with providing the
overview of system memory utilization.
- It displays all the details regarding the RAM usage such as how is the
total, what is used, and free memory including
buffers and cached data, aiding in real-time monitoring of memory
resources.
- It acts as essential command for administrators and users to assess system
performance, allocate resources effectively, and
identify potential memory-related issues promptly.

Syntax:

free [OPTION]

-k, –kilo --> Displays memory usage in kilobytes (default).


-m, –mega --> Displays memory usage in megabytes.
-g, –giga --> Displays memory usage in gigabytes.
–tera --> Displays memory usage in terabytes.
-h, –human --> Automatically scales all output columns to the shortest
three-digit unit and displays the units (B, K, M, G, T).
-c, –count --> Displays the output ‘c’ number of times; works with the
-s option.

When no option is used then free command produces the columnar output
as shown above where column:

total -->displays the total installed memory (MemTotal and SwapTotal


i.e present in /proc/meminfo).
used --> displays the used memory.
free --> displays the unused memory.
shared --> displays the memory used by tmpfs(Shmen i.e. present in
‘/proc/meminfo’ and displays zero in case not available).
buffers --> displays the memory used by kernel buffers.
cached --> displays the memory used by the page cache and slabs(Cached
and Slab available in ‘/proc/meminfo’).
buffers/cache --> displays the sum of buffers and cache.

===================================================================================
============================================

63) sar - (System Activity Report)

- sar (System Activity Report) It can be used to monitor Linux system’s


resources like CPU usage, Memory utilization,
I/O devices consumption, Network monitoring, Disk usage, process and thread
allocation, battery performance,
Plug and play devices, Processor performance, file system and more.

Syntax:

sar options

To report CPU details a total of 5 times with the interval of 2 seconds.


If the interval command is set to zero, average statistics from the time
system started are presented.
If the count is not provided and the interval is given, statistics are
provided continuously after every interval.

Syntax: m

sar -u 2 5

To report about the amount of memory used, amount of memory free, available
cache, available buffers total 3 times with the interval of 1 second.

Syntax:

sar -r 1 3

===================================================================================
============================================

64) vmstat - (Virtual Memory Statistics)

- vmstat command in Linux/Unix is a performance monitoring command of


the system as it gives the information
about processes, memory, paging, block IO, disk, and CPU scheduling.
- All these functionalities makes the command vmstat also known as
virtual memory statistic reporter.

Syntax:

vmstat [options][delay [count]]

Delay:
- It is the time interval in between two updates.
- It can be termed as a sampling period after each interval of the
sampling period report that will be printed with the updated details.
- If there will be no delay specified only one report will be printed
with average value since boot.

Count:
- It is the number of updates which is printed after each
interval(sampling period).
- In absence of count and delay is specified, the default value of
count is infinite.

===================================================================================
============================================

You might also like