国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

在Linux中查看進程占用的端口號

2019-11-02 14:13:35
字體:
來源:轉載
供稿:網友

對于 Linux 系統管理員來說,清楚某個服務是否正確地綁定或監聽某個端口,是至關重要的。如果你需要處理端口相關的問題,這篇文章可能會對你有用。

端口是 Linux 系統上特定進程之間邏輯連接的標識,包括物理端口和軟件端口。由于 Linux 操作系統是一個軟件,因此本文只討論軟件端口。軟件端口始終與主機的 IP 地址和相關的通信協議相關聯,因此端口常用于區分應用程序。大部分涉及到網絡的服務都必須打開一個套接字來監聽傳入的網絡請求,而每個服務都使用一個獨立的套接字。

套接字是和 IP 地址、軟件端口和協議結合起來使用的,而端口號對傳輸控制協議(TCP)和用戶數據報協議(UDP)協議都適用,TCP 和 UDP 都可以使用 0 到 65535 之間的端口號進行通信。

以下是端口分配類別:

0 - 1023: 常用端口和系統端口 1024 - 49151: 軟件的注冊端口 49152 - 65535: 動態端口或私有端口

在 Linux 上的 /etc/services 文件可以查看到更多關于保留端口的信息。

# less /etc/services# /etc/services:# $Id: services,v 1.55 2013/04/14 ovasik Exp $# Network services, Internet style# IANA services version: last updated 2013-04-10# Note that it is presently the policy of IANA to assign a single well-known# port number for both TCP and UDP; hence, most entries here have two entries# even if the protocol doesn't support UDP operations.# Updated from RFC 1700, ``Assigned Numbers'' (October 1994). Not all ports# are included, only the more common ones.# The latest IANA port assignments can be gotten from# http://www.iana.org/assignments/port-numbers# The Well Known Ports are those from 0 through 1023.# The Registered Ports are those from 1024 through 49151# The Dynamic and/or Private Ports are those from 49152 through 65535# Each line describes one service, and is of the form:# service-name port/protocol [aliases ...] [# comment]tcpmux 1/tcp # TCP port service multiplexertcpmux 1/udp # TCP port service multiplexerrje 5/tcp # Remote Job Entryrje 5/udp # Remote Job Entryecho 7/tcpecho 7/udpdiscard 9/tcp sink nulldiscard 9/udp sink nullsystat 11/tcp userssystat 11/udp usersdaytime 13/tcpdaytime 13/udpqotd 17/tcp quoteqotd 17/udp quotemsp 18/tcp # message send protocol (historic)msp 18/udp # message send protocol (historic)chargen 19/tcp ttytst sourcechargen 19/udp ttytst sourceftp-data 20/tcpftp-data 20/udp# 21 is registered to ftp, but also used by fspftp 21/tcpftp 21/udp fsp fspdssh 22/tcp # The Secure Shell (SSH) Protocolssh 22/udp # The Secure Shell (SSH) Protocoltelnet 23/tcptelnet 23/udp# 24 - private mail systemlmtp 24/tcp # LMTP Mail Deliverylmtp 24/udp # LMTP Mail Delivery

可以使用以下六種方法查看端口信息。

ss:可以用于轉儲套接字統計信息。 netstat:可以顯示打開的套接字列表。 lsof:可以列出打開的文件。 fuser:可以列出那些打開了文件的進程的進程 ID。 nmap:是網絡檢測工具和端口掃描程序。 systemctl:是 systemd 系統的控制管理器和服務管理器。

以下我們將找出 sshd 守護進程所使用的端口號。

方法 1:使用 ss 命令

ss 一般用于轉儲套接字統計信息。它能夠輸出類似于 netstat 輸出的信息,但它可以比其它工具顯示更多的 TCP 信息和狀態信息。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 渭南市| 利辛县| 丰宁| 榆树市| 荔波县| 祁连县| 泾川县| 武冈市| 博爱县| 合水县| 泰宁县| 连州市| 博白县| 舟山市| 清远市| 枞阳县| 关岭| 嘉善县| 南召县| 偃师市| 浦东新区| 旺苍县| 龙口市| 探索| 广安市| 嘉荫县| 米脂县| 驻马店市| 平武县| 鄂伦春自治旗| 盐池县| 五河县| 安义县| 库车县| 抚远县| 革吉县| 无为县| 华坪县| 临泉县| 平潭县| 定结县|