In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to check the list of open ports on the local system in Linux, I believe most people do not know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it together.
You can use the following four commands to finish the job. These commands are well known and are widely used by Linux administrators.
Netstat:netstat ("network statistics") is a command line tool that displays information about network connections (inbound and outbound), such as routing tables, camouflage connections, multicast members, and network ports.
Nmap:Nmap ("Network Mapper") is an open source tool for network exploration and security audit. It is designed to quickly scan large networks.
Ss: ss is used to dump socket statistics. It can also be used similar to netstat. It can display more TCP status information than other tools.
Lsof: lsof is the abbreviation of List Open File. It is used to output all files opened by a process.
How to use the Linux command netstat to check the list of open ports in a system
It lists all tcp, udp connections, and all unix socket connections.
It is used to discover network problems and determine the number of network connections.
Netstat-tplugnActive Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program nametcp 0 0 0.0.0.0 Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program nametcp 25 0.0.0.0 only servers * LISTEN 2038/mastertcp 0 0 127.0.1 VR 199 0.0.0.0 Vol * LISTEN 1396/snmpdtcp 0 0 0 LISTEN 1388/sshdtcp6 80 0: 0 0 0. 0 LISTEN 1388/sshdtcp6 0 0:: 25:: * LISTEN 2038/mastertcp6 0 0: 22: * LISTEN 1388/sshdudp 0 0 0.0.0.0 1396/snmpdudp 39136 0.0.0.0 1396/snmpdudp 00 0.0.0.0 1396/snmpdudp 56130 0 .0.0.0: * 1396/snmpdudp 0 0 0.0.0.0 1396/snmpdudp 40105 0.0.0.0 1396/snmpdudp 0 0 0.0.0.0 30105 0.0.0.0 * 1396/snmpdudp 0 0 0.0.0.0.015 0656 0.0.0.015 * 1396/snmpdudp 0 0 0.0.0.015 1632 0.0.0.0 * 1396/snmpdudp 0 0 0.0.0.0 1396/snmpdudp 28265 0.0.0.0 1396/snmpdudp 0 010.90.56.21 : 123 0.0.0.0 895/ntpdudp * 0127.0.0.1 123 0.0.0.0 * 895/ntpdudp 00 0.0.0.012 0.0.0.015 * 895/ntpdudp 00 0.0.0.0 1396/snmpdudp6 53390 0.0.0.0 1396/snmpdudp6 0:: 123:: * 895/ntpdIPv6/IPv4 Group MembershipsInterface RefCnt Group- lo 1 224.0.0.1eth0 1 224.0.0.1lo 1 ff02::1lo 1 ff01::1eth0 1 ff02::1eth0 1 ff01::1
You can also use the following command to check specific ports.
# # netstat-tplugn | grep: 22tcp 0 0 0.0 0 22tcp 22 0 0 0 LISTEN 1388/sshdtcp6 0: 22:: * LISTEN 1388/sshd
How do I use the Linux command ss to check the list of open ports in the system?
Ss is used to dump socket statistics. It can also display information similar to netstat. It can display more TCP status information than other tools.
# ss-lntuNetid State Recv-Q Send-Q Local Address:Port Peer Address:Portudp UNCONN 0 0 *: 39136 *: * udp UNCONN 0 0 *: 56130 *: * udp UNCONN 0 0 *: 40105 *: * udp UNCONN 0 0 *: 11584 *: * udp UNCONN 0 0 *: 30105 *: * udp UNCONN 0 0 *: 50656 *: * udp UNCONN 0 *: 1632 *: * udp UNCONN 0 0 *: 28265 *: * udp UNCONN 0 0 *: 40764 *: * udp UNCONN 0 0 10.90.56.21 *: * udp UNCONN 0 0127.0.0.1 123 *: * udp UNCONN 0 0 *: 123 *: * udp UNCONN 0 0 *: 53390 *: * udp UNCONN 0 0 *: 161 *: * udp UNCONN 00: 123: * tcp LISTEN 0 100 *: 25 *: * tcp LISTEN 0 128 127.0.0.1 199 *: * tcp LISTEN 0 128 *: 80 *: * Tcp LISTEN 0 128 *: 22 *: * tcp LISTEN 0 100: 25: * tcp LISTEN 0 128:: 22:: *
You can also use the following command to check specific ports.
# # ss-lntu | grep': 25'tcp LISTEN 0100 *: 25 *: * tcp LISTEN 0100: 25:: *
How do I use the Linux command nmap to check the list of open ports in the system?
Although Nmap is commonly used for security audits, many system and network administrators find it useful for day-to-day tasks such as network inventory, managing service upgrade plans, and monitoring host or service uptime.
Nmap-sTU-O localhostStarting Nmap 6.40 (http://nmap.org) at 2019-03-20 09:57 CDTNmap scan report for localhost (127.0.0.1) Host is up (0.00028s latency) .Other addresses for localhost (not scanned): 127.0.0.1Not shown: 1994 closed portsPORT STATE SERVICE22/tcp open ssh25/tcp open smtp80/tcp open http199/tcp open smux123/udp open ntp161/udp open snmpDevice type: general purposeRunning: Linux 3.XOS CPE: cpe:/o:linux:linux_ Kernel:3OS details: Linux 3.7-3.9Network Distance: 0 hopsOS detection performed. Please report any incorrect results at http://nmap.org/submit/ .nmap done: 1 IP address (1 host up) scanned in 1.93 seconds
You can also use the following command to check specific ports.
Nmap-sTU-O localhost | grep 123123/udp open ntp
How do I use the Linux command lsof to check the list of open ports in the system?
It shows you a list of open files on the system and the process of opening them. Other information related to the file will also be displayed to you.
# lsof-iCOMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEntpd 895 ntp 16u IPv4 18481 0t0 UDP *: ntpntpd 895 ntp 17u IPv6 18482 0t0 UDP *: ntpntpd 895 ntp 18u IPv4 18487 0t0 UDP localhost:ntpntpd 895 ntp 20u IPv4 23020 0t0 UDP CentOS7.2daygeek.com:ntpsshd 1388 root 3u IPv4 20065 0t0 TCP *: ssh (LISTEN) sshd 1388 root 4U IPv6 20067 0t0 TCP *: ssh (LISTEN) snmpd 1396 root 6u IPv4 22739 0t0 UDP *: snmpsnmpd 1396 root 7u IPv4 22729 0t0 UDP *: 40105snmpd 1396 root 8u IPv4 22730 0t0 UDP *: 50656snmpd 1396 root 9u IPv4 22731 0t0 UDP *: pammratcsnmpd 1396 root 10u IPv4 22732 0t0 UDP *: 30105snmpd 1396 root 11u IPv4 22733 0t0 UDP *: 40764snmpd 1396 root 12u IPv4 22734 0t0 UDP *: 53390snmpd 1396 root 13U IPv4 22735 0t0 UDP *: 28265snmpd 1396 root 14u IPv4 22736 0t0 UDP *: 11584snmpd 1396 root 15u IPv4 22737 0t0 UDP *: 39136snmpd 1396 root 16u IPv4 22738 0t0 UDP *: 56130snmpd 1396 root 17u IPv4 22740 0t0 TCP localhost:smux (LISTEN) httpd 1398 root 3u IPv4 20337 0t0 TCP *: http (LISTEN) master 2038 root 13u IPv4 21638 0t0 TCP *: smtp (LISTEN) master 2038 root 14u IPv6 21639 0t0 TCP *: smtp (LISTEN) sshd 9052 root 3u IPv4 1419955 0t0 TCP CentOS7.2daygeek.com:ssh- > Ubuntu18-04.2daygeek.com:11408 (ESTABLISHED) httpd 13371 apache 3u IPv4 20337 0t0 TCP *: http (LISTEN) httpd 13372apache 3u IPv4 20337 0t0 TCP *: http (LISTEN) httpd 13373 apache 3u IPv4 20337 0t0 TCP *: http (LISTEN) httpd 13374 apache 3U IPv4 20337 0t0 TCP *: http (LISTEN) httpd 13375 apache 3u IPv4 20337 0t0 TCP *: http (LISTEN)
You can also use the following command to check specific ports.
# lsof-i:80COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEhttpd 1398 root 3U IPv4 20337 0t0 TCP *: http (LISTEN) httpd 13371 apache 3u IPv4 20337 0t0 TCP *: http (LISTEN) httpd 13372 apache 3u IPv4 20337 0t0 TCP *: http (LISTEN) httpd 13373 apache 3u IPv4 20337 0t0 TCP *: http (LISTEN) httpd 13374 apache 3u IPv4 20337 0t0 TCP *: http (LISTEN) httpd 13375 apache 3u IPv4 20337 0t0 TCP *: http (LISTEN) these are all the contents of the article "how to check the list of open ports on a local system in Linux" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.