永远保持花哨的 sudo 警告

usr*_*ΛΩΝ 50 linux sudo

我第一次sudo使用 openSUSE 时,我总是收到一条奇怪的消息警告

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:
Run Code Online (Sandbox Code Playgroud)

第一次成功登录后,我不会再收到警告。

我想一直被警告。我觉得这个消息有点花哨。有什么办法可以通过 sudo prompt 发出这样的警告吗?

小智 54

在 /etc/sudoers.d/ 里面创建一个文件你可以使用这个命令

sudo nano /etc/sudoers.d/privacy
Run Code Online (Sandbox Code Playgroud)

现在将此行粘贴到文件中。

Defaults        lecture = always
Run Code Online (Sandbox Code Playgroud)

现在关闭终端/Konsole,重新打开它并尝试用 sudo 做一些事情。

  • 我也可以通过将 `lecture` 设置为 `never` 来禁用该消息吗? (2认同)
  • 你不需要 `echo` 上的 `sudo` (2认同)

小智 7

要重新设置帐户以再次看到警告,请删除该用户的 sudo 记录。

root>  rm  /var/lib/sudo/<username>/*
root>  rmdir /var/lib/sudo/<username>
Run Code Online (Sandbox Code Playgroud)