Mac
sudo lsof -iTCP -sTCP:LISTEN
Linux
List used ports
$netstat -tulpn | grep LISTEN
tcp 0 0 127.0.0.1:5939 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp6 0 0 :::80 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:631 :::* LISTEN -
List process that using port
You like to knows who is using port 80, then
$sudo lsof -i :80
apache2 965 root 4u IPv6 26650 0t0 TCP *:http (LISTEN)
apache2 13794 www-data 4u IPv6 26650 0t0 TCP *:http (LISTEN)
apache2 13795 www-data 4u IPv6 26650 0t0 TCP *:http (LISTEN)
apache2 13796 www-data 4u IPv6 26650 0t0 TCP *:http (LISTEN)
apache2 13797 www-data 4u IPv6 26650 0t0 TCP *:http (LISTEN)
apache2 13798 www-data 4u IPv6 26650 0t0 TCP *:http (LISTEN)
Second option
$sudo netstat -peanut | grep ":80"
tcp6 0 0 :::80 :::* LISTEN 0 26650 965/apache2
Setting apache
$vi /etc/apache2/apache2.conf
# /etc/apache2/
# |-- apache2.conf
# | `-- ports.conf
# |-- mods-enabled
# | |-- *.load
# | `-- *.conf
# |-- conf-enabled
# | `-- *.conf
# `-- sites-enabled
# `-- *.conf