netstat -tulnap
shows me what ports are in use. How to free up a port in Linux?
相关问题
- Is shmid returned by shmget() unique across proces
- IPAddress.[Try]Parse parses 192.168 to 192.0.0.168
- how to get running process information in java?
- Error building gcc 4.8.3 from source: libstdc++.so
- Why should we check WIFEXITED after wait in order
To a kill a specific port in Linux use below command
replace Port_Number with your occupied port.
I think the only way will be to stop the process which has opened the port.
You can use
tcpkill
(part of thedsniff
package) to kill the connection that's on the port you need:In terminal type :
netstat -anp|grep "port_number"
It will show the port details. Go to last column. It will be in this format . For example :- PID/java
then execute :
kill -9 PID. Worked on Centos5
Kill the process that is listening to the port in question. I believe netstat shows you process ids.
If you really want to kill a process immediately, you send it a KILL signal instead of a TERM signal (the latter a request to stop, the first will take effect immediately without any cleanup). It is easy to do:
Be aware however that depending on the program you are stopping, its state may get badly corrupted when doing so. You normally only want to send a KILL signal when normal termination does not work. I'm wondering what the underlying problem is that you try to solve and whether killing is the right solution.