Bash shell via Git Bash or WSL in Windows

  • Thread starter fog37
  • Start date
  • #1
fog37
1,569
108
Hello,
I understand that, in Windows, there are two native shells which are the programs CMD and Powershell. An operating system has a kernel and a shell and CMD and Powershell are shell programs, i.e. programs to interact with the shell. These programs have their own similar but different language (the commands are not all the same). Both CMD and Powershell run inside the terminal, which is another program.

There are many text-based shell which are all command-line programs to interact with the shell of the operating system...Natively, Windows does not have the bash shell (which is instead available in Mac or Linux). However, it seem possible to have access to the bash shell if we either install WSL (Windows Subsystem Linux) or download Git, which automatically come with the Git bash....

My understanding is that Git bash allow us to use the bash shell in Windows, correct? Doe the Git bash run inside the same terminal as CMD and Powershell? I would think so...

How does the Git bash compare with WSL which also make the bash shell available to Windows user? WSL is not a Linux virtual machine but it apparently allows programs that are meant for Linux to run in Windows (same as Wine which Windows programs to run in Linux)?
For example, Docker expects Linux so to run Docker in Windows we need to install WSL...Or is it WSL2 (which is a actual Linux virtual machine) which is different from WSL1? Not sure what WSL1 really is if it is not an Linux emulator.

Thank you!
 
Technology news on Phys.org
  • #2
On all the installations of GIT bash I have used, it is a stand-alone program. When you run it, it opens a dedicated terminal window into which you can type commends and see console output. It does not use either CMD or Powershell.

The GIT bash shell allows you to use most (not all) Unix Bash commands.

I have not used WSL but from your description it sounds like it does much more than GIT bash. I have not heard of people using GIT bash to run programs designed for Linux on a Windows machine.

Here is a picture of my GIT bash terminal window

1707451758687.png
 

Attachments

  • 1707451588910.png
    1707451588910.png
    26.5 KB · Views: 61
  • Like
Likes fog37 and FactChecker

FAQ: Bash shell via Git Bash or WSL in Windows

What is Git Bash and how does it differ from WSL?

Git Bash is a command-line interface for Windows that provides a Unix-like environment, allowing users to run Bash commands. It is primarily used for Git version control and comes bundled with Git for Windows. On the other hand, Windows Subsystem for Linux (WSL) allows users to run a full Linux distribution alongside Windows, providing a more comprehensive Linux experience, including access to native Linux applications and tools.

How do I install Git Bash on Windows?

To install Git Bash on Windows, download the Git for Windows installer from the official Git website. Once the installer is downloaded, run it and follow the installation prompts. During the installation, you can choose the components you want to install and configure options such as your preferred terminal emulator. After installation, you can launch Git Bash from the Start menu.

How do I install WSL on Windows?

To install WSL on Windows, open PowerShell as an administrator and run the command `wsl --install`. This command will install the default Linux distribution. If you want to install a specific distribution, you can do so from the Microsoft Store after enabling WSL. Once installed, you can launch your Linux distribution from the Start menu and begin using it.

Can I use both Git Bash and WSL on the same Windows system?

Yes, you can use both Git Bash and WSL on the same Windows system. They can coexist without any issues, and you can choose to use one or the other based on your preferences or specific tasks. Git Bash is great for Git-related tasks and lightweight scripting, while WSL provides a more complete Linux environment for a broader range of applications and tools.

What are some common commands I can use in Git Bash and WSL?

In both Git Bash and WSL, you can use common Bash commands such as `ls` (list directory contents), `cd` (change directory), `mkdir` (create a directory), `rm` (remove files or directories), and `git` commands for version control. Additionally, WSL allows you to use Linux-specific commands and tools, such as `apt` for package management, making it a powerful option for developers and system administrators.

Back
Top