Skip to content

How to check if port is in use

lsof command

Bash
1
2
3
4
5
6
7
8
$> sudo lsof -i -P -n
$> sudo lsof -i -P -n | grep LISTEN

# Output Example
# --------------------------------------------------------------------------
# app  process_id  user  _  ip_protocol  _      _  protocol  bind_addr:port
# --------------------------------------------------------------------------
# sshd   85379    root  3u    IPv4     0xffff  0t0  TCP 10.86.128.138:22 (LISTEN)

netstat command

Bash
1
2
3
4
5
6
7
# deprecated
netstat -tulpn | grep LISTEN

# in place of netstat
sudo ss -tulw
sudo ss -tulwn
sudo ss -tulwn | grep LISTEN

View Internet network services list

Bash
less /etc/services