(Help!) Sudo doesn't ask for password in AL 9 WSL

Hi all!

I am glad to announce that I am a newcomer to the linux community (please be nice) and after trying Fedora as my first linux distro I decided to install AlmaLinux 9 WSL in my windows machine to keep practising bash commands (I prefer to learn with RHEL-based distros since it’s an industry and science standard).

Problem is AL 9 in WSL doesn’t ask for a password when using the sudo command, which I find pretty unsafe. After googling thoroughly, I checked the /etc/sudoers file and even though I have the “user_name ALL=(ALL) NOPASSWD:ALL” commented and I set the timestamp_timeout to 0, still doesn’t ask for a password.

So please, if anyone could help me I will be very grateful.

Use the “id” command to see what groups the user belongs to. Check /etc/sudoers to make sure any groups do not have the NOPASSWD option. If you have made changes to the sudoers file (using visudo), log out and log back in.

Furthermore, check what is in /etc/sudoers.d/. (That is the place, where you should add custom rules.)

I used the id command and the output was the following:

uid=0(root) gid=0(root) groups=0(root)

Any groups has the NOPASSWD option since y commented the whole line in the sudoers config file.

This worked! There was a “default_user” file where the only line was the NOPASSWD option was configured for my user, I commented it and now it ask for the password.

Thank you very much to all of you for your help!

2 Likes