2

Having set a lecture with Default lecture=always and Default lecture_file=/etc/sudoers.lecture, I would like to add colour to it. ANSI escape characters show without escaping, and creating a wrapper function displays it every time I use sudo, even if the password is in the cache.

  • 1
    What is a lecture? – k.stm Aug 23 at 17:05
  • @k.stm This is described in the sudoers(5) manual. It is the short text that is outputted upon first using sudo, which (by default) reminds the user to use the command responsibly. – Kusalananda Aug 23 at 17:22
  • Cannot reproduce here; using the appropriate tput output, I created a file that sudo dutifully outputted in color. How did you produce the /etc/sudoers.lecture file? – Jeff Schaller Aug 23 at 18:38
  • @JeffSchaller, I also don't know how tput works. – gadzooks02 Aug 25 at 18:28
1

Using:

echo $(tput setaf <colour>)<text>$(tput sgr0) >> /etc/sudoers.lecture

adds coloured text to /etc/sudoers.lecture

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.