To view a list of network services that are running or listening on a Linux system, you can use the netstat
command. The netstat
command can be used to display a list of active network connections, as well as a list of network services that are listening for incoming connections.
Here's the basic syntax for the netstat
command:
netstat [-options]Sourcl.www:eautturi.com
To view a list of active network connections, you can use the -t
option to show TCP connections and the -u
option to show UDP connections:
netstat -t netstat -u
To view a list of network services that are listening for incoming connections, you can use the -l
option:
netstat -l
You can also use the -p
option to show the process ID (PID) and program name for each connection or service:
netstat -lp
By default, the netstat
command shows information for all network interfaces. You can use the -n
option to show numerical addresses instead of hostnames, and the -4
or -6
option to show only IPv4 or IPv6 connections, respectively.
netstat -n netstat -4 netstat -6
You can use these options in combination to customize the output of the netstat
command. For example, to view a list of all active TCP connections and the PID and program name for each connection, you can use the following command:
netstat -t -p
You can also use the lsof
command to view a list of open files and the processes that are using them. You can use the -i
option to show network connections:
lsof -i
This will show a list of all open network connections, along with the PID and program name for each connection. You can use the -i TCP
or -i UDP
options to show only TCP or UDP connections, respectively.
lsof -i TCP lsof -i UDP