본문 바로가기
Web

WSL 윈도우 Ubuntu 비밀번호 분실 시 초기화

by chan10 2023. 10. 17.

WSL(Windows Subsystem Linux)은 윈도우에서 리눅스(Ubuntu)를 이용하기 위해 사용됩니다.

저는 Ansible 이용을 위해 WSL을 사용했으나 비밀번호를 잊어버려 초기화 했던 방법을 공유하려고 합니다.

생각보다 간단해서 초기화 하는데 1분도 걸리지 않았습니다~!!

 

1. 윈도우 커맨드 창을 실행합니다.

2. 다음 명령어를 입력합니다. `wsl --user root`

ㄴC:\Users\chan>wsl --user root

[Root 비밀번호 변경 시]
root@HBPVG3010567:/mnt/c/Users/chan# passwd
New password:
Retype new password:
passwd: password updated successfully

[유저 계정 비밀번호 변경 시]
root@HBPVG3010567:/mnt/c/Users/chan# passwd chan
New password:
Retype new password:
passwd: password updated successfully

root@HBPVG3010567:/mnt/c/Users/chan# exit
logout

 

3. 변경된 비밀번호로 명령어가 실행되는지 확인합니다.

chan@HBPVG3010567:/etc/ansible$ sudo apt update
[sudo] password for chan:
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:2 http://ppa.launchpad.net/ansible/ansible/ubuntu focal InRelease [18.0 kB]
Hit:3 http://archive.ubuntu.com/ubuntu focal InRelease
...

 

[참고 사이트]

https://mycup.tistory.com/286