Interview Prep/Linux/Rapid-Fire Commands

Test whether a remote TCP port is reachable without telnet or nc.

BeginnerProductionRapid-Fire Commands
Answer
timeout 3 bash -c '</dev/tcp/db.internal/5432' && echo open || echo closed
curl -v telnet://db.internal:5432 --max-time 3

/dev/tcp is a bash feature, so it works in minimal images.

All Linux questions Roadmap: Linux

More on Rapid-Fire Commands