改/etc/sudoers会变得不幸

故事

其实是改了+更新+乱继续会变得不幸。

故事是这样的:一个小可爱获得了一个纯净的Debian VM。这个小可爱拿到root以后就创建了一个自己的账户,然后修改了/etc/sudoers来给自己sudo权限,然后把root的终端改成了nologin

It works just as intended.

直到有一天,这个小可爱换了个apt源。

$ sudo apt update
//...
$ sudo apt upgrade

似乎无事发生。

直到出现了一个文件冲突。是谁想必聪明的读者已经猜到了。

这个小可爱还是意识到了问题,想用shell看看合并一下修改,但是root的终端现在是nologin,于是只有一句:

This account is currently not available.

“算了,更新完以后再改吧。”

更新很快就结束了。于是:

$ sudo vim /etc/sudoersb
[sudo] password for sillyB: 
sillyB is not in the sudoers file.

没有后悔药了,这时这个小可爱陷入了深深的自责中。(因为接下来就要被疯狂嘲笑了啊哈哈哈哈)

正常人的做法

首先,把sudoer加入到组sudo是最正确的做法。

# usermod -aG sudo cleverOne
# id -Gn cleverOne
cleverOne cleverOne sudo ...

其次,用添加代替编辑。请在/etc/sudoers.d/里面新增条目。这个目录里面的README中的一段是这么说的:

As of Debian version 1.7.2p1-1, the default /etc/sudoers file created on installation of the package now includes the directive:

        #includedir /etc/sudoers.d

This will cause sudo to read and parse any files in the /etc/sudoers.d
directory that do not end in '~' or contain a '.' character.

Note that there must be at least one file in the sudoers.d directory (this
 one will do), and all files in this directory should be mode 0440.

大意是建议你创建一个文件在/etc/sudoers.d下面(名字不用~结尾且没有.)就好啦~还要记得chmod 0400哦……

现在很多软件的配置文件都支持include目录,所以可能的话,下次再编辑xxx.conf的时候去试试找找conf.d哦~

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇