Quick Linux Tip #26:
Try: sudo lsof -iTCP:3306 -sTCP:ESTABLISHED
Info: lsof -iTCP:PORT lists active network connections on a port. -sTCP:ESTABLISHED filters out listening sockets to show active connections only.
Examples:
- $ sudo lsof -iTCP:80 -sTCP:LISTEN # Active listeners on port 80
- $ sudo lsof -i @192.168.1.100 # Filter by remote IP
- $ sudo lsof -Pn -iTCP:3306 # Fast mode (no DNS or port resolution)
Note: lsof can be slow on busy servers because it resolves hostnames and port names by default. Add -Pn to disable resolution for instant output. Common states: LISTEN, ESTABLISHED, TIME_WAIT.
Follow @LinuxTeck for more #LinuxTips
Leave a Reply