I would like to use ls
, and many other Linux tools, from the command line on Windows 10. I know that there is GnuWin32 and other binary replacements, but none of those works as elegantly as the Windows Subsystem for Linux (WSL); including the update mechanisms.
With WSL, one can call ls ...
from the command line via bash -c "ls ..."
, which works great. Ideally, however, I would just type ls
on the command line. I can create an ls.bat
which basically does @bash -c "ls %*"
- but I would have to do that for every single command I want to export. Is there a more direct way of exporting ls
(and many others) to the command line?
Apparently this was the most requested feature for WSL, and Microsoft now supports this feature. To use linux commands from within Command Prompt (or PowerShell), just prefix the command with wsl
. So, for example, here's how you run ls
from CMD.
C:\temp> wsl ls
<- contents of C:\temp ->
Or here's how you update package lists.
C:\temp> wsl sudo apt-get update
[sudo] password for username:
Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [94.5 kB]
More details can be found in the official docs. I'm not sure if you are looking for a solution which doesn't involve any kind of prefixing. If that's the case, I don't know of any solution yet.