Close Port Centos

type following command:

> netstat -lpn

This will list all listening ports


Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:49027           0.0.0.0:*               LISTEN      13098/java    
tcp        0      0 127.0.0.1:9160          0.0.0.0:*               LISTEN      13098/java    
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      -            
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      13098/java    
tcp        0      0 0.0.0.0:33395           0.0.0.0:*               LISTEN      13098/java    
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -            
tcp        0      0 127.0.0.1:7000          0.0.0.0:*               LISTEN      13098/java  


Use grep for filtering out the 8080 port.

You can use following command:
> netstat -lpn | grep 8080

You'll get output something like this

tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      13098/java

Here my process id is 13098 and it is the process that is using port 8080

Kill the process using following command:
> kill 13098

for force kill:
> kill -9 13098

Comments

Popular Posts