Are you a Windows power user, yet you've always missed bash like the one on Linux?
I consider myself a Windows power user. Personally I use it since Windows 95. As we all know, Windows had its ups and downs, especially with Windows ME and Vista, oh that slow and bugged Vista, we all remember that..., but Windows has come a long way introducing new features with the newest Windows Subsystem for Linux (WSL). Linux on Windows? What kind of sorcery is that? 🤔
We all love Linux, whether you are a system admin, developer or just a simple user, for sure you know the linux bash and how powerful it is compared to the Windows CMD. I mean, you can do basically anything with it and it just flies nicely, while on the contrary on Windows it lacks features and syntax is definitely not so good.
What I find great about WSL, is that it runs an entire distro in this subsystem, just like a Virtual Machine, but with native performance and with direct access to the Host file system and vice versa. Basically we have a Linux system in a window. We can even run X11 Gui applications, although for the scope of this article, I am going to set up a simple ReactJS environment with our Bash shell on Windows.
Let's get to work!
Disclaimer: You need at least Windows 10 1603
Go to your start menu and search for:Windows Features
Now Search for Windows Subsystem for linux
Now you need to Restart, so we can continue
After Restarting we can go to Microsoft Store, and search for our Distro. Type linux in the search , here are few:
- Kali Linux
You may ask, where is Arch Linux? Well, there isn't one on the Store, but you can deploy it. You can check how to do it here: https://github.com/yuk7/ArchWSL .
But since we are testing we don't want to configure every spec of it, so I chose Ubuntu, but you can choose anything else you want.
After Installation you can go to start menu or the install location path (might be different depending on your distro)
After installation you should see something like this:
As you can see we are in the root of a linux file system, to access your C:\ you can go to:
As you can see we are inside the windows file system now, using our lovely bash 😁
Now, let's assume that you want to deploy a Web Development Environment, so instead of bloating your Windows OS with all these packages, we are going to do that inside our WSL but in our Windows file system.
Let's install NodeJS, I'm going to use nvm, feel free to use whatever you want, then type this in the terminal:
After that you need to restart bash, then type:
To install NodeJS :
nvm install 10.14.2
Then you can check for node with:
Great, now we've installed nodeJS in our Linux SubSystem let's install create-react-app:
npm install -g create-react-app
After that, just follow the create-react-app instructions
Now use npm start or yarn start (if you installed it before) and watch your app deploy on your windows browser
As you can see, this is a great addition to Windows. It can maximize your workflow a lot. Now you can use your bash skills on Windows! You can deploy servers or other Linux based applications, inside Windows, without the need to bloat your OS, if you are a developer who likes trying new cutting-edge stuff, you are going to love this new feature.
But before I go, I have a bonus for you. Let's say that I am anywhere in the explorer and I want to access the bash? Let's add it to our context menu. Right click and we got a bash in that path! 🤯
Open up your Regedit and search:
Now Right-Click on Shell and name it "bash"
Edit the Key, and add the text you want, like "Open Bash Here"
Great! Now let's add another key but this time click on "bash" key instead of "shell", the one we created previously, name it "command", then on the (Default) key add this to the value data:
As you might have noticed, I got another Key called "Icon", you can add it as a path to any icon you want.
Great let's test it out! Right click on your explorer in any path and click "Open Bash" or however you named it.
Now, we can access Bash anywhere, and use it instead of cmd or powershell.
In summary, we talked a bit about the new WSL feature on Windows, we got it set up, and we deployed a ReactJS app, all from our linux SubSystem.
Try it out and see you next time!✌