LoginSignup
6
1

More than 3 years have passed since last update.

sudoコマンドがいきなり使えなくなった!

Posted at

問題

$ sudo
sudo: /etc/sudoers is owned by uid 1000, should be 0
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

原因

/etc/sudoers の権限がroot権限から(wakkihayaに)いつの間にか変わっていたみたい

$ ls -la /etc/sudoers
-r--r----- 1 wakkihaya root 820 Aug 26 15:00 /etc/sudoers

やったこと

その1(失敗)

$ chown -R root:root /etc/sudoers
chown: changing ownership of '/etc/sudoers.d': Operation not permitted

普通にroot権限を付与しようとしたけど、root権限でしか /etc/sudoers は変更できないので、permittedになるのは当たり前…

その2(失敗)

$ su - root 
Password: 
su: Authentication failure

suでrootに変更しようと思ったけど、
なぜか、Passwordをいれても認証されない…

その3(失敗)

$ pkexec visudo
Error getting authority: Error initializing authority: Could not connect: No such file or directory
$ pkexec chown root:root /etc/sudoers /etc/sudoers.d -R
Error getting authority: Error initializing authority: Could not connect: No such file or directory

pkexec で実行しようと思ったけど、これも認証落ちる…

その4(成功)
WSLから権限を付与することが無理なら、Win上から権限を付与しちゃおう!

Windowsのコマンドプロントを開いて、

$ wsl -u root
$ chown root:root /etc/sudoers
6
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
1