Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to check which port is occupied by a process under Linux

Shulou Source: shulou.com Published: 2022-06-01 16:02:53 10月02日 Update

This article mainly explains "how to check which port a process occupies under Linux". The explanation in the article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "how to check which port is occupied by a process under Linux".

Sometimes you need to look under Linux to see which port a process occupies, but only know the general name of the process, such as to see on which port hadoop's namenode is running in order to connect in eclipse.

First use the ps command to view the id of the process:

The code is as follows:

$ps-ef | grep Name

The second field for each line (which takes up several lines for a long time) is the process's id.

Of course, processes running in the java virtual machine, such as hadoop daemons, can be viewed directly with the jsp command:

The code is as follows:

$jps | grep Name

Or if you already know the exact name of the process, you can check it with pidof:

The code is as follows:

$pidof Name

After you see the process id, use the netstat command to see the port it occupies:

The code is as follows:

$netstat-nap | grep pid

Thank you for your reading, the above is the content of "how to check which port a process occupies under Linux". After the study of this article, I believe you have a deeper understanding of how to check which port is occupied by a process under Linux. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Processes ports code commands learning content names that is runs lines fields ideas situations articles times more sometimes knowledge knowledge points articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Information vpn Xiaomi Shulou Technology