[linux下查找端口号对应的服务名] linux 进程对应端口号

linux命令在系统中有两种类型:内置Shell命令和Linux命令。那么你知道linux下查找端口号对应服务名么?接下来是小编为大家收集的linux下查找端口号对应服务名,欢迎大家阅读:

linux下查找端口号对应服务名。

1)grep —w 端口号 /etc/services。

2)grep "\b端口号\b" /etc/services。

以2049端口为例,执行grep —w 2049 /etc/services或grep "\b2049\b" /etc/services 即可查找到其对应服务名为nfs。

grep —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下查找端口号对应服务名还想看:

1.linux有什么常见服务端口

2.LINUX的端口服务有什么关系。

3.Linux常用网络服务端口

4.LINUX操作系统如何修改的端口

5.Linux中的Apache服务查看和启动的方法。

0 次访问