linux下查找端口号对应的服务名
2015-10-21 18:03
561 查看
根据端口号查找对应的服务名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 System
nfs 2049/udp nfsd shilp # Network File System
nfs 2049/sctp nfsd shilp # Network File System
# grep "\b2049\b" /etc/services
nfs 2049/tcp nfsd shilp # Network File System
nfs 2049/udp nfsd shilp # Network File System
nfs 2049/sctp nfsd shilp # Network File System其中-w表示只显示全字符合的列,即精确匹配;"\b"表示匹配一个字边界,即字与空格间的位置。例如,“er\b”匹配“never”中的“er”,但不匹配“verb”中的“er”(若匹配“verb”中的“er”可使用"\B"进行非字边界匹配)。
根据服务名查找对应的端口号1)grep -w 服务名 /etc/services
2)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 System
nfs 2049/udp nfsd shilp # Network File System
nfs 2049/sctp nfsd shilp # Network File System
# grep "\bnfs\b" /etc/services
nfs 2049/tcp nfsd shilp # Network File System
nfs 2049/udp nfsd shilp # Network File System
nfs 2049/sctp nfsd shilp # Network File System其中-w表示只显示全字符合的列,即精确匹配;"\b"表示匹配一个字边界,即字与空格间的位置。\bnfs\b即为精确匹配nfs。
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 System
nfs 2049/udp nfsd shilp # Network File System
nfs 2049/sctp nfsd shilp # Network File System
# grep "\b2049\b" /etc/services
nfs 2049/tcp nfsd shilp # Network File System
nfs 2049/udp nfsd shilp # Network File System
nfs 2049/sctp nfsd shilp # Network File System其中-w表示只显示全字符合的列,即精确匹配;"\b"表示匹配一个字边界,即字与空格间的位置。例如,“er\b”匹配“never”中的“er”,但不匹配“verb”中的“er”(若匹配“verb”中的“er”可使用"\B"进行非字边界匹配)。
根据服务名查找对应的端口号1)grep -w 服务名 /etc/services
2)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 System
nfs 2049/udp nfsd shilp # Network File System
nfs 2049/sctp nfsd shilp # Network File System
# grep "\bnfs\b" /etc/services
nfs 2049/tcp nfsd shilp # Network File System
nfs 2049/udp nfsd shilp # Network File System
nfs 2049/sctp nfsd shilp # Network File System其中-w表示只显示全字符合的列,即精确匹配;"\b"表示匹配一个字边界,即字与空格间的位置。\bnfs\b即为精确匹配nfs。
相关文章推荐
- Linux socket 初步
- linux lsof详解
- linux 文件权限
- Linux 执行数学运算
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- Ubuntu Linux使用体验
- c语言实现hashmap(转载)
- Linux 信号signal处理机制
- linux下mysql添加用户
- Scientific Linux 5.5 图形安装教程
- 基于 Linux 集群环境上 GPFS 的问题诊断
- 谁是桌面王者?Win PK Linux三大镇山之宝
- vivi下重新调整分区