If you’re using a fresh installation of WSL, you’ll most probably get the following message every time you start a new WSL/Windows Terminal instance, or a new Windows Terminal Ubuntu tab.
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
It gets annoying after a while. Fortunately the way to get rid of it is surprisingly easy.
Solution #1: just run ANY sudo command
sudo echo hi
The command isn’t important. As a matter of fact, you can even supply sudo with an invalid command like sudo x. As long as sudo can validate your password successfully, the message will go away.
If, for whatever reason, this solution doesn’t work for you, here are two more solutions.
Solution #2: Create the Flag in Your Home Directory
The logic that displays the startup message is disabled if this file exists in your home directory: .sudo_as_admin_successful
The file gets generated automatically if you sudo at least once successfully.
Alternatively you can just create the flag manually:-
Solution #3: System-Wide Solution
I’m not really sure the use case for this solution. Perhaps it’s useful when you’re deploying WSL to multiple users?
Anyway, the logic is stored in the system-wide Bash configuration file: /etc/bash.bashrc
Search for the message. Then just remove or comment out the If-block.
The startup message doesn’t come from WSL or Windows Terminal. It is Ubuntu feature, if you can call it that. Personally I think its usefulness is questionable.
WSL/Windows Terminal Guides