Linux in Windows? (or how to run Ubuntu shell on Windows 10)
How many times have you been coding in visual studio code and type "touch someFile.js"? Or how about using "ls" in the CMD? Well, fear no more! Now you can use the Linux shell inside Windows 10! Woo-Hoo!. Let's check it out!
First, open your Microsoft Store and search for "LINUX" There will be an "ad"-type banner that has a call-to-action -- click on it. You will be given FOUR options to choose. This article will be based on UBUNTU. Why? I dunno, I use it for a lot of work. So, click on the image and download. AND STOP.
So you need to go into "Turn Windows features On or Off" and enable WINDOWS LINUX SUBSYSTEM...This will cause you to restart your machine. I suggest before you restart, either install the shell, or attach it to your taskbar so you are ready to install when your machine boots back up.
Upon restart, click your icon to install the image if you haven't done so already. Now the fun shit.
Wait, no fancy UI? NOPE. Just a shell. But for developers this is the shiiiiiit. If you don't know your basic CLI commands then I suggest you go download a cheat sheet. Or better yet, just go throw a website into production through AWS or Digital Ocean already! Seriously though, it won't be much fun without.
First, you'll notice that you aren't in your normal drive letter. Let's change that:
//mnt = mount && /c = drive letter
cd /mnt/c
BAM, now we're cooking. This gets you to 'C' drive on your windows system. from here, we can list all our contents, or 'cd' into your directory of choice and create a file:
touch myFile.txt // yes, this works now!
"But Nick, I wanna still use my shitty command prompt window!" Whaaa? Well have no fear! You have TWO options for working inside your CMD with your new shell:
//in your command prompt window
wsl.exe
This command launches you right into your ubuntu shell, AND into your current working directory! BUT WAIT, THERE'S MORE!
wsl touch myFile.txt // yep, it works
You can prefix 'wsl' followed by your command and type like a linux genius! What, you want it all, huh? You expect to just be typing commands for BOTH environments in the SAME LINE? AWWWWW SHIT, YES.....YOU....CAN!
C:\temp> wsl ls -la | findstr "foo"
-rwxrwxrwx 1 root root 14 Sep 27 14:26 foo.bat
// I snatched this from the docs due to time restraints
So, what is it? How can this be? Well, this has actually been in the works for a while, and my partner and I have been following it. But recently it's been getting mature enough to talk about. My favorite thing right now is running WSL in VS-CODE to install my developer tools like RVM and NVM, along with SASS and other tooling.
To find out more, head on over to the DOCS and get started. It's a great time to be a programmer, that's for sure. Until next time...