Professional Documents
Culture Documents
Exp 4 - Linux Commands in Process Management
Exp 4 - Linux Commands in Process Management
Exp 4 - Linux Commands in Process Management
Theory: A process in Linux is nothing but a program in execution. It’s a running instance of a
program. Any command that you execute starts a process.
● Foreground Processes
depend on the user for input
also referred to as interactive processes
● Background Processes
run independently of the user
referred to as non-interactive or automatic processes
A process in Linux can go through different states after it’s created and before it’s terminated.
These states are:
● Running
● Sleeping
● Interruptible sleep
● Uninterruptible sleep
● Stopped
● Zombie
● A process in running state means that it is running or it’s ready to run.
Mahavir Education Trust's
● Zombie state is when a process is dead but the entry for the process is still present in the table.
There are two commands available in Linux to track running processes. These two commands
are Top and Ps.
To track the running processes on your machine you can use the top command.
$ top
Mahavir Education Trust's
Top command displays a list of processes that are running in real-time along with their memory
and CPU usage. Let’s understand the output a little better:
You can use the up/down arrow keys to navigate up and down through the list. To quit press q.
To kill a process, highlight the process with the up/down arrow keys and press ‘k’.
Alternatively, you can also use the kill command, which we will see later.
$ ps
Here:
$ ps -A
Mahavir Education Trust's
This command lists even those processes that are currently not running.
3. Stop a process
To stop a process in Linux, use the 'kill’ command. kill command sends a signal to the process.
There are different types of signals that you can send. However, the most common one is ‘kill -9’
which is ‘SIGKILL’.
$ kill -L
Kill L
The default signal is 15, which is SIGTERM. Which means if you just use the kill command
without any number, it sends the SIGTERM signal.
$ kill [pid]
$ kill -9 [pid]
Mahavir Education Trust's
This command will send a ‘SIGKILL’ signal to the process. This should be used in case the
process ignores a normal kill request.
In Linux, you can prioritize between processes. The priority value for a process is called the
‘Niceness’ value. Niceness value can range from -20 to 19. 0 is the default value.The fourth
column in the output of top command is the column for niceness value.
To start a process and give it a nice value other than the default one, use: