Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run bash command from windows Command line (WSL)

I have installed WSL on Windows 10 Pro. And I need to execute bash commands from Windows Command Line like this:

bash -c ll

Expected: ll command output in Command Line console

In practice: /bin/bash: ll: command not found

But its work for some commands like ls or apt.

Please, see :

screenshot with example

What could be the problem?

like image 324
hdnn Avatar asked Oct 17 '18 15:10

hdnn


People also ask

How do I run Bash from 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.

How do I run a Linux command in Windows using WSL?

Run Linux tools from a Windows command line Run Linux binaries from the Windows Command Prompt (CMD) or PowerShell using wsl <command> (or wsl.exe <command> ). Binaries invoked in this way: Use the same working directory as the current CMD or PowerShell prompt. Run as the WSL default user.

How do I run a Bash command in Windows?

To access the shell, simply type 'bash' in the Windows command prompt, and everything is good to go.

Does WSL support Bash?

Once you've configured your system to run WSL (i.e., Bash on Ubuntu on Windows), access it by clicking the Bash on Ubuntu on Windows icon (Figure 1), which will launch you into a Bash console (Figure 2). The remainder of this article will show some of the interesting things you can do using the WSL.


2 Answers

ll is a common alias (for ls -alF in WSL; defined in the default .bashrc). Depending on how you invoke bash will determine whether the scripts which set up your system aliases are run. See the INVOCATION section of the bash manual.

You can use bash -i -c ll to invoke bash in an appropriate way for WSL.

like image 103
borrible Avatar answered Oct 13 '22 01:10

borrible


Apparently ll is an alias you defined in some of your configuration files. You should start bash as follows:

bash -ilc ll

Depending on where you defined the aliases, you can omit the -i or -l flag.

like image 30
alfunx Avatar answered Oct 13 '22 01:10

alfunx