Looking up Ports by Service Name

If wonder what ports are the default for a given service, you can look them up by inspecting the /etc/services file which is present on most Unix systems, including macOS. E.g. if you wonder which port is the default for SSH, you can do:

$ grep -w ssh /etc/services 
ssh                22/tcp
ssh                22/udp
ssh                22/sctp
..

The other way works too. Say you wonder which services are related to 389 and 636, you can do:

$ egrep -w '389|636' /etc/services 
ldap              389/tcp
ldap              389/udp
ldaps             636/tcp
ldaps             636/udp

I find having /etc/services at my fingertips extremely useful, hope you do too!


~ /home 🏠 ~ talks 💬 ~ bash ~ craftsmanship ~ db ~ dongxi ~ emacs ~ escenic ~ iam ~ java ~ js ~ language ~ latex ~ ldap ~ life ~ linux ~ llm ~ mac-os-x ~ mt-foo ~ network ~ norsk ~ python ~ quotes ~ running ~ security ~ travel ~ unix ~ various ~ vcs ~ webdesign ~ windows ~ discoveries ~ cv 🧙 ~

Licensed under CC BY Creative Commons License ~ 📡 RSS feed ~ ✉ torstein.k.johansen @ gmail ~ 🐘 @skybert@hachyderm.io ~ 🎥 youtube.com/@skybert