How do I see sockets in Linux?
Michael Henderson
Published Feb 28, 2026
How do I see sockets in Linux?
Linux netstat syntax
- -t : Show only TCP sockets on Linux.
- -u : Display only UDP sockets on Linux.
- -l : Show listening sockets. For example, TCP port 22 is opened by SSHD server.
- -p : List process name that opened sockets.
- -n : Don’t resolve service names i.e. don’t use DNS.
How do you check socket is connected or not?
If you need to determine the current state of the connection, make a nonblocking, zero-byte Send call. If the call returns successfully or throws a WAEWOULDBLOCK error code (10035), then the socket is still connected; otherwise, the socket is no longer connected.
How do I check if a socket is open Linux?
Open a Linux terminal application. Use ss command to display all open TCP and UDP ports in Linux. Another option is to use the netstat command to list all ports in Linux. Apart from ss / netstat one can use the lsof command to list open files and ports on Linux based system.
How check TCP connection in Linux?
netstat command: It can display network connections, routing tables, interfaces and much more. tcptrack and iftop commands: Displays information about TCP connections it sees on a network interface and display bandwidth usage on an interface by host respectively.
What is Socat command in Linux?
Socat is a command line based utility that establishes two bidirectional byte streams and transfers data between them. In the init phase, the command line options are parsed and logging is initialized. During the open phase, socat opens the first address and afterwards the second address.
How do I check if port 443 is open Linux?
How to check if a port is in use on Linux
- Open the terminal application on Linux.
- Type any one of the following command to check if a port is in use on Linux. sudo lsof -i -P -n | grep LISTEN.
- Search for the TCP or UDP port description in /etc/services file on Linux: grep -E -w ‘PORT_NUMBER_HERE/(tcp|udp)’ /etc/services.
How is socket connected?
A socket is one endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent to. An endpoint is a combination of an IP address and a port number.
What is So_error?
SO_ERROR. gets the error status of the socket. The TCP/IP software maintains an errno value (the SO_ERROR field on a UNIX operating system) for each socket. The SO_ERROR option obtains and then clears this field, which is useful when checking for errors that occur between socket calls.
How do I check if a port is open on a remote server Linux?
5 ways to Check a remote port is open in Linux
- Use nc command nc -zvw10 192.168.0.1 22.
- Use nmap command nmap 192.168.0.1 -p 22.
- Use telnet command telnet 192.168.0.1 22.
- Use python telnet module.
- Use python socket module.
How do I test TCP port connectivity?
Press the Windows key + R, then type “cmd.exe” and click OK. Enter “telnet + IP address or hostname + port number” (e.g., telnet 1723 or telnet 10.17. xxx. xxx 5000) to run the telnet command in Command Prompt and test the TCP port status.
What is replacing netstat?
Formally, ss is the socket statistics command that replaces netstat .
What is netcat and socat?
Very (very, very) simply put, netcat is a telnet that you can use in scripts. Plus is can be used as a simple listener if you want. And yes socat can do more stuff than netcat, but to verify whether it is a superset, you need to compare command line options.