I want to make a global alias for killprocessatport
so I put at the end in /etc/bash.bashrc
fuserfunction() {
fuser -KILL -k -n tcp
it does not work because when you do:
bash /etc/profile
you open a new shell, execute the profile script, and get back to your current shell.
Actually, that's why to load the content of /etc/bash.bashrc
you do source /etc/bash.bashrc
in the /etc/profile
.
Thus to load it in your current shell, you should run:
source /etc/profile
instead.
Nota Bene:
~/.bashrc
which gets automatically sourced by bash on load ;/etc/profile.d
where it will be automatically sourced on new shell instances ;killprocessatport
to fuserfunction
. Though, you may prefer to do an alias for a call to the function with a parameter like: alias killhttpserver=fuserfunction 80
fuserfunction
, something like fuserkillproc
or even something better you may come up with…HTH
You can't use an alias or a function in this case. Create an executable script in a location that's on your PATH (as configured by sudo, if your /etc/suoders
modifies root's PATH).
#!/bin/sh
exec fuser -KILL -k -n tcp "$@"
Save the script, then set its permissions with chmod +x
.