If you have used
sudo on a new system, you have probably been greeted with this message:
$ sudo -i We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility.
sudo’s lecture prompt that typically runs the first time you use
sudo, and although it is it has important information, it isn’t very fun so we are going to customize it.
First you need to create your lecture prompt file (default of
/etc/sudoers.lecture). This where your wildest ASCII dreams can come true.
Here is one I like to use:
Which you can grab with this:
$ wget https://raw.githubusercontent.com/brianclemens/dotfiles/master/sudoers.lecture
Now you are ready to set the lecture prompt.
You can check if your system’s
sudo was built with the
--without-lecture flag (Ubuntu enables it), with this command
$ sudo -V | grep without-lecture
If nothing is found, then the lecture prompt is easily changed:
sudoersfile with the
Add the following lines into the Defaults section:
Defaults lecture = always Defaults lecture_file = /path/to/file
Change the path to your new
lecture_file from the first section.
Congrats! Your artwork will be displayed on every
sudo password prompt. Now you can focus on spreading your ASCII brilliance to MOTD,
sudo’s insults, or even your Bash prompt.
sudo was built with
--without-lecture, then your quest for impressing other Unix nerds and avoiding actual work just got a little harder. But you are already in this deep, aren’t you?
sudo without the
Copy out your current
sudo build configuration:
$ sudo -V | sed -n -e 's/ --without-lecture //g; s/^.*Configure options: //p' | tee sudo.options
sudo source and build it
$ apt-get source sudo $ cd sudo* $ ./configure $(< sudo.options) $ make $ make install
Follow the steps from the Easy Method above to finish the process.
Now you can re-alias your new
sudo and proudly display your work!
If you read the above method and scoffed at my lavish wasting of tens of kilobytes, then this method is for you.
Since you have to rebuild
sudo anyway, you can override the default lecture with your own in the source and avoid a separate file altogether:
$ apt-get source sudo $ cd sudo*
grep -nR lecture .)(Further hint:
Change the following block to your desired message:
#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"
$ make $ make install
Voilà! You are ready to take some nice screenshots of your terminal!