Thursday, June 25, 2026

How to list networking services in linux as like netstat in windows & How to kill the service runs in linux under some port identified with lsof

--https://share.google/aimode/RVHbh41MY76WY73lj

--https://share.google/aimode/4xIjIyRDB3MjeLU5b


To list networking services in Linux similarly to netstat in Windows, use the ss command. While netstat is historically available in Linux, it is now deprecated in favor of ss, which is significantly faster and pre-installed on all modern distributions. [1, 2, 3, 4, 5]
The Equivalent Commands
Windows Command [1, 2, 3]Modern Linux Equivalent (ss)Legacy Linux Equivalent (netstat)
netstat -anosudo ss -tulnpsudo netstat -tulnp
Command Options Breakdown
The specific flags used in the Linux commands mimic the behavior of Windows networking lookups:
  • -t: Displays TCP ports.
  • -u: Displays UDP ports.
  • -l: Shows only listening sockets (active services waiting for connections).
  • -n: Shows numerical addresses and port numbers (prevents slow DNS lookups).
  • -p: Shows the Process ID (PID) and the process name running the service. Note: Running this with sudo is required to see process ownership details. [1, 2, 3, 4]

Alternative: Using lsof
If you need to find a networking service bound to a highly specific port, the lsof (List Open Files) utility is a powerful alternative: [1, 2, 3]
bash
sudo lsof -i :80
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
(Replace 80 with the specific port number you want to investigate). [1]
If you would like to dive deeper, let me know:
  • Do you need to filter for a specific port or protocol?
  • Are you looking to track real-time changes to network connections?
  • Do you want to see how much bandwidth a specific service is using? [1]


To kill a Linux process running on a specific port found using lsof, execute the following command:
bash
sudo kill -9 $(sudo lsof -t -i :<PORT_NUMBER>)
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
Replace <PORT_NUMBER> with your actual port (e.g., 8080). [1, 2, 3]
1. The Two-Step Method
If you prefer to verify the process before terminating it, split the action into identification and deletion steps. [1]
Find the Process ID (PID) [1]
Run lsof to view the service name and its associated numerical PID: [1]
bash
sudo lsof -i :8080
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
  • -i :8080: Filters results specifically to network files operating on port 8080.
  • sudo: Forces the system to display processes owned by other users or system accounts. [1, 2]
Example Output:
text
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
node     3821 root   23u  IPv4  0x8a9    0t0  TCP *:8080 (LISTEN)
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
Kill the Process
Use the kill command along with the exact PID displayed in the second column of your lsof output: [1]
bash
sudo kill 3821
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
  • This sends a default SIGTERM signal, requesting a clean, safe shutdown.
  • If the process fails to close, force termination using sudo kill -9 3821, which sends a SIGKILL signal. [1, 2, 3]

2. The One-Liner Automation Method
To bypass manual PID lookups, combine lsof and kill into a single command string via shell substitution: [1, 2]
bash
sudo kill -9 $(sudo lsof -t -i :8080)
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
  • -t: Strips down the lsof output to return only raw PID numbers.
  • $(...): Feeds those exact numbers directly into the kill command as arguments. [1, 2, 3, 4]

3. Alternative Alternative: The fuser Shortcut
If lsof is unavailable, use the native fuser tool to close ports quickly without hunting down process numbers. [1, 2]
bash
sudo fuser -k 8080/tcp
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
  • -k: Instantly delivers a termination signal to every active process tied to the port.
  • 8080/tcp: Defines the port number alongside its designated transport protocol layer. Use 8080/udp if terminating a UDP port instead. [1, 2, 3]