- Published
- Author
- Nived HariSystem Analyst
If a port (say
Here,
So this command lists all processes that have files (or ports) open.
Example output:
Now you can see the PID (Process ID) of the program using the port.
To stop it, run:
The
If the process refuses to die, you can forcefully stop it with:
Here,
#unix
3000) is already in use, you can check what’s running on it with:Code
lsof -i :3000Here,
lsof stands for “List Open Files” — and in Unix/Linux, everything is a file, including network sockets.So this command lists all processes that have files (or ports) open.
Example output:
Code
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 1234 nived 22u IPv6 0x... 0t0 TCP *:3000 (LISTEN)Now you can see the PID (Process ID) of the program using the port.
To stop it, run:
Code
kill 1234The
kill command sends a signal to a process — by default, it’s SIGTERM (Signal Terminate), which politely asks the process to shut down.If the process refuses to die, you can forcefully stop it with:
Code
kill -9 1234Here,
-9 represents the SIGKILL (Signal Kill) — which immediately ends the process without cleanup.#unix