How to require ‘reboot’ to be interactive?
One too many times I’ve dropped a reboot
in the localhost thinking I was logged into a server.
How to require ‘reboot’ to be interactive?
One too many times I’ve dropped a reboot
in the localhost thinking I was logged into a server.
sudo tee /etc/profile.d/custom.sh << "EOF"
reboot() {
read -p "reboot ${HOSTNAME}? (y/N): "
if [ "${REPLY}" = "y" ]
then sudo reboot "${@}"
fi
}
EOF
. /etc/profile
An alternative method to work with sudo reboot
:
sudo tee /usr/local/sbin/reboot << "EOF"
#!/usr/bin/bash
read -p "reboot ${HOSTNAME}? (y/N): "
if [ "${REPLY}" = "y" ]
then /usr/sbin/reboot "${@}"
fi
EOF
sudo chmod +x /usr/local/sbin/reboot
hash -r
thanks brother!
Calling the hostname was a good idea
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.