I am trying to kill a process in the command line for a specific port in ubuntu.
If I run this command I get the port:
sudo lsof -t -i:9001
You may also use fuser to do that (sends SIGKILL by default):
sudo fuser -k 9001/tcp
Use killport command :
sh killport 9001
To Download shell ,you can use wget
:
wget https://cdn.rawgit.com/abdennour/miscs.sh/e0aac343/killport
Use the command
netstat -plten |grep java
used grep java as tomcat uses java as their processes.
It will show the list of processes with port number and process id
tcp6 0 0 :::8080 :::* LISTEN
1000 30070621 16085/java
the number before /java is a process id. Now use kill command to kill the process
kill -9 16085
-9 implies the process will be killed forcefully.
you can work this using node
npm install freethenport -g
then
node freethenport 9001
Displays active TCP connections, ports on which the computer is listening.
netstat -tupln
It will list you all the connection along pid. Find and copy the pid and run the following command. Make sure you replace the with actual id in the following command.
kill -9 <copied pid>
-9 use to forcefully kill the connection.
To kill a process running on Port number 9001
sudo kill -9 $(sudo lsof -t -i:9001)
lsof - list of files(Also used for to list related processes)
-t - show only process ID
-i - show only internet connections related process
:9001 - show only processes in this port number
kill - command to kill the process
-9 - forcefully
sudo - command to ask admin privilege(user id and password).
for more you can visit my blog