Find the service name corresponding to the port number in linux

Source: Internet
Author: User
Tags nfsd

Find the service name corresponding to the port number in linux
Search for the corresponding service name 1) grep-w port number/etc/services 2) grep "\ B port number \ B"/etc/services. Port 2049 is used as an example, run grep-w 2049/etc/services or grep "\ b2049 \ B"/etc/services to find the corresponding service named 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 where-w indicates that only columns with full-word matching are displayed, that is, exact match; "\ B" indicates matching a word boundary, that is, the position between the word and the space. For example, "er \ B" matches "er" in "never ", but it does not match "er" in "verb" (if it matches "er" in "verb", "\ B" can be used for non-word boundary matching ). Find the corresponding port number based on the service name. 1) grep-w service name/etc/services2) grep "\ B service name \ B"/etc/services. The nfs service is used as an example, run grep-w nfs/etc/services or grep "\ bnfs \ B"/etc/services to find the corresponding port number 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 where-w indicates that only the columns that match the full word are displayed, that is, exact match; "\ B" indicates matching a word boundary, that is, the position between the word and the space. \ Bnfs \ B exactly matches nfs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.