How do I view open ports on linux
- User
How do I view open ports on linux
Assistant
Here are a few ways to view open ports on Linux:
- netstat -tunlp
The netstat command shows all active connections and listening ports. The options used here show TCP ports (-t), UDP ports (-u), numeric output (-n), listening ports (-l), and the process/program using each port (-p).
- ss -tunlp
The ss command does something similar to netstat. The options have the same meanings.
- lsof -i
The lsof command lists open files and connections. The -i option shows only network connections.
- nmap localhost
Nmap is a network scanning and discovery tool. Running it on localhost scans your own machine. It will list all open ports and associated services.
- tcpdump tcp or udp
Tcpdump prints out network traffic. The tcp or udp options lets you select only TCP or UDP traffic to view. This can show connections on open ports.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.