Identifying TCP and UDP sockets
Use the lsof command, a variant of the netstat -af command to identify TCP sockets that are in the LISTEN state and idle UDP sockets that are waiting for data to arrive.
For example, to display the TCP sockets in the LISTEN
state and the UDP sockets in the IDLE state, run the lsof command
as follows:
# lsof -i | egrep "COMMAND|LISTEN|UDP"The output produced is similar to the following:
| Command | PID | USER | FD | TYPE | DEVICE | SIZE/OFF | NODE | NAME |
|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
After identifying the process ID, you can obtain more information
about the program by running the following command:
" # ps -fp PID#"The output contains the path to the command name, which you can use to access the program's man page.