# Prevent Human Error on Linux

Put the following content into /etc/profile.d/PHE_function.sh.

cat > /etc/profile.d/PHE_function.sh << "EOF"
function rm {
  echo ""
  echo "Your current host is              : $(hostname)"
  echo "Your current directory is         : $PWD"
  echo "You are abount to do the following: $(/usr/bin/which rm) $@"
  echo "Are you sure (enter HOSTNAME to proceed)?"
  read sure
  if [ $sure == "$(uname -n)" ]; then
    $(/usr/bin/which rm) "$@"
  else
    echo "Cancelled."
  fi
}
function mv {
  echo ""
  echo "Your current host is              : $(hostname)"
  echo "Your current directory is         : $PWD"
  echo "You are abount to do the following: $(/usr/bin/which mv) $@"
  echo "Are you sure (enter HOSTNAME to proceed)?"
  read sure
  if [ $sure == "$(uname -n)" ]; then
    $(/usr/bin/which mv) "$@"
  else
    echo "Cancelled."
  fi
}
function umount {
  echo ""
  echo "Your current host is              : $(hostname)"
  echo "Your current directory is         : $PWD"
  echo "You are abount to do the following: $(/usr/bin/which umount) $@"
  echo "Are you sure (enter HOSTNAME to proceed)?"
  read sure
  if [ $sure == "$(uname -n)" ]; then
    $(/usr/bin/which umount) "$@"
  else
    echo "Cancelled."
  fi
}
EOF
Edited on