[nflug] Kill ports

Ken Smith kensmith at cse.Buffalo.EDU
Fri Aug 31 20:54:18 EDT 2007


On Fri, 2007-08-31 at 19:32 -0400, Franklin Kumro Jr wrote:
> Is there anyway I could kill all the connections for a specific port
> to my machine?

Not quite sure what you mean by that.  Do you mean set up your machine
so it won't accept connections on that port (firewall it)?  Or do you
mean kill any/all processes currently attached to that port but
otherwise leave your machine as-is?

Or do you mean something else? :-)

I'm guessing you mean that second one, and if that's the case all I can
think of is using lsof(1) to find out what local processes have that
port open and killing them.  Figuring out the syntax to do that isn't
particularly intuitive, it would be something like this (run as root) to
see all the processes on your system that have port 22 open:

	lsof -i :22

(you need to specify that it's Internet "files" you want information and
you're specifying the address as "any IP address, port number 22").

-- 
                                                Ken Smith
- From there to here, from here to      |       kensmith at cse.buffalo.edu
  there, funny things are everywhere.   |
                      - Theodore Geisel |



More information about the nflug mailing list