62

The first time I do sudo on openSUSE I'm always warned with a someway fancy message

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.

root's password:

After the first successful login I won't be warned again.

I'd like to be always warned. I find this message someway fancy. Is there any way to be warned like that by sudo prompt?

2
  • 4
    To be honest if this shows every time I use sudo, I will still manage to ignore it and remove root directory or something like that. This will probably only work if the warning is a 3d banner blinking with multiple color which is different every time. Apr 15, 2019 at 3:17
  • 3
    @NgSekLong I've seen (boring|terrible|lazy|startup character) ASCII banners in conjunction with poor system administration skills before. I guess it's not that simple but… uh challenge accepted? omgubuntu.co.uk/2018/07/… At worst you loose your compliance status, or even worse it's mandatory in the next revision of whatever rules you have to implement at work.
    – LiveWireBT
    Jan 28, 2021 at 2:07

3 Answers 3

61

Create a file inside /etc/sudoers.d/ You can use this command

sudo nano /etc/sudoers.d/privacy

Now paste this line into the file.

Defaults        lecture = always

Now close Terminal/Konsole, Reopen it and try to do something with sudo.

6
  • 3
    Can I also disable the message by setting lecture to never? Jun 14, 2017 at 10:16
  • 1
    Yes, the options for lecture are: always never once sudoers man
    – Chris
    Nov 28, 2017 at 4:18
  • 1
    $ sudo echo "Defaults lecture = always" | sudo tee -a /etc/sudoers.d/privacy
    – Oliver Ni
    Jun 18, 2019 at 4:32
  • 3
    You don't need the sudo on the echo
    – chaosaffe
    Apr 15, 2020 at 2:02
  • 1
    Using sudoedit would be a lot safer than sudo nano - if something goes wrong, you may not be able to run sudo again to fix it
    – Xen2050
    Apr 12, 2023 at 5:44
7

To re-set an account to see the warning once more, delete the sudo records for that user.

root>  rm  /var/lib/sudo/<username>/*
root>  rmdir /var/lib/sudo/<username>
1
  • 1
    According to man sudoers on a CentOS 7 host, the default setting for lecture_status_dir is /var/db/sudo/lectured
    – cherdt
    Dec 18, 2019 at 17:52
4

To add to Michael JAMES's statement, locations might vary. On Fedora,

rpm -ql sudo

Shows a directory called:

/var/db/sudo

In this directory i found another directory called 'lectured' followed by my name. Removing my name from this directory show the warning again.

Edit: This is a one time solution to reset showing the message. You could of course use crontab to empty the directory so that the message is printed on a more regular basis.

1
  • What does rpm -ql do, and is there a debian-equivalent?
    – Xen2050
    Apr 12, 2023 at 5:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .