Bash shell via Git Bash or WSL in Windows

  • Thread starter fog37
  • Start date
  • #1
fog37
1,568
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: 19
  • Like
Likes fog37 and FactChecker

Related to Bash shell via Git Bash or WSL in Windows

1. How do I open a Bash shell in Windows using Git Bash or WSL?

To open a Bash shell in Windows using Git Bash, simply open the Git Bash application. To use WSL, you can open the Windows Subsystem for Linux by searching for "WSL" in the Windows search bar and selecting the desired Linux distribution.

2. Can I run Bash commands in Git Bash or WSL on Windows?

Yes, you can run Bash commands in Git Bash or WSL on Windows just like you would in a traditional Linux environment. Simply type the desired command into the terminal and press enter.

3. How do I navigate the file system in a Bash shell on Windows?

To navigate the file system in a Bash shell on Windows, you can use commands such as "cd" to change directories, "ls" to list files and directories in the current location, and "pwd" to print the current working directory.

4. Can I install and use Linux packages in Git Bash or WSL on Windows?

Yes, you can install and use Linux packages in Git Bash or WSL on Windows. Both Git Bash and WSL provide access to a wide range of Linux packages and tools that can be installed using package managers such as apt or yum.

5. Is it possible to customize the Bash shell environment in Git Bash or WSL on Windows?

Yes, you can customize the Bash shell environment in Git Bash or WSL on Windows by editing configuration files such as .bashrc or .bash_profile. These files allow you to set custom aliases, environment variables, and other settings to personalize your shell experience.

Similar threads

Replies
3
Views
357
  • Programming and Computer Science
Replies
4
Views
436
  • Programming and Computer Science
Replies
13
Views
2K
  • Programming and Computer Science
Replies
5
Views
454
  • Programming and Computer Science
Replies
5
Views
996
  • Computing and Technology
Replies
20
Views
2K
Replies
16
Views
2K
  • Programming and Computer Science
Replies
16
Views
1K
  • Computing and Technology
Replies
12
Views
3K
  • Programming and Computer Science
Replies
12
Views
3K
Back
Top