Linux how to end a process. Process ID (PID)

Do you think the Linux operating system can take care of itself automatically? When everything is working fine or you do not need any non-standard features - quite yes. But sometimes you may need your intervention in its work.

On Linux for each separate program, when it starts, a process is created. It doesn't matter if you run the program manually yourself, or if it's done by the system or the kernel. For example, the initialization program that runs immediately after the kernel has finished loading also has its own process with ID 0. Processes in linux can be described as containers that store all information about the state and execution of the program. If the program works well, then everything is fine, but if it freezes or you need to tweak its operation, you may need to manage processes in Linux.

This article will cover an extensive topic, we will consider such possibilities:

  • View running processes
  • Viewing process information
  • Finding Processes in Linux
  • Terminating processes
  • Process Memory Limit

I could not help but include the first points in the article, but they are very simple and we will not analyze them in great detail. But everything else may seem complicated and insufficiently described.

Let's start by understanding the terms. In fact, a process is every program. As I said, a separate process is created for each launched program. As part of the process, the program is allocated processor time, RAM and other system resources. Each process has its own identifier, Process ID or simply PID, and Linux processes are most often determined from them. PID is not determined by chance, as I said, the initialization program receives PID 1, and each following running program- one more. Thus, the PID of user programs already reaches several thousand.

In fact, Linux processes are not as abstract as they seem to you now. It is quite possible to try to feel them. Open your file manager, change to the root directory, then open the /proc folder. See a bunch of numbers here? So this is all - the PID of all running processes. Each of these folders contains all the information about the process.

For example, let's look at the process folder 1. The folder has other subdirectories and many files. The cmdline file contains information about the command to start the process:

cat /proc/1/cmdline

/usr/lib/systemd/systemd

Since I use the Systemd initialization system, the first process is launched for it. Everything can be done with the /proc directory. But this is very inconvenient, especially considering the number of running processes in the system. Therefore, for the implementation of the necessary tasks, there are special utilities. Let's move on to the consideration of utilities that allow you to implement process control in Linux.

Linux Process Management

Linux has very a large number of utilities to solve various tasks for process management. These are such multifunctional solutions as htop, top, as well as simple utilities, for example, ps, kill, killall, who, etc. I will not consider graphical utilities in this article, and I will not consider top either. The first is because it's too easy, the second is because htop is better. We will focus on working with the htop program and its counterparts in the form of GNU-style utilities, one utility, one function.

Let's install htop if you don't have it already. In Ubuntu it is done like this:

sudo apt install htop

On other distributions, you just need to use your package manager. The package name is the same.

View running processes

This is a very simple task, and just as easy to solve. There are many utilities for this, ranging from the usual ps to the more advanced interactive top, htop, and so on.

Opening htop, we immediately see a list of running processes. Of course, not all linux processes are displayed here, there are a lot of them in the system, you already know, all of them will not fit on one screen. By default, processes running as your user are displayed:

You can see the following information about the process:

  • PID- process ID
  • USER- the user under which the process was started
  • PRI- linux process priority at the kernel level (usually NI+20)
  • N.I.- process execution priority from -20 to 19
  • S- process state
  • CPU- used processor resources
  • M.E.M.- used memory
  • TIME- process running time

Additional parameters can be added to the display, but these are the main ones. You can add options using the Setup menu. Everything is very simple, read the tips and follow the instructions. For example, the PPID parameter is added:

Highly important feature programs is that you can sort the processes in Linux by the desired parameter. Just click on the name of the parameter, it will be highlighted in green and sorting will be done. For example, if you want to see in what order the processes were launched, sort by PID:

There is also an interesting possibility to place processes in the form of a tree. You will be able to see which process started a particular process. To display the tree, press the F5 button:

You can do almost the same things with the ps program. Only here there is no such convenient interactive mode. Everything is done with options.

Consider the main options that we will use:

  • -e- display information about all processes
  • -a- display information about all the most frequently requested processes
  • -t- show only processes from this terminal
  • -p- show information only about the specified process
  • -u- show processes of a specific user only

In a word, to see all active on this moment processes in linux, a combination of aux options is used:

The program shows all the same parameters, only there is no interactive interface. You think it is impossible to sort processes here, but you are mistaken, you can. There is a sort option for this. You can sort them by any field, for example:

ps aux --sort=%mem

The list will be sorted in reverse order, the values ​​are greater at the bottom and less than at the top. If needed in reverse order, add a minus:

ps aux --sort=-%cpu

Linux process priorities or any other parameters can be used as a sort field. You can also truncate the output if you don't want to display all the information:

It would seem that ps has no way to cost process trees. But not quite, there is a separate command for this:

Finding Processes in Linux

The list of processes is good. But sometimes, when some process is frozen and needs to be killed Linux process or we need to take some action with it, we need to select this process from the list, find out its PID and information about it.

To find the linux process in htop, you can use the F3 key. Press F3 and type right word. Next, to move to the next occurrence, press F2 or Esc to end the search:

You can also use the htop filter to search for processes in htop. Press F4, type in a word, and only linux processes whose name includes that word will be listed.

There is no filtering in the ps utility, but we can use the grep utility by redirecting the output of ps to it to find the linux process:

ps aux | grepchromium

This is a very commonly used command.

Changing the Priority of Processes

The priority of a linux process means how much more CPU time will be given to this process compared to others. This way we can very finely tune which program will run faster and which will run slower. The priority value can range from 19 (minimum priority) to -20 - the maximum priority of the linux process. Moreover, you can reduce the priority with the rights of a regular user, but in order to increase it, you need superuser rights.

htop uses the nice parameter to control priority. Let me remind you that Priv is just an amendment, in most cases it is more than Nice by 20. To change the priority of a process, simply place the cursor on it and press F7 to decrease the number (increase the priority) or F8 to increase the number.

But you don't have to use htop to solve this Linux process management task. You can do everything with other commands. For example, the nice command. With it, you can specify the priority for the running process:

nice -n 10 apt-get upgrade

Or change the priority for an already existing one by its pid:

renice -n 10 -p 1343

Terminating Processes in Linux

If the process is hung and unresponsive, it must be terminated. In htop, to kill a Linux process, simply place the cursor on the process and press F9:

The system uses certain signals to control processes, there are signals that tell the process to terminate. Here are some basic signals:

  • SIGKILL- ask the process to save the data and end
  • SIGTERM- end the process immediately without saving

In general, there are several dozen signals, but we will not consider them. Let's send a SIGKILL signal:

You can also use the kill utility:

You can also kill a process by name:

killallchromium

Process restriction

Process management in Linux allows you to control almost everything. You have already seen what can be done, but even more can be done. With the ulimit command and configuration file/etc/security/limits.conf you can limit processes access to system resources such as memory, files, and CPU. For example, you can limit Linux process memory, number of files, etc.

The entry in the file looks like this:

<домен> <тип> <элемент> <значение>

  • domain- username, group or UID
  • type of- type of restrictions - soft or hard
  • element- a resource that will be limited
  • meaning- necessary limit

Hard limits are set by the superuser and cannot be changed ordinary users. Soft limits can be changed by users using the ulimit command.

Consider the main restrictions that can be applied to processes:

  • nofile
  • as- maximum amount random access memory
  • stack - maximum size stack
  • cpu- maximum processor time
  • nproc- maximum number of processor cores
  • locks- number of locked files
  • nice- maximum process priority

For example, let's limit the processor time for the processes of the user sergiy:

sergiy hard nproc 20

You can view the limits for a particular process in the proc folder:

cat /proc/PID/limits

Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 204800 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 23562 23562 processes
Max open files 1024 4096 files
Max locked memory 18446744073708503040 18446744073708503040 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 23562 23562 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us

Restrictions changed in this way will take effect after a reboot. But we can also set limits for the current shell and the processes it creates with the ulimit command.

Here are the command options:

  • -S- soft limit
  • -H- hard limit
  • -a- display all information
  • -f- maximum size of generated files
  • -n- maximum number of open files
  • -s- maximum stack size
  • -t- maximum amount of processor time
  • -u- maximum number of running processes
  • -v- maximum amount of virtual memory

For example, we can set a new limit for the number of files that can be opened:

Now we look:

Set the RAM limit:

ulimit -Sv 500000

I remind you that this restriction will be relevant for all programs running in this terminal.

conclusions

That's all. Now process management in Linux will not cause you problems. We have considered this topic in great detail. If you have any questions or suggestions for adding to the article, write in the comments!

Today we will talk about how ubuntu linux deal with processes that are stuck and you can't terminate them. They devour system resources by loading the system, devouring a decent part of the RAM, which creates problems such as slowdown in the computer or partial system freezes for short periods of time. There are different situations, sometimes the desktop freezes, sometimes the application freezes, sometimes the desktop environment freezes, it is from these situations that we will look for a way out of how to do without rebooting the system and not turning off the computer with the button system unit computer as this is not a good solution.

Sometimes there is a need to kill a process in Ubuntu Linux, how to do it correctly and not harm, we will discuss both console solutions and through a graphical interface.

Today we're going to talk about how to deal with processes in Ubuntu Linux that are stuck and you can't terminate them. They devour system resources by loading the system, devouring a decent part of the RAM, which creates problems such as slowdown in the computer or partial system freezes for short periods of time. Situations are different, sometimes the desktop freezes, sometimes the application freezes, sometimes the desktop environment freezes, it is from these situations that we will look for a way out, how to do without rebooting the system and not turn off the computer with the button on the computer's system unit, as this is not a good solution .

When working with Ubuntu Linux, you probably already have questions:

How to determine the PID in order to subsequently kill the process / application

If you don't want to run the command top or another more powerful analogue htop, then bother looking for the id of this or that process id, there is an easier way out / solution to find PID process, you can use the command " pidof" or " PS".

Let's say we need to find out the process ID of the application Google Chrome what we do in this situation, open the terminal Ctrl + Alt + T and execute the command in the terminal:

Pidof chrome

we get the output:

9497 9183 9123 8815 8788 6042 6033 5938 5916 5911 5908 5900 5892 5836 5831 5819

almost ready, we have determined the PID, about how to kill the process, read below.

How to kill a process in Linux by PID

We have determined which PID in the application that we want to kill, from the above, you can see that I have many tabs running in the browser and plus separate browser processes, as a result, 16 IDs, to kill them all, execute the command:

Sudo kill 9497 9183 9123 8815 8788 6042 6033 5938 5916 5911 5908 5900 5892 5836 5831 5819

you can also see all active processes in the system by running the command:

sudo ps axu

yes, it's that simple. Instead of Chrome, there can be any other application, skype or some other.

You can also use additional command to find the process id of the application you want to kill:

Ps-A | grep -i name-app

instead of name-app we write the name of the application, do not enter the full name manually, use auto-detection using the keys " TAB". As a result, this command will display the running time of the required process and, accordingly, its PID, which you can use to kill, let's check the command run in the terminal:

Ps-A | grep -i skype

we get the following result:

9257? skype 00:00:57

all we need is at a glance, there is an id, we also see how long this process has already been running.

How to Use the Kill Command in Linux

I have already described how to get the PID identifier above, then we just have to use this PID together with kill than we will kill the process we don’t like, see the details a little lower.

ID received and we can now kill the application:

Sudo kill 9257

that's it, the app is dead.

How to kill a process in Linux by name

To kill a process by name, you can use the killall command, you must first understand that this command kills all processes that have the same name. This is very convenient, since in this situation we do not need to look for the PID of the process we need, for example, we want to close the Skype application, we will execute the command in the terminal:

sudo killall skype

same option:

sudo killall -s 9 skype

at the same moment, the application stops its work, so you can easily kill unwanted processes.

The death command that you should not execute in the terminal

I previously wrote a material about bad advice, which commands should not be executed in the terminal so as not to kill the system, but the list is not perfect and it can be supplemented with many more commands, one of which you will find below.

Here is an example of a death command:

Sudo kill -9 -1

this command will kill all currently running processes. I would not advise you to perform it, since the consequences can be unpredictable and most likely you will have to restart the system without a graphical interface. In case it suddenly refuses GUI, then open the terminal with the commands CTRL+ALT+F1, each new window is opened by the same analogy, it just changes F1 to F2 and so on.

You can also get help on the commands that were used above, through the terminal by running the commands:

Man ps man grep man pidof man kill man killall

This concludes our brief material, if something is not clear to you, ask in the comments to the material below.

Despite the fact that Linux is more stable than Windows, in terms of program operation and various services, things happen and sometimes it becomes necessary to terminate the Linux process. This may be necessary if the program crashed when you started the system service in the background through the terminal, and not in the initialization system, and in many other cases, when it is easier to kill the Linux process, reboot the entire system.

In this article, we will look at some of the most common ways to end a Linux process. We will describe in detail how the process stops and how to do everything right.

Process control in the Linux operating system is carried out using signals. Including the completion of any process. Signals are sent by the system, but they can also be sent by the user using special commands or even keyboard shortcuts in the terminal. When a process is signaled to terminate, it must perform some preparatory work.

It is necessary to terminate child processes, delete temporary files, sockets, and so on. But depending on the complexity of the situation, the process may not respond to all signals. Consider the main signals that are used to terminate the process:

  • SIGINT- the most innocuous termination signal, means Interrupt. It is sent to a process launched from a terminal using the Ctrl+C keyboard shortcut. The process correctly completes all its actions and returns control;
  • SIGQUIT- this is another signal that is sent via a keyboard shortcut to a program running in the terminal. It tells it to terminate and the program can gracefully terminate or ignore the signal. Unlike the previous one, it generates a memory dump. Keyboard shortcut Ctrl+/;
  • SIGHUP- informs the process that the connection to the control terminal is broken, sent mainly by the system when the connection to the Internet is broken;
  • SIGTERM- immediately terminates the process, but is handled by the program, therefore allowing it to terminate child processes and release all resources;
  • SIGKILL- also immediately terminates the process, but, unlike the previous option, it is not transferred to the process itself, but is processed by the kernel. Therefore, resources and child processes remain running.

It is important to understand that you need to give the process a chance to complete gracefully. It is desirable that ports and sockets be freed, closed and temporary files removed. Therefore, never send a SIGKILL immediately. Send termination signals in sequence as listed above.

First ctrl+c, if possible, then SIGTERM - although it ends the process, it does this culturally, and only as a last resort SIGKILL. And now let's look at how to kill a process by pid Linux in practice. If you always use SIGKILL then this picture comes to mind:

How to kill a Linux process?

The kill utility is used to signal processes in Linux. Its syntax is very simple:

$ kill -pid_process signal

The signal is one of the above signals to terminate the process. By default, if this parameter is not specified, the SIGTERM signal is used, which is very correct. We also need to specify which process to terminate. For this, a unique process identifier is used - PID.

Let's say we have a ping utility running. We want to end it with kill. Then, first we find out its ID using the ps command:

ps aux | grep ping

The first line will display the ping utility itself, and the second line will display the ps program itself. We take the desired PID and terminate the process using SIGTERM:

kill -TERM 20446

And only if after this command the process continued to hang, and you can check this by running ps. Only now you can SIGKILL:

kill -KILL 20446

Now we check again:

If the process is running as root, then naturally you need to use sudo. It is not always convenient to kill a process by its PID, at least because you still need to find out this PID. We could use xargs to make a lot of complex constructs to calculate the pid automatically from the process name and terminate it immediately, but this is not necessary. There are already special utilities.

How to kill a process with pkill

The pkill utility is a wrapper for kill, it behaves exactly the same and has the same syntax, only it needs to be passed the name of the process as the process ID. The utility scans the proc directory and finds the PID of the first process with that name, then sends SIGTERM to it. So you can kill a process called Linux. For example, if we want to terminate the same ping:

You can also manually set the signal type:

pkill -TERM ping

Instead of ps, you can use the pgrep utility to find the pid of the process, make sure our program is finished:

But if the program has created several processes for you, for example, the chromium browser or firefox create a separate process for each of the tabs, then this utility will not help much. Here is the next option.

How to stop a process with killall

killall works similarly to the two previous utilities. It also takes the process name as a parameter and looks for its PID in the /proc directory. But this utility will detect all processes with that name and terminate them. For example:

As you can see, there are several processes running, it remains to stop the Linux process with killall:

The command will terminate all running ping utilities, you can verify this by running pgrep again:

conclusions

In this article, we looked at how to kill a Linux process. Sometimes this task can be very useful, but it is important to understand that it must be done correctly. This is not to say that passing SIGKILL instead of SIGTERM is very dangerous, but you shouldn't do it. I hope this information was helpful to you.

Be that as it may, some applications in linux sometimes hang up. At the same time, there are situations when the application does not respond at all, or it works so slowly that it is not possible to shut it down correctly. To quickly get out of the resulting situation, you can "kill" this process. For this, commands are used kill and killall. Now we will understand how to use these commands, find the PID of the process and send the SIGKILL signal.

To avoid confusion, we will agree to understand a process as a program launched into the system. For example, if you have multiple browser windows open Mozilla Firefox- this means that three processes are running.

Find the PID of a process - pidof command

PID- unique process ID in the system linux. To correctly stop a process, you first need to determine its PID. The ps and grep commands are used for this. In its turn ps command is designed to display a list of active processes in the system and information about them. grep command runs at the same time as ps (in a pipe) and will search through the results of the ps command. You can list all processes by running:

Of course, the PID can also be determined via top. But in most cases, the number of processes is too large (and dynamically changes in top), so it is not so easy to quickly and correctly determine the PID. This is exactly what the grep command is used for. For example, to terminate the process Google browser Chrome needs to run the following command:

ps axu | grep chrome

$ ps axu | grep chrome
itechf2 20474 2.7 1.5 938416 120136 tty2 Sl+ 11:07 0:00 /opt/google/chrome/chrome

In our case, 20474 is the desired PID. An easier way is to use the command pidof, and you must specify the name of the process. For example:

$pidofchrome
20728 20706 20668 20647 20586 20574 20553 20508 20474

Kill process in Linux - kill and killall commands

End process in operating system linux, knowing its PID, you can use the command kill. It is worth knowing and understanding: the kill command is intended to send a signal to the process. By default, if we do not specify which signal to send, the SIGTERM signal (from the word termination - termination) is sent. SIGTERM tells the process to terminate. Each signal has its own number. SIGTERM is number 15. A list of all the signals (and their numbers) that the kill command can send can be displayed by typing kill -l . To send a SIGKILL signal (numbered 9) to process 2811, run:

At the same time, the SIGTERM signal may not stop the process (for example, when intercepting or blocking the signal), SIGKILL always kills the process, since it cannot be intercepted or ignored.

killall command in Linux is designed to "kill" all processes that have the same name. This is convenient since we don't need to know the PID of the process. For example, we want to close all processes named chrome. Run in terminal:

The killall command, like kill, sends a SIGTERM signal by default. To send another signal, use the option -s . For example:

Basically, we watch the PID to kill an unresponsive program, and it is similar to the Windows Task Manager.

The Linux GUI also offers the same feature, but the CLI is effective method performing a kill operation.

What is a process PID?

PID stands for process identification number, which is commonly used by most operating system kernels such as Linux, Unix, macOS, and Windows.

This is a unique identification number that is automatically assigned to each process when it is created in the operating system.

A process is an executable instance of a program.

Each time, the process ID will get changed to all processes except init, because init is always the first process in the system and is the ancestor of all other processes. This PID is 1.

The default maximum PID value is 32,768.

# cat/proc/sys/kernel/pid_max

On 32-bit systems, 32768 is the maximum value, but we can set any value up to 2^22 (approximately 4 million) on 64-bit systems.

Why do we need so many PIDs, you may ask? because we can't reuse the PID right away. Also to avoid possible errors.

The PID for running processes on the system can be found using the following nine methods, such as the pidof command, the pgrep command, the ps command, the pstree command, the ss command, the netstat command, the lsof command, the fuser command, and the systemctl command.

  • pidof: pidof - Find the process ID of a running program.
  • pgrep: pgre - lookup or process signals based on name and other attributes.
  • ps:ps - Reports a snapshot of current processes.
  • pstree: pstree - Displays the process tree.
  • ss: ss is used to print socket statistics.
  • netstat: netstat displays a list of open sockets.
  • lsof: lsof is a list of open files.
  • fuser: process IDs in the term list of all processes that open one or more files
  • systemctl: systemctl - Control systemd system and service manager

In this tutorial, we'll take a look at the Apache process ID to check.

Method-1: Using the pidof Command

pidof is used to find the process id of a running program.

It prints these identifiers to standard output.

To demonstrate this, we will get the Apache2 process ID from a Debian 9 system.

# pidof apache2 3754 2594 2365 2364 2363 2362 2361

From the above, you may have difficulty identifying the process id as it shows all PIDs (including parent and child) with the process name.

Therefore, we need to find out the parent PID (PPID) we are looking for.

It might be number one. In my case it is 3754 and it is shown in descending order.

Method-2: Using the pgrep command

pgrep looks at the current processes and lists the process IDs that match the selection criteria for stdout.

# pgrep apache2 2361 2362 2363 2364 2365 2594 3754

This is also similar to the above output, but this one causes the results to be truncated in ascending order, which makes it clear that the parent PID is the last one.

In my case it is 3754.

Note. If you have multiple process IDs, you may run into a problem identifying the parent process ID when using the pidof & pgrep command.

Method-3: Using the pstree command

pstree shows running processes as a tree.

The tree is rooted either in pid or init if pid is omitted.

If a username is specified in the pstree command, then the entire process owned by the corresponding user is displayed.

pstree visually merges identical branches by putting them in square brackets and prefixing them with the number of repetitions.

# pstree -p | grep "apache2" |- apache2(3754)-+-apache2(2361) | |-apache2(2362) | |-apache2(2363) | |-apache2(2364) | |-apache2(2365) | `-apache2(2594)

To get only one parent process, use the following format.

# pstree -p | grep "apache2" | head -1 |- apache2(3754)-+-apache2(2361)

The pstree command is very simple because it separates the parent and child processes separately.

Method-4: Using the ps command

ps displays information about the selection of active processes.

It displays the process ID (pid=PID), the terminal associated with the process (tname=TTY), the cumulative CPU time in hh:mm:ss format (time=TIME), and the executable name (ucmd=cmd).

By default, the output file is not sorted.

# ps aux | grep "apache2" www-data 2361 0.0 0.4 302652 9732 ? S 06:25 0:00 /usr/sbin/apache2 -k start www-data 2362 0.0 0.4 302652 9732 ? S 06:25 0:00 /usr/sbin/apache2 -k start www-data 2363 0.0 0.4 302652 9732 ? S 06:25 0:00 /usr/sbin/apache2 -k start www-data 2364 0.0 0.4 302652 9732 ? S 06:25 0:00 /usr/sbin/apache2 -k start www-data 2365 0.0 0.4 302652 8400 ? S 06:25 0:00 /usr/sbin/apache2 -k start www-data 2594 0.0 0.4 302652 8400 ? S 06:55 0:00 /usr/sbin/apache2 -k start root 3754 0.0 1.4 302580 29324 ? Ss Dec11 0:23 /usr/sbin/apache2 -k start root 5648 0.0 0.0 12784 940 pts/0 S+ 21:32 0:00 grep apache2

From the above output, we can easily identify the parent process ID (PPID) based on the start date of the process.

In my case, the apache2 process was started by @Dec11 which is the parent and the others are children. apache2 PID is 3754.

Method-5: Using the ss command

ss is used to display socket statistics.

It allows you to display information similar to netstat.

It can display more TCP and status information than other tools.

It can display stats for all socket types like PACKET, TCP, UDP, DCCP, RAW, Unix Domain etc.

# ss -tnlp | grep apache2 LISTEN 0 128:::80:::* users:(("apache2",pid=3319,fd=4),("apache2",pid=3318,fd=4),("apache2", pid=3317,fd=4))

Method-6: Using the netstat command

netstat - output network connections, routing tables, interface statistics, masquerading and multicast connections.

By default, netstat displays a list of open sockets.

If you don't specify any address families, the active sockets of all configured address families will be listed.

This program is outdated. The replacement for netstat is ss.

# netstat -tnlp | grep apache2 tcp6 0 0:::80:::* LISTEN 3317/apache2

Method-7: Using the lsof command

lsof - list of open files.

The Linux lsof command displays information about files that are open to processes running on the system.

# lsof -i -P | grep apache2 apache2 3317 root 4u IPv6 40518 0t0 TCP *:80 (LISTEN) apache2 3318 www-data 4u IPv6 40518 0t0 TCP *:80 (LISTEN) apache2 3319 www-data 4u IPv6 40518 0t0 TCP *:80 (LISTEN)

Method-8: Using the fuser command

The fuser utility should write to standard output the process IDs of processes running in local system, which open one or more named files.

# fuser -v 80 /tcp USER PID ACCESS COMMAND 80 /tcp:root 3317 F....apache2 www-data 3318 F.... apache2 www-data 3319 F.... apache2

Method-9: Using the systemctl command

systemctl - Systemd system management and service manager.

This is a replacement for the old system management SysV and most modern operating rooms Linux systems have been adapted by systemd.

# systemctl status apache2 ● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor preset: enabled) Drop-In: /lib/systemd/system/apache2.service. d └─apache2-systemd.conf Active: active (running) since Tue 2018-09-25 10:03:28 IST; 3s ago Process: 3294 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 3317 (apache2) Tasks: 55 (limit: 4915) Memory: 7.9M CPU: 71ms CGroup: /system.slice/apache2.service ├─3317 /usr/sbin/apache2 -k start ├─3318 /usr/sbin/apache2 -k start └ ─3319 /usr/sbin/apache2 -k start Sep 25 10:03:28 ubuntu systemd: Starting The Apache HTTP Server... Sep 25 10:03:28 ubuntu systemd: Started The Apache HTTP Server.

Internet