Wednesday, January 10, 2018

How to Manage Processes in Linux

https://www.rosehosting.com/blog/how-to-manage-processes-in-linux

We’ll show you, How to Manage Processes in Linux. A process is the
abstraction used by the Linux operating system to represent a running
program. Each process in Linux consists of an address space and a set of
data structures within the server kernel. The address space contains
the code and libraries that the process is executing, the process
variables, its stacks, and different additional information needed by
the kernel while the process is running.PID is a unique ID number named and it is assigned by
the kernel to every process. PIDs are assigned in order as processes are
created.UID is a user identification number of the person who created it.
The EUID is the ‘effective’ user ID, used to
determine what resources and files a process has permission to access at
any given moment. In general, the UID and EUID are the same, except for
the programs that are setuid.
The GID is the group identification number of a
process. The EGID is related to the GID in the same way that the EUID is
related to the UID. In short, a process can be a member of many groups
at once.
Listed below are some basic commands to manage processes in Linux:

1. ps Command to Manage Processes in Linux

It is one of the essential Linux system administrator commands used for monitoring processes.
While different versions of ps differ in their arguments and display,
they all deliver the same information. The output of the ps command can
show the PID, UID, priority, and control terminal of processes. It also
gives information about how much CPU time it has consumed, how much
memory a process is using, and its current status (state).
Process states codes:R – running – the process is running/can be executed.D – uninterruptible sleepS – interruptible sleep – the process is waiting for some event to completeT – Traced or stoppedZ – Zombie – defunct process, a terminated process but
still hanging around in kernel process table because the parent of this
process has still not fetched the termination status of this process.
Here’s an example of ps aux output on a CentOS 7 VPS with cPanel installed on it:

A short explanation of ‘ps aux’ output:
USER – Username of the process’s owner
PID -Process ID
%CPU – Percentage of the CPU a specific process is using
%MEM – Percentage of real memory a specific process is using
VSZ – Virtual size of the process
RSS – Resident set size (number of pages in memory)
TTY – Control terminal ID
STAT – Current process status
START – Time the command started
TIME – CPU time the process has consumed
COMMAND – Command name and arguments

4. kill – Command to Manage Processes in Linux

The kill command is most often used to terminate a process. Kill can
send any signal, but by default, it sends a TERM. kill can be used by
normal users on their own processes or by root on any process.
The syntax of the kill command is:

kill [-signal] pid

where signal is the number or symbolic name of the signal to be sent
and PID is the process identification number of the target process.
A kill without a signal number does not guarantee that the process
will die, because the TERM signal can be caught, blocked, or ignored.
The command ‘kill -9 pid’ ‘guarantees’ that the process will die
because signal 9, KILL, cannot be caught. The killall command kills
processes by name. For example, the following command kills all Dovecot
processes:

6. jobs – Command to Manage Processes in Linux

7. fg – Command to Manage Processes in Linux

This command is used to move a background process into the foreground:

# fg 1
service spamd restart

Of course, you don’t have to Manage Processes in Linux if you use one of our Fully-Managed Linux VPS Hosting services,
in which case you can simply ask our expert Linux admins to manage the
server for you. They are available 24×7 and will take care of your
request immediately.PS. If you
liked this post, on How to Manage Processes in Linux, please share it
with your friends on the social networks using the buttons below or
simply leave a reply in the comments section. Thanks.