linux下尋找連接埠號碼對應的服務名

來源:互聯網
上載者:User

linux下尋找連接埠號碼對應的服務名
根據連接埠號碼尋找對應的服務名 1)grep -w 連接埠號碼 /etc/services 2)grep "\b連接埠號碼\b" /etc/services 以2049連接埠為例,執行grep -w 2049 /etc/services或grep "\b2049\b" /etc/services  即可尋找到其對應的服務名為nfsgrep -w 2049 /etc/services    nfs             2049/tcp        nfsd shilp      # Network File Systemnfs             2049/udp        nfsd shilp      # Network File Systemnfs             2049/sctp       nfsd shilp      # Network File System# grep "\b2049\b" /etc/services     nfs             2049/tcp        nfsd shilp      # Network File Systemnfs             2049/udp        nfsd shilp      # Network File Systemnfs             2049/sctp       nfsd shilp      # Network File System 其中-w表示只顯示全字元合的列,即精確匹配;"\b"表示匹配一個字邊界,即字與空格間的位置。例如,“er\b”匹配“never”中的“er”,但不匹配“verb”中的“er”(若匹配“verb”中的“er”可使用"\B"進行非字邊界匹配)。 根據服務名尋找對應的連接埠號碼1)grep -w 服務名 /etc/services2)grep "\b服務名\b" /etc/services以nfs服務為例,執行grep -w nfs /etc/services 或grep "\bnfs\b"/etc/services即可尋找到其對應的連接埠號碼為2049# grep -w nfs /etc/services nfs             2049/tcp        nfsd shilp      # Network File Systemnfs             2049/udp        nfsd shilp      # Network File Systemnfs             2049/sctp       nfsd shilp      # Network File System# grep "\bnfs\b" /etc/services             nfs             2049/tcp        nfsd shilp      # Network File Systemnfs             2049/udp        nfsd shilp      # Network File Systemnfs             2049/sctp       nfsd shilp      # Network File System 其中-w表示只顯示全字元合的列,即精確匹配;"\b"表示匹配一個字邊界,即字與空格間的位置。\bnfs\b即為精確匹配nfs。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.