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.

  • You could use 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 2 '14 at 19:19

See man sudoers

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"
  • 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 2 '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 2 '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 2 '14 at 19:11
  • @turtle I have no idea about OSX, but on Ubuntu it is not compiled in. – jasonwryan Jan 2 '14 at 19:44

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"
  • 1
    Thanks. This is starting to make some sense. However, on Ubuntu, the command you provided does not output anything. – turtle Jan 2 '14 at 18:27
  • What version of Ubuntu? I am using 10.04 LTS to test. – Timothy Martin Jan 2 '14 at 18:31
  • I'm on Ubuntu 12.04.3 LTS (Precise Pangolin). – turtle Jan 2 '14 at 18:33
  • Does strings /usr/bin/sudo | grep "lecture" output anything? – Timothy Martin Jan 2 '14 at 18:47
  • 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 2 '14 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.