shell : warn about or deny command execution with help of an alias

This should not work because of the space in your alias name.

You could call a custom function instead, in .bash_aliases :

#!/bin/bash

function myiptables {
 if [ $@ == "-F" ]
 then
   echo "WARNING: due to the DROP default rule, flushing all rules would lock you out"
 else
   command iptables "$@"
 fi
}

alias iptables='myiptables'

This will print the warning message if iptables argument is -F.

Otherwise, it will execute the normal iptables command, including all parameters you may have passed to it ($@).


command will run the real iptables command, preveting calling back your own function :

# help command
...
Runs COMMAND with ARGS suppressing shell function lookup, or display
information about the specified COMMANDs. Can be used to invoke commands
on disk when a function with the same name exists.
...