Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash on Ubuntu on Windows start parameter

Hei, I want to start the bash.exe on windows with start parameters, and let the shell open. I found the msdn page for this, but if I try to run it with e.g. bash -c "ls" , the bash is already closed after.

I want to have a link on my desktop where I put in a login command for ssh. So the shell should stay open, and not perfom the command then exit.

like image 435
Twiebie Avatar asked Dec 11 '16 11:12

Twiebie


People also ask

How do I start the bash terminal in Windows?

Press Windows key + X then click Command prompt, at the command prompt, type: bash then hit Enter. If you want to be able to access the local file system, press Windows key + X, Command Prompt (Admin) then type bash at the prompt.

How do I start bash in WSL?

1] Execute Shell Script file using WSLScroll to find WSL, check the box, and then install it. Once done, one has to reboot to finish installing the requested changes. Press Restart now. BASH will be available in the Command Prompt and PowerShell.


1 Answers

From man bash

   -c        If the -c option is present, then commands are read from the first non-option
             argument command_string.  If there are arguments  after  the  command_string,
             they are assigned to the positional parameters, starting with $0.

So, with -c, the shell is not interactive. If you want an interactive shell after the initial command is run, start another interactive bash shell from running bash shell.

With your example, it will be:

bash -c 'ls; exec bash'
like image 138
anishsane Avatar answered Sep 23 '22 12:09

anishsane