Posted: . At: 9:44 AM. This was 6 years ago. Post ID: 12144
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to add a lecture that appears every time sudo is run.


To add a lecture that appears when sudo is run to remind a user to be careful, just run the sudo visudo command and add these two lines to the /etc/sudoers file.

Defaults lecture="always"
Defaults lecture_file="/root/lecture"

Save the file and then add this text to the /root/lecture file.

root@Yog-Sothoth:~# cat lecture 
1) All commands run with root privileges are always dangerous.
2) Never run commands on an environment you are not willing to destroy, or able to restore.
3) Do not become root until you know what you are going to do.
4) Be sure of your command and what is going to be affected by it.

This task is now complete. Now when you run the sudo command, this is what you will be presented with.

jason@Yog-Sothoth » ~ » $ sudo ls
1) All commands run with root privileges are always dangerous.
2) Never run commands on an environment you are not willing to destroy, or able to restore.
3) Do not become root until you know what you are going to do.
4) Be sure of your command and what is going to be affected by it.
[sudo] password for jason:

That is how easy it is to personalize the sudo command. This is a good way to remind users of the responsibility involved in having access to sudo and the superuser access.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.