What is the difference between Bash and Ubuntu terminals on Windows 10 - bash

I recently installed Ubuntu for Windows and now inside the Start Menu there are 2 new items:
Bash
Bash
This terminal opens in:
root#myName-PC:/mnt/c/Windows/System32#
Ubuntu
Ubuntu
This terminal opens in:
root#myname-PC:~#
What is the difference between the two?
For example, we want to install Git and Utils, RVM (Ruby) then clone a Git project and deploy via SSH with Capistrano commands. Should that be run with Bash or Ubuntu as above?
Also, should the commands be run in system32 or C:/ folder when inside the terminal?
Thanks

The Bash terminal is the old style (prior to Windows 10 v1790 a.k.a. Fall Creator Update). It resides in %LocalAppData%\Lxss and is managed using lxrun.exe.
The Ubuntu terminal is the new style, downloaded from Microsoft Store. The launcher part is a Windows App (%ProgramFiles%\WindowsApp) and its data resides in %LocalAppData%\Packages.
Those are two isolated installation of Windows Subsystem for Linux and do not interfere with each other. Practically you need only one of them, so choose one at your own preference.
I personally dislike the Windows Store version as it can be easily removed, which isn't a good thing for a productivity environment.

I was trying to delete the legacy "Bash on Windows" and wasn't unable to because lxrun.exe is not available in my system. But in case anyone needs it, here's how:
If you wish, you can manually delete your legacy instance. This may be required if you encounter issues uninstalling the legacy distro using lxrun.exe, or are running Windows 10 Spring 2018 Update (or later) which do not ship with lxrun.exe.
To forcefully delete your legacy WSL distro, delete the %localappdata%\lxss\ folder (and all it's sub-contents) using Windows' File Explorer, or the command-line: (using PowerShell)
rm -Recurse $env:localappdata/lxss/

The git bash vs the Ubuntu bash.
Basically there is nothing much different except maybe the versions of the bash. Because bash is bash. It's most likely different versions of bash were installed at different times for different purposes on the PC. And they will also likely be found in different folders on the PC.
Run the following code from the two different shells. This returns the version of bash:
echo "$BASH_VERSION"
On this PC, using the two terminals (MinGW and Ubuntu) returned the following versions of bash: (see image link below)
5.0.17(1) - release
4.4.23(1) - release
It's likely most people using PCs that have been around a while will find that there are two (or more) different versions of bash installed on their PCs. On this PC, the older version of bash was installed some time back.
That older version of bash might have been installed when Cygwin was installed on this PC. Or maybe the older version of bash was installed when Git was installed long ago. It really doesn't matter now. On this PC, bash is found in at least these following locations:
C:\cygwin64\bin\bash.exe
C:\Program Files\Git\bin\bash.exe
C:\Program Files\Git\git-bash.exe
The Windows 10 on this PC was updated. Specifically, the WSL kernel was updated from WSL to WSL2. Part of this update involved turning on some Windows features, including the: Windows Subsystem for Linux.
There was an old (virtual) version of Ubuntu (18.04) that had been installed on this PC some time back. But that old version of Ubuntu went away with this update. This WSL2 update changes the way Linux (Ubuntu) operates on this PC. After the WSL2 update, Ubuntu was installed from the Microsoft Store. This is Ubuntu 20.04.
This WSL2 update and the newly installed version of Ubuntu also installed a newer version of bash on this PC. And this newer version of bash is the newer version of bash that is showing above.
Another good way to understand the difference between these two versions of bash would be to enter the following into each shell:
type ping
The result should clearly show that one version of bash is providing the source from Windows while the other version of bash provides the source from Ubuntu.
ping is /c/windows/system32/ping
ping is /usr/bin/ping
Sometimes a picture is worth more than a thousand words. Attached below are two of the new Windows Terminals side by side.
These terminals show the two different versions of bash. Echo returns the older version of bash being used in the MinGW shell and Echo returns a newer version of bash being used in the Ubuntu shell.

Related

How to access anaconda prompt in ubuntu terminal installed in windows 10?

I have recently added the ubuntu terminal in my windows pc since certain packages were only supported in linux. Now for example if I were to access my packages that are present in my conda environments in my windows os through the linux terminal would it be possible? Will it still function the same way or do I have to manually install everything via the ubuntu terminal as well.
If I do have to install everything manually again, where will all the stored data be present? Which directories should I access?
How does this ubuntu terminal work exactly? Does it work in a similar manner if I were to dual boot it?
Yes, you can access all the packages from Ubuntu terminal. You don't have to install everything all-together again. WSL or Ubuntu on Windows can seamlessly integrate with windows. Even though Linux systems have different directory structure, Ubuntu terminal (or bash or WSL or Ubuntu for Windows) happen to maintain the directory structure for windows. So anything you install on Ubuntu terminal will be installed as to windows terms. But I wouldn't recommend mixing these two as it's very tricky. And also, WSL and dual-booting Ubuntu with windows are far from close. You can know more about it if you search online.
I would personally recommend installing Ubuntu as it makes programming a billion times easier. You don't have to install Ubuntu replacing windows. You can just install Ubuntu on a separate hard drive and just specify which drive to boot from on system start-up. If you use a laptop and don't have two drives, then create a new volume and use it as if it were an original drive.

Do I need to install Git for both Windows 10 and WSL?

I'm trying to set up a web development environment using a guide on Medium. The author says we need to install Git for both Windows and for Windows Subsystem for Linux. Git takes up a lot of space. Do we need to install it twice?
I have Visual Studio Code and Ubuntu (WSL). I also installed Git for Windows 10.
Git For Windows differs from the Linux Git.
So, if you want to execute commands in a Windows CMD and a Linux WSL shell, then yes, you would need to install both.
On Windows side, that can mean simply uncompressing the self-extracting archive PortableGit-2.22.0-64-bit.7z.exe anywhere you want, and add it to your PATH.

How to access ruby from Ubuntu bash for windows

I started ROR development on windows using Ubuntu bash. For now it was going well but when i tried to debug ruby on window using Rubymine it said no ruby SDK specified. How can i access the ruby sdk from ubuntu bash?
In resume: maybe Rubymine is a windows-program which is not aware of the ruby (ROR) environment installed inside the windows10-WSL.
In more detail: before windows10 (with winxp, win7, etc) ubuntu and linux programs could not be installed inside windows. So in those cases, if you needed to use a linux program, you could download virtualbox, create a separate VirtualMAchine, install there your Ubuntu and then inside install the ubuntu programs (Ruby, ROR, etc)
With windows10, there is a new feature called WSL - Windows Subsystem for Linux, which allows a ubuntu system to be installed inside window. It uses some hidden virtualization/conversion to make it transparent for the user, and so any ubunut command can be run from the windows-console, without VirtualBox nor VirtualMachine - its looks as if windows could execute linux programs natively (but its just an ilusion though)
It looks like you installed ROR in the WSL-Ubuntu. And then installed RubyMine on windows. And then Rubymine tried to find the ROR-things in the windows directories but it did not found any. I guess its because Rubymine is not prepared to search within the WSL-Ubuntu for the ROR-things and so fails.
My second guess, is that the easiest solution could be to avoid using WSL-Ubuntu (as other programs wont be ready for it - currently it looks more of an experiment, not a real stable standard). And instead, try to do it all inside a Virtual-Box VirtualMachine, where you install ubuntu, all the programs you want (and they will run fine there), and avoid the WSL-mix. Even if this way requires a bit more work in the start - to prepare the VirtualBox and VM with ubuntu (youtube has many tutorials for this) - it will definitely save you time/headaches in the long-run when you need to install additional library/program/gem for your ROR environment

How to run eclipse on bash on Ubuntu on Windows?

I have eclipse installed on my windows machine, but I can't seem to use it with bash so I installed eclipse on the bash terminal by using "sudo apt-get install eclipse". It installed fine, but I can't figure out how to launch the eclipse GUI from the linux subsystem so I can use it like the windows version. I tried using Xming and exporting DISPLAY, but that didn't work. Any ideas?
from what i understood from the link below, you require to update .bashrc to direct the GUI display to a X Server process. I installed xMing to run X Server from Windows 10. i also had to install gtk components that allowed me to run sublime text GUI from within WSL.
https://medium.com/#pck/how-to-use-sublime-text-3-from-command-line-with-ubuntu-bash-terminal-in-windows-10-subsystems-for-aa2ad59d088c
hope this helps
IMHO you should not install eclipse by apt but simply get your desired eclipse product from from https://www.eclipse.org/downloads/packages , download and unzip it to your wanted location and just start eclipse.
Reasons:
I do not know any Linux distribution containing a newer eclipse bundled, so you are always having older versions being slower and having less features
You can update your eclipse installation directly inside eclipse Check for updates
You can have multiple installations at same time
If you want to get rid of a eclipse installation just remove the folder and you are done.
But of course you can also use bash directly in Windows with Eclipse.
Please look at
https://stackoverflow.com/a/62724163/2590615 or take a glimpse at You Tube Video about Bash Debugging with Bash Editor eclipse plugin on a Windows 10 machine
PS: I am the maintainer of the mentioned eclipse plugin

Why is git slow on my windows machine?

Just typing git at the command prompt (of powershell), takes 2.5 seconds until it returns with the help message.
I'm using the git for windows release, installed in C:\Program Files (x86)\Git. When I use cygwin (via babun), I get an error: Hint: your prompt is very slow. Check the installed 'BLODA' software. Maybe this is related? If it is, I'm using a corporate laptop, so can't uninstall antivirus or driver software, are there other options?
For me the reason seemed to be the "Inject ConEmuHk" setting in cmder under which I ran git. I've opened a bug https://github.com/bliker/cmder/issues/592
Try and see if the issue persists with the latest 2.4+ git for Windows release.
There is a bug related to the git bash startup time which is actively addressed.

Resources