Wednesday, 24 April 2013

Unix:How to check which process is running on a given port and how to make port free

'fuser' command can be used to check the pid of the process running on a given port

Syntax:

fuser port_no/tcp

For example, following command is used to check the process running on port 50070

$ fuser 50070/tcp
50070/tcp:            9118

 9118 is the pid of the process running on port 50070

To make a given port free you can kill the pid of the process running on a port. There is one more option, you can use "-k " option with fuser to do the same .

Syntax:
fuser -k port_no/tcp

For example:
$ fuser -k 50070/tcp

It will kill the process running on port 50070.

Note : A user can only kill the process on which it has  access  otherwise root user can help.

No comments:

Post a Comment