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.


1 Answer 1


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 .