WSL open command

Posted on Monday, March 2, 2026


 


In Cygwin I have a nice open command that I can use to open directories or files.  What are the options in WSL ubuntu to replicate this?

I can use the explorer.exe cmd for example I can run

 

> explorer.exe .

 

And that will open the folder you are in windows explorer.

This will also work on files

 

> explorer.exe file.pdf

 


And it will open in pdf viewer

You can even open a web site

 

> explorer.exe https://www.google.com

 


I prefer using open vs explorer.exe, so let’s add it to ~/.bashrc

 

> vi ~/.bashrc

 

And add in

 

alias open='explorer.exe'

 



Source ~/.bashrc to pick up the changes

 

> source ~/.bashrc

 

 

Now try it out

 

> open .
> open file.pfd
> open https://www.google.com

 

That all worked fine.

 


Side Journey

 

I had an idea to make another alias to open https://www.google.com/search?q=speed+test


 


 


It’s a tool I use a lot to quickly diagnose my internet speed.

However, that full length does not work with explorer.exe

 

> explorer.exe https://www.google.com/search?q=speed+test

 

DOES NOT WORK!!

 

Install wslview, a better tool than explorer.exe

 

> sudo apt update && sudo apt install wslu

 


Now let me test

 

> wslview https://www.google.com/search?q=speed+test

 

 

That worked!

Now let me make an alias in ~/.bashrc

 

> vi ~/.bashrc

 

And add in

 

alias open='wslview'

alias speedtest='wslview https://www.google.com/search?q=speed+test'

 


 

Source ~/.bashrc to pick up the changes

 

> source ~/.bashrc

 


Now try and run the speedtest command

 

> speedtest

 

 


Hey that worked!



References

No comments:

Post a Comment