How to Find and Kill a Process that is Using a Particular Port
You try to install an application and get the error that the specified port is in use
You can find the application that is using the process kill it, here's how:
Find what application/process:
sudo netstat -lpn | grep :<portnumber>
Example
sudo netstat -lpn | grep :8080
The PID will precede the name of the application using the port
Example
tcp6 0 0 :::8080 :::* LISTEN 5723/apache2
Kill the process:
kill <port number>
Example:
kill 5723
If there are multiple instances of the application, you can use the killall command
Example:
Killall apache2
Now you can continue to install the application
If you wish to prevent the application from starting automatically, you can remove it from the init.d folder
rm /etc/init.d/<application name>
Example
rm /etc/init.d/apache2