Processes and Services in Linux

Prathvi Kothari
3 min readMar 3, 2021

A process is a program in execution; it is a running instance of a program. It is consists of the program instruction, data from files, other programs, and input from a system user. Different processes have different IDs. (pid) (ppid[parent process id]). Root processes have the same pid and ppid.

Processes are of 2 types:

Foreground process (Interactive processes) — These are the processes that are initialized and controlled through a terminal session. There needs a user to be connected to the system to start such processes. They are not started automatically as part of the system services. Eg: All the tasks performed by the user like using a keyboard and performing some inputs.

Background process (Automatic processes) — These are the processes not connected to a terminal; they do not expect any user input. We are only able to see the input of the process and the output. Background processes are not visible to us.

State of a process in Linux:

  1. Running state: The process either executing on the CPU or waiting to run. The process can be executing users or kernel system calls is called a running state.
  2. Sleeping state( Waiting State): The process is always sleeping but unlike not able to respond to any system call. When the child process is not completed till then the parent process is waiting in the sleeping state. It is uninterruptable by the kernel or user.
  3. Stopped state: The process will be stopped when another process wants to execute. Sometimes we need to stop the process permanently sometimes it goes in the stop state.
  4. Zombie state: Two types of zombie :

Exit zombie: parent and the child process is completed and when they will be released pid and ppid then they move to exit zombie mode.

Dead zombie: If One of the child is not able to complete its task while other have completed then it is moved to dead zombie

Linux Services:

A service is a program that runs in the background. They run outside the interactive control of system users as they lack an interface. They provide even more security, because some of these services are important for the running of the operating system.

In Unix or Linux, the services are also known as daemons. Few of the times the name of these services or daemons ends with the letter d. For example, sshd is the name of the service that handles SSH.

Managing Linux Services

Below are the basic controls of services like start, stop, and check the status of the service.

For starting a service on Linux, we need to run the following command:

sudo systemctl start [service_name]

If the service is correctly configured, it will start.

Now, if we want to stop it, we will use the following command:

sudo systemctl stop [service_name]

Meanwhile, to check the status of a service we can use:

sudo systemctl status [service_name]

It is also possible to have a service run while the operating system is being loaded:

sudo systemctl enable [service_name]

Or remove it from the initial load:

sudo systemctl disable [service_name]yum install net-tools

Then, we run the following command:

sudo netstat -plnt

The output will give us all the required network information.

--

--