Posted: . At: 10:26 AM. This was 6 years ago. Post ID: 11931
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 have a custom message appear each time sudo is used.


This is how to have a custom lecture appear each time a user executes the sudo command to remind them to be careful with it.

Run the visudo command as root and add these lines to the /etc/sudoers file.

Defaults lecture="always"
Defaults lecture_file="/home/jason/lecture"

Then create the /home/jason/lecture file and put this in it.

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 is the output when sudo is run with these settings.

-> 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 get a very nice custom message to appear when a user runs sudo to execute a command as the superuser.


1 thought on “How to have a custom message appear each time sudo is used.”

  1. Truthfully this is an excellent idea. I have been playing with Linux now for some years, but this is the first time I have heard about this capability. That’s really cool. I will now make a point to set this up on a couple of peoples computers who look to me when they have questions and when they need help with their computers. I seem to learn more by passing this kind of information along to them and then as I explain it… LOL Whatever works eh?

    Good post. Please keep them coming as you now have a new big-eared lurker hanging about…

    Reply

Leave a Comment

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