In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to find the port name and port number in the Linux system. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Method 1: use the grep command to use the grep command to find the default port number for the specified service in Linux, simply run:
$grep / etc/services for example, to find the default port for the SSH service, simply run:
$grep ssh / etc/services is that simple. This command should apply to most Linux distributions. The following is a sample output from my Arch Linux test machine:
Ssh 22/tcp ssh 22/udp ssh 22/sctp sshell 614/tcp sshell 614/udp netconf-ssh 830/tcp netconf-ssh 830/udp sdo-ssh 3897/tcp sdo-ssh 3897/udp netconf-ch-ssh 4334/tcp snmpssh 5161/tcp snmpssh-trap 5162/tcp tl1-ssh 6252/tcp tl1-ssh 6252/udp ssh-mgmt 17235/tcp ssh-mgmt 17235/udp as you can see in the output above, the default port number for the SSH service is 22.
Let's find the port number of the Apache Web server. To do this, the command is:
$grep http / etc/services # http://www.iana.org/assignments/port-numbers http 80/tcp www www-http # WorldWideWeb HTTP http 80/udp www www-http # HyperText Transfer Protocol http 80/sctp # HyperText Transfer Protocol https 443/tcp # http protocol over TLS/SSL https 443/udp # http protocol over TLS/SSL https 443/sctp # http protocol over TLS/SSL gss-http 488/tcp gss-http 488/udp webcache 8080/tcp http-alt # WWW caching service webcache 8080/udp http-alt # WWW caching What is the port number of service [...] FTP? There's nothing to it!
$grep ftp / etc/services ftp-data 20/tcp ftp-data 20/udp # 21 is registered to ftp, but also used by fsp ftp 21/tcp ftp 21/udp fsp fspd tftp 69/tcp [...] Method 2: use the getent command, as you can see, the above command displays all port names and numbers for the specified search words "ssh", "http" and "ftp". This means that you will get a fairly long output of all port names that match a given search term.
However, you can use the getent command to output the exact result, as shown below:
$getent services ssh ssh 22/tcp $getent services http http 80/tcp www www-http $getent services ftp ftp 21/tcp if you don't know the port name, but you do know the port number, you just need to replace the port name with a number:
$getent services 80 http 80/tcp to display all port names and port numbers, simply run:
$getent services method 3: using the Whatportis program Whatportis is a simple Python script to find the port name and port number. Unlike the above command, this program is output in beautiful tabular form.
Make sure that the pip package manager is installed. If not, please refer to the link below.
How to use pip to manage Python packages
After installing pip, run the following command to install the Whatportis program.
$pip install whatportis you can now find the port associated with the service, as shown below.
Sample output of $whatportis ssh $whatportis ftp $whatportis http my CentOS 7 server:
Look up the port number of the service in Linux
If you don't know the exact name of the service, use the-like flag to display the results.
Whatportis mysql-- like the above command to help you find the port associated with the service. You can also find services associated with the port number, as shown below.
Whatportis 993 you can even display the results in JSON format.
$whatportis 993-json
This is the end of the article on "how to find port names and port numbers in the Linux system". 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, please 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.