Command not found: sudo mkdir test
kelteseth opened this issue · 2 comments
kelteseth commented
Sudo for Windows version
1.0.1
Windows build number
Windows build: 26100.1.amd64fre.ge_release.240331-1435
Other Software
Sudo works with the provided example sudo netstat -ab, but not when invoking mkdir.
Steps to reproduce
PS C:\Users\Ryzen-7950X> cd 'C:\Program Files\'
PS C:\Program Files> sudo mkdir test
Command not found
PS C:\Program Files>
Expected Behavior
A folder
Actual Behavior
Command not found
lhecker commented
mkdir is a builtin command of PowerShell, not a standalone application like it would be on UNIX/Linux. You have to write sudo powershell -c '...' or sudo pwsh -c '...' to launch PowerShell and tell it to execute your command(s).
If you were to use cmd then sudo mkdir test would work. The builtin commands of cmd are quite a bit simpler and haven't changed in decades, so sudo supports them as a "shortcut" to help cmd users.