Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use commands to fix the service status of linux

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will show you how to use commands to fix the service status of linux. The content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.

It is important to verify which ports are listening on the server's network interface. The status of open ports can be used to detect network intrusion, troubleshoot, and confirm port occupancy on the server. Here's how to use the netstat, nmap, and lsof commands to check port usage information and find out which programs are using these ports.

How to check the programs and listening ports in Linux

1. Open a terminal, such as shell command window. 2. Run any of the following commands:

Sudo lsof-I-P-n | grep LISTEN

Sudo netstat-tulpn | grep LISTEN

Sudo nmap-sTU-O IP address

Mode 1:lsof command

The syntax is as follows:

$sudo lsof-I-P-n $sudo lsof-I-P-n | grep LISTEN$ doas lsof-I-P-n | grep LISTEN # OpenBSD

The output is as follows:

Take a closer look at the last line of output above:

Sshd 85379 root 3U IPv4 0xffff80000039e000 0t0 TCP 10.86.128.138 sshd is the program name 10.86.128.138 is the sshd program binding (LISTEN) IP address 22 is used (LISTEN) TCP port 85379 is the process ID of the sshd task (PID)

Mode 2:netstat command

You can use netstat as shown below to check the listening ports and programs.

Netstat syntax in Linux

$netstat-tulpn | grep LISTEN

Netstat syntax in FreeBSD/MacOS X

$netstat-anp tcp | grep LISTEN$ netstat-anp udp | grep LISTEN

Netstat syntax in OpenBSD

$netstat-na-f inet | grep LISTEN$ netstat-nat | grep LISTEN

You can also use this command in windows:

Netstat-bano | morenetstat-bano | grep LISTENINGnetstat-bano | findstr / R / C: "[LISTING]"

Mode 3:nmap command

The syntax is as follows:

$sudo nmap-sT-O localhost$ sudo nmap-sU-O 192.168.2.13 # list open UDP ports $sudo nmap-sT-O 192.168.2.13 # list open TCP ports

The sample output is as follows:

You can merge TCP/UDP scans with one command:

The above $sudo nmap-sTU-O 192.168.2.13 is how to use the command to fix the full content of the service status of linux. For more information related to how to use the command to fix the service status of linux, you can search the previous article or browse the following article to learn! I believe the editor will add more knowledge to you. I hope you can support it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report