0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

wslのsudoパスワードの再設定方法

0
Last updated at Posted at 2026-04-13

wsk環境でsudoコマンド実行しようとしたときにパスワードを求められるが、パスワードを忘れてしまったので再設定方法を調べてみた。

方法

powershellかコマンドプロンプトを管理者権限で開いて以下を実行

wsl -u root

ディストリビューションごとに設定しなおしたい場合

wsl -d [ディストリビューション名] -u root

# 例
wsl -d Ubuntu-20.04 -u root

これで入れたら、以下を実行してパスワードを設定しなおす
この時のユーザー名はWSLのLinuxユーザ名のこと

passwd [ユーザー名]

# 例
passwd yamada

あとは流れに沿って新しいパスワードを設定するだけで完了

0
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?