今天進度 : How do I check if a port is in use on Linux? - nixCraft
學會如何查 port 的占用狀況
可以使用 /etc/services
root@test:~# cat /etc/services
# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, officially ports have two entries
# even if the protocol doesn't support UDP operations.
#
# Updated from https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml .
#
# New ports will be added on request if they have been officially assigned
# by IANA and used in the real-world or are needed by a debian package.
# If you need a huge list of used numbers please install the nmap package.
tcpmux 1/tcp # TCP port service multiplexer
echo 7/tcp
echo 7/udp
discard 9/tcp sink null
discard 9/udp sink null
systat 11/tcp users
daytime 13/tcp
daytime 13/udp
netstat 15/tcp
qotd 17/tcp quote
chargen 19/tcp ttytst source
chargen 19/udp ttytst source
...
但是單純使用資訊太多了,可以使用 grep -w {port}
篩選指定的 port
root@test:~# grep -w 80 /etc/services
http 80/tcp www # WorldWideWeb HTTP
只想查詢 tcp 跟 udp egrep -w '53/(tcp|udp)' /etc/services
root@test:~# egrep -w '53' /etc/services
domain 53/tcp # Domain Name Server
domain 53/udp
root@test:~# egrep -w '53/(tcp)' /etc/services
domain 53/tcp # Domain Name Server