Almenon
Posted on April 13, 2019
For the past couple years I have worked entirely in the microsoft stack. Typescript. C#. VB. MSSQL. IIS. Azure. and the list goes on…
But now I’ve joined a new company and they don’t use windows at all. It’s a total paradigm shift. JS instead of TS. Python instead of C#. Postgres instead of MSSQL. Nginx and AWS instead of IIS and Azure.
I could say bye to windows. With thermite and a raft I could give my PC a decent viking burial. Then I would use a macbook air and sit in a coffee shop and say goodbye to ☕ENTERPRISE DEV☕ and become ⚡ROCKSTAR HACKER⚡.
But you know what? Over the years I’ve become a bit fond of windows. It's clunky. It's slow. But I grew up with it, damn it. So……
Enter WSL, the Windows Subsystem for Linux, also known under its much more awkward acronym, BOUOW. With this bad boy you can have a full blown ubuntu system in the same environment as windows! Hooray! Problem Solved!
But not so fast. You still have to learn all the new linux concepts and commands. And get ready for a clown car full of bugs….
For starters, let’s assume you installed ubuntu, upgraded it, and have the terminal up and ready to go. Or have shelled out a few bucks for wlinux. Next you should find a basic linux terminal tutorial and follow that, getting used to cd'ing to directories, ls'ing to see items, the basic stuff. Once you've mastered the basics you can put some handy dandy aliases in your .profile:
Restart your terminal and test out a alias or two to make sure they work.
Then add a softlink to your windows drive. For me I used the below command:
ln -s dev /mnt/c/dev
Now you can cd into your windows dev folder. (you might need to make the dev folder in Windows first)
But be warned, because WSL / windows interoperability is still pretty buggy. I suggest keeping the two systems as separate as possible, even if it means re-installing stuff on your ubuntu subsystem.
If you want to interact with windows from ubuntu regardless, keep these things in mind:
If you try doing git status on a windows repo, it will report all the files as modified. To fix this set the following in your repo:
git config --local core.autocrlf true
git config --local core.filemode false
If you ever need to use chmod or deal with permissions in the windows filesystem follow this stackoverflow: https://superuser.com/a/1343737/890079
see this blog post for more details.
you can invoke windows utilities through cmd /C. For example, cmd.exe /C echo hello world . Or you can invoke utilities directly by specifying .exe, like so: ipconfig.exe | grep IPv4 | cut -d: -f2
Vice-versa, you can invoke linux utilities on windows through wsl command.
Docker doesn’t work well in WSL 1, along with some other miscellaneous feature and apps that don’t function properly. For docker you need WSL 2.
Last of all, if you’re new to linux you probably want a handy reference to look up documentation on linux utilties. There is the man command, of course (man ls to see ls docs) but it can be a lot to read. I would suggest also downloading cheat. cheat command will give you plenty of useful examples that you can use to quickly get up to speed. For starters, try out cheat grep.
So to sum it all up, is WSL worth the hassle? If you're going to be using WSL primarily, no. I regret not just setting up a ubuntu dual-boot straightaway, and that's what I eventually ended up doing. But if you are working a minority of the time in WSL or just playing around with it, then I would heartily recommend it.
Posted on April 13, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.