Enable the default warning message whenever “sudo” is used.
Edit sudoers file by typing:
sudo EDITOR=vim visudo
Add the following line near the other defaults:
Defaults lecture=always
NOTE: Instead of always you can use once too.
To make sure the syntax of the edited file is not incorrect, check it with the following command and look for parsed: OK.
NOTE: If you mess up the syntax in this file, it can cause you problems using the “sudo” command.
visudo -c
To customize the message, you can create a custom message file.
Edit the lecture file by typing:
touch /etc/lecture chmod 644 /etc/lecture vi /etc/lecture
Add the following text (which is default) or whatever you want:
We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility.
Now point to the newly-created file in the sudoers config file.
sudo EDITOR=vim visudo
Defaults lecture_file=/etc/lecture