How to make a warning when entering sudo
You probably have several admins running your Linux servers.
To actually do anything, these admins will most likely have to use sudo.
As you probably well know, you can do anything with your servers with sudo.
Therefore, make sure your admins use sudo with caution.
One way to do this is by setting up a sudo password prompt.
So, instead of sudo just asking for the admin password, it also warns them to be careful.
Let’s say, for example, when you have a user running sudo, you want the password prompt to say “WARNING – THINK WHAT YOU ARE DOING -> PASSWORD:”
You can make this configuration change with one quick command. On completion, when the user enters the command with sudo, they will be presented with this warning.
To do this, open a terminal window and install a custom prompt using the command:
export SUDO_PROMPT="Custom Prompt"
Custom Prompt is the text string that we will use for the sudo warning. Following our example above, this command will:
export SUDO_PROMPT="ВНИМАНИЕ - ДУМАЙ ЧТО ДЕЛАЕШЬ - > ПАРОЛЬ:"
Once you do this, the user will see this warning whenever they use sudo.
If you ever decide to change this, you can simply rerun the command with a different line with the desired value.
If you want to revert this to the default values, run the command:
And that’s all it takes to set up a sudo password prompt. This is a very easy way to remind administrators to be careful with sudo. After all, no one wants to fix mistakes at this level.