Linux – Opening Linux Subsystem (Bash on Ubuntu on Windows) at a certain directory

windows-subsystem-for-linux

Are there any arguments available so the bash doesn't start in the home dir, but another one?

Thank you

Best Answer

  • First install Windows Subsystem Linux in your Windows PC. Go to the folder C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs in other words put this %AppData%\Microsoft\Windows\Start Menu\Programs in file explorer. You can find a shortcut named "Bash on Ubuntu on Windows".

Bash shortcut path

  • Copy the shortcut in any other folder. Right click on that shortcut and open shortcut tab in properties. See the default target path is C:\Windows\System32\bash.exe ~. The tilde (the wavy horizontal line character) is used to represent users' home directories. Thus, a user could also return to its home directory by using the tilde as an argument to cd, i.e., cd ~

Default path in Bash Shortcut

  • Remove the tilde (~) from the target path and put the folder name in Start in option. As example I put "C:\Program Files\WindowsPowerShell". Place the folder path in double quote if path has space in it. Now you are ready to launch bash in that folder.

New Bash Start path

Bash opened in new directory