I'm using Ubuntu and I would like to find and/or print the sudo lecture that is printed to the screen the first time a user executes a sudo command. How can I do this? I'm unable to find the lecture file.
Asked
Active
Viewed 8,003 times
2 Answers
12
See man sudoers
lecture_file
Path to a file containing an alternate sudo lecture that will be used in place of the standard lecture if the named file exists. By default, sudo uses a built-in lecture.
So, if you wish to change the text, add it to a file and point to it from /etc/sudoers
:
Defaults lecture_file = /etc/sudoers.lecture
According to the change log for Ubuntu Qantal, sudo
is now compiled --without-lecture
.
The default text, when compiled in, is:
#define DEFAULT_LECTURE "\n" \
"We trust you have received the usual lecture from the local System\n" \
"Administrator. It usually boils down to these three things:\n\n" \
" #1) Respect the privacy of others.\n" \
" #2) Think before you type.\n" \
" #3) With great power comes great responsibility.\n\n"

jasonwryan
- 73,126
-
Yes, I read the man page, but I still dont understand. If I try: nano /etc/sudoers.lecture there is no file present. How do I print or open the default lecture file? – turtle Jan 02 '14 at 18:03
-
@turtle The default lecture is part of the source code, it's not in a plaintext file. You may be able to use
strings
, or similar, to extract it. – Chris Down Jan 02 '14 at 18:25 -
Yes, in theory, this is exactly what I'm looking for; however, I do not get this output on Ubuntu or OS X. – turtle Jan 02 '14 at 19:11
-
@turtle I have no idea about OSX, but on Ubuntu it is not compiled in. – jasonwryan Jan 02 '14 at 19:44
1
The lecture text is compiled into the sudo binary. Issuing the following strings
command will output the default lecture text.
strings /usr/bin/sudo | grep -A4 "usual lecture"

Timothy Martin
- 8,595
-
1Thanks. This is starting to make some sense. However, on Ubuntu, the command you provided does not output anything. – turtle Jan 02 '14 at 18:27
-
-
-
-
It shows a bunch of text. Here's a sample:
--prefix=/usr -v --with-all-insults --with-pam --with-fqdn --with-logging=syslog --with-
– turtle Jan 02 '14 at 18:52
apt-get source sudo
to install the source package and then search for the lecture in the source code (cd sudo; grep -A4 "usual lecture"
). – depquid Jan 02 '14 at 19:19