This question already has an answer here:

What I have:

alias killport='sudo kill -9 `sudo fuser -n tcp $1 2> /dev/null`'


Running e.g. killport 8000 doesn't appear to work, though. However, simply running...

sudo kill -9 `sudo fuser -n tcp 8000 2> /dev/null` 

... DOES work. I can't figure out where I'm messing up.

The major difference between the working and non-working versions as far as I can see is that the aliased version involves a variable, and is executed by the shell for me.... But maybe someone has seen this kind of problem before and knows right where to look.

marked as duplicate by Gilles, slm, jasonwryan, rahmu, Rahul Patil Sep 28 '13 at 2:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You should use a function instead an alias, becaue aliases don't support parameters, make something like that:


sudo kill -9 $(sudo fuser -n tcp $1 2> /dev/null);


Now put this function in your bash configuration file, eg ~/.bashrc and then run:

source  ~/.bashrc

And you're done


Not the answer you're looking for? Browse other questions tagged or ask your own question.