bash - "Aliasing" of Commands with Arguments -
this question has answer here:
i know commands can aliased through shell, such as
alias mv="cp"
but want similar arguments (and yes, have seen other question, question different). similar to:
sshkill() { service sshd restart } alias sshkill="killall sshd"
but doesn't work.
i wish prevent users directly killing sshd (at least accident) , make restart (this server has happened more once). so, rather aliasing, there way prevent command killall sshd
being executed , rather executing service sshd restart
instead?
you want intercept killall
, so:
killall() { if [ "$1" = "sshd" ]; echo "some warning message, , perhaps service sshd restart" else command killall "$@" fi }
Comments
Post a Comment