In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to check the list of open ports in Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
There are few utilities in Linux for this purpose. However, I provide the four most important Linux commands to check this out.
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
Netstat, short for 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.
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-tplugn Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program nametcp 0 0 0.0.0.0 only servers 25 0.0.0.0 LISTEN 2038/mastertcp 0 0 127.0.0.1 VR 199 0.0.0.0 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 1396/snmpdudp 56130 0.0.0.0 1396/snmpdudp * 1396/snmpdudp 40105 0.0.0.0 1396/snmpdudp * 1396/snmpdudp 0 0.0.0.0 1396/snmpdudp 0 0 0 1396/snmpdudp 30105 0 0 0 1396/snmpdudp * 0 0 0 50 656 0 0 0 V * 0 0 0 1396/snmpdudp 0 0 0.0.0.0 1396/snmpdudp 28265 0.0.0.0 1396/snmpdudp 0 0 10.90.56 .21 123 0.0.0.0 * 895/ntpdudp 0 0127.0.0.1 123 0.0.0.0 * 895/ntpdudp 00 0.0.0.012 0.0.0.015 * 895/ntpdudp 0 0 0 895/ntpdudp 53390 0 0 0. 0 1396/snmpdudp6 0:: 123: :: * 895/ntpd IPv6/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: 22 tcp 00 0.0.0.0 grep * LISTEN 1388/sshdtcp6 0 0:: 22: * how does LISTEN 1388/sshd 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-lntu Netid 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 to use the Linux command nmap to check the list of open ports in the system?
Nmap ("Network Mapper") is an open source tool for network exploration and security audit. It is designed to quickly scan large networks, but it can also work on stand-alone hosts.
Nmap uses naked IP packets in a novel way to determine which hosts are available on the network, what services they provide (application name and version), what operating system (version) they run, what type of data * filters / firewalls are used, and many other features.
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 localhost Starting 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 ports PORT STATE SERVICE22/tcp open ssh25/tcp open smtp80/tcp open http199/tcp open smux123/udp open ntp161/udp open snmp Device type: general purposeRunning: Linux 3.XOS CPE: cpe:/o: Linux:linux_kernel:3OS details: Linux 3.7-3.9Network Distance: 0 hops OS 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 123 123/udp open ntp how to 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-i COMMAND 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-iroot 80 COMMAND 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) Thank you for reading! This is the end of the article on "how to check the list of open ports in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.