Linux Process Commands file4
Linux Process Commands file4
( ps, top, nice, renice, f-user, kill, bg, free, sar, vmstat ) 10
===================================================================================
============================================
56) PS - Process Status
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.
Options
===================================================================================
============================================
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.
To launch the top command, open a terminal window and simply type:
top
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:
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.
The %Cpu(s) line in the top command provides information about CPU usage and
statistics on a Linux system. It typically includes:
The “MiB Memory” line in the top command provides information about memory
usage and statistics on a Linux system. It typically includes:
The “MiB Swap” line in the top command provides information about swap usage
and statistics on a Linux system. It typically includes:
----------------------------------------------------------------
Second half output
===================================================================================
============================================
Syntax:
nice value process_name
Ex:
To set the priority of a process
To start a new process with a specific nice value
- ‘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
Syntax :
n
u87u kill PID
PID = The `kill` command requires the process ID (PID) of the process we want
to terminate.
===================================================================================
============================================
61) bg
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]
When no option is used then free command produces the columnar output
as shown above where column:
===================================================================================
============================================
Syntax:
sar options
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
===================================================================================
============================================
Syntax:
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.
===================================================================================
============================================