Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start WSL Ubuntu in specific or current folder on Windows

When installing Subsystem for Linux and Ubuntu from store on his development machine I can switch (or start) to Ubuntu shell by simply

enter image description here

But the Ubuntu shell start in /home/techsupp folder by default. Is it possible to force it to start in same folder than the one I use my Ubuntu command?

So in my example I should be in

/mnt/h 

Thank you.

What I already tried:

H:\>ubuntu help Launches or configures a linux distribution.  Usage:     <no args>       - Launches the distro's default behavior. By default, this launches your default shell.      run <command line>       - Run the given command line in that distro, using the default configuration.       - Everything after `run ` is passed to the linux LaunchProcess call.      config [setting [value]]       - Configure certain settings for this distro.       - Settings are any of the following (by default)         - `--default-user <username>`: Set the default user for this distro to <username>      clean       - Uninstalls the distro. The appx remains on your machine. This can be         useful for "factory resetting" your instance. This removes the linux         filesystem from the disk, but not the app from your PC, so you don't         need to redownload the entire tar.gz again.      help       - Print this usage message. 

I also discover this request on uservoice: https://wpdev.uservoice.com/forums/266908-command-prompt-console-windows-subsystem-for-l/suggestions/13421103-let-us-right-click-open-bash-here-from-explorer?tracking_code=8a8bc624c72a8336565fcd6d5737d712

Please vote for it.

like image 265
Bastien Vandamme Avatar asked Mar 28 '18 04:03

Bastien Vandamme


People also ask

How do I start WSL in a specific directory?

You can launch to a specified directory using the (also undocumented) wsl --cd <WindowsDirectory> commandline. Note that this takes a Windows-style path to the directory, as opposed to a Linux path. For instance, wsl --cd C:\ . To use a path inside the WSL instance, you can use the Windows' \\wsl$\<distroname>\path .

Where is the Ubuntu folder in Windows WSL?

If you navigate into the package folder, you will find the Linux file system. For WSL Ubuntu, it's located in the LocalState\rootfs folder. This is the root directory of your Linux distro.

How do I access WSL folder in Windows?

First, the easy one. From within the Windows Subsystem for Linux environment you want to browse, run the following command: explorer.exe . This will launch File Explorer showing the current Linux directory — you can browse the Linux environment's file system from there.


2 Answers

I'm on Windows 10 Home with May Update and have Ubuntu 18.04 for WSL installed, I can open the console in any folder with Shift + Right Click and selecting the Open Linux shell here option

like image 72
Emmanuel Guerra Avatar answered Sep 17 '22 17:09

Emmanuel Guerra


If you check in Task Manager how the explorer "Open Linux shell here" option opens wsl, you can see that there's a "--cd" option.

like image 29
talles Avatar answered Sep 16 '22 17:09

talles