How To Check Which Port Is Listern or Open on Linux
September 12th, 2008 | Tags: Linux, lsof, netstat, network, nmap, SSH, telnet
For some security reason you may configure SSH or any other protocol using different kind of port number on Linux server. Sometimes it’s important to know which ports are actually listern or open to the system network, it may open for network instruction or hacking.
Basically there are few methods to see which ports are open on Linux.
Option 1:
Check /etc/services file
planetmy:/ # cat /etc/services | grep xxx (xxx = port number)
If the command return no output mean no port configure to listen on the particular port number. For port SSH/22, you should be able to see:
ssh 22/tcp # SSH Remote Login Protocol
ssh 22/udp # SSH Remote Login Protocol
Option 2:
Use netstat command - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
planetmy:/ # netstat -nan | grep 22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 7110/sshd
If the command output return ‘LISTEN’, mean the particular port is open or listen on network.
Option 3:
use lsof command - list open files
planetmy:/ # lsof -i -n -P|grep 631
cupsd 17934 lp 0u IPv4 56540196 TCP *:631 (LISTEN)
cupsd 17934 lp 2u IPv4 56540197 UDP *:631
Read the rest of this entry »
Possibly Related Posts:
- SSH Remote Access Authentication Tips
- Your Password is Disclose
- Ask Google Engineer a Questions
- Fedora 10 Artwork
- Set a Good Password Policy On SuSE Linux
