Search this site
Embedded Files
intdescod
  • Home
  • My Note
    • Linux
    • Node js
    • Docker
    • PostgreSQL
    • Hadoop
    • Python
    • JavaScript
    • Express
    • ShellScript
    • Github
    • Next js
    • Node-Red
  • Full Projects
    • bot_telegram
  • About me
intdescod
  • Home
  • My Note
    • Linux
    • Node js
    • Docker
    • PostgreSQL
    • Hadoop
    • Python
    • JavaScript
    • Express
    • ShellScript
    • Github
    • Next js
    • Node-Red
  • Full Projects
    • bot_telegram
  • About me
  • More
    • Home
    • My Note
      • Linux
      • Node js
      • Docker
      • PostgreSQL
      • Hadoop
      • Python
      • JavaScript
      • Express
      • ShellScript
      • Github
      • Next js
      • Node-Red
    • Full Projects
      • bot_telegram
    • About me

list contents

Linux

PORT

Checking Open Ports in Linux

1. Using `netstat` command


sudo netstat -tulnp


- `-t` - show TCP ports

- `-u` - show UDP ports

- `-l` - show listening ports

- `-n` - show numeric addresses instead of resolving hostnames

- `-p` - show the process using the port


2. Using `ss` command (modern replacement for netstat)


sudo ss -tulnp


Same options as netstat, but generally faster.


3. Using `lsof` command


sudo lsof -i -P -n | grep LISTEN

- `-i` - show network connections

- `-P` - show port numbers instead of service names

- `-n` - show numeric addresses


4. Checking specific port status


sudo lsof -i :22  # Check if port 22 is open



5. Using `nmap` (for scanning from another machine)


nmap -sT -O localhost


Or to scan a remote host:


nmap target-ip-address



6. Checking firewall status (if ports are blocked)


sudo iptables -L -n -v  # For iptables

sudo ufw status verbose  # For UFW (Ubuntu)

sudo firewall-cmd --list-all  # For firewalld (RHEL/CentOS/Fedora)



Note that you'll typically need root privileges (using sudo) to see all open ports and the processes using them.

Kill a Process Using a Specific Port in Linux

For port 3000 as an example:


sudo kill $(sudo lsof -t -i:3000)


Or more forcefully:


sudo kill -9 $(sudo lsof -t -i:3000)



Google Sites
Report abuse
Page details
Page updated
Google Sites
Report abuse