Linux commands: Difference between revisions

Jump to navigation Jump to search
77 bytes added ,  18 December 2025
m
 
Line 294: Line 294:


'''Kill the process by port number'''<ref>[https://stackoverflow.com/questions/11583562/how-to-kill-a-process-running-on-particular-port-in-linux How to kill a process running on particular port in Linux? - Stack Overflow], [https://linux.die.net/man/8/lsof lsof(8) - Linux man page]</ref>
'''Kill the process by port number'''<ref>[https://stackoverflow.com/questions/11583562/how-to-kill-a-process-running-on-particular-port-in-linux How to kill a process running on particular port in Linux? - Stack Overflow], [https://linux.die.net/man/8/lsof lsof(8) - Linux man page]</ref>
* {{kbd | key=<nowiki>kill -9 $(lsof -ti:3000) 2>/dev/null</nowiki>}} - Force kill the process using port 3000. Replace 3000 with your target port number.
* {{kbd | key=<nowiki>kill -9 $(lsof -ti:3000) 2>/dev/null</nowiki>}}: Force kill the process using port 3000. The {{kbd | key=2>/dev/null}} suppresses error messages if no process is found. Replace 3000 with your target port number.
* Alternative (shorter command): {{kbd | key=fuser -k 3000/tcp}} - Kill the process using TCP port 3000 (if {{kbd | key=fuser}} is available on your system)
* Alternative (shorter command): {{kbd | key=fuser -k 3000/tcp}}: Kill the process using TCP port 3000 (if {{kbd | key=fuser}} is available on your system)


Explanation:
Explanation:
* {{kbd | key=<nowiki>lsof -ti:3000</nowiki>}} - Find the process ID (PID) using port 3000
* {{kbd | key=<nowiki>lsof -ti:3000</nowiki>}}: Find the process ID (PID) using port 3000
** {{kbd | key=-t}}: Output only the PID
** {{kbd | key=-t}}: Output only the PID
** {{kbd | key=-i:3000}}: Filter by port 3000
** {{kbd | key=-i:3000}}: Filter by port 3000

Navigation menu