You know how to whistle, don’t you? Just put your lips together and blow. Well installing WSL is nearly as easy and can up your efficiency and expand your toolset.
Throughout my career I’ve found myself constantly seeking more efficiency; Better, faster, easier ways to accomplish my tasks. I’ve found many tools and methods, and sometimes they’ve only been available for Linux. I’m comfortable with a command line, whether it’s Windows command prompt, Powershell, IOS/IOS XE/NXOS, and yes, even Linux amongst many others. I feel like my job has always required me to use some kind of Windows program so I’ve tried a number of ways to allow me to use both Windows and Linux tools. I’ve tried a multi-boot system where I could boot into either Windows or Linux, I’ve used a Mac (with its built-in Linux-like shell) running Parallels for my Windows programs, and most recently I’ve used Windows and connected to a virtual machine running Linux when I’ve needed to use those tools.
In all my workarounds though, there’s always been some kind of sacrifice whether it be partial functionality, the battle to securely get files from one system to another, or issues accessing systems when I’m working on location rather than from my office. Today I’d like to tell you about running Linux on your Windows machine and show you a couple Linux tools that might just change your life. The only sacrifice I’ve found is the laughably minimal disk space it takes up. Depending on your internet connection, you could be trying WSL in less than10 minutes.
Getting Started
Part 1 of 3: Enabling WSL
Let me walk you through enabling Windows Subystem for Linux or WSL (It’s so much easier than you’d expect!)
- This will require Windows 10 version 1607 or higher (including Windows 11)
- Enable WSL
I. Graphical Installation:
a. Go to Turn Windows features on or off (you can search for “turn”)
b. or hit windows key + r and run “appwiz.cpl”, then select Turn Windows features on or off
c. Scroll down & check “Windows Subsystem for Linux”
- Powershell Installation:
I. Run the following command:
II. dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart - Celebrate at the speed with which you’ve completed such a task!
Part 2 of 3: Choosing and installing a Linux Distribution
Next, you’ll need to choose a distro. I believe Ubuntu is the most common right now, but Debian or Kali Linux are also good choices. I won’t go into any detail here on the difference between them, but I encourage you to try one out and feel free to learn as you go.
- Open the Microsoft Store
- Search for Linux
- Choose your poison & “Get” it. I’m using Ubuntu for my example:
- You should see it download and give you a status of the progress
- Once that’s finished, it should change to “Open”, if you click on it, you’ll get a new window with your new Linux command line
- Another way to open your linux command line is to open your Windows command line and type “wsl”
- Another way to open your linux command line is to open your Windows command line and type “wsl”
Part 3 of 3: Use it!
Now that you have your very own WSL running Linux, let me show you a couple of my favorite Linux tools. It’s worth noting that when you go into the WSL CLI, it shows you the path you’re currently in which is /mnt/c/Users/[your username]. Your Windows C drive was mounted to Linux as /mnt/c so you can access any files on your computer and use the built-in or added in Linux tools with them.
Grep
Grep is my favorite search tool. I am admittedly a total noob because it has so many options and more functionality that I’m not familiar with yet, but let me introduce you if you haven’t used it before. It is so much faster than Windows search when I’m looking for something in logs or other files. To use it, you call grep, pass any options, then specify one or more files to search through. I’ll be passing ./* which specifies all the files in the current directory.
- If you type “man grep” it will open the manual for you to learn the tool’s options (POWER MOVE: open the manual in one window for reference and open another window to work in). Pressing ‘q’ will get you out of the manual and take you back to the CLI.
- For a simple example, I created a couple files and will show you a couple commands.
- -i option (ignore case) will find the text in single quotes without case sensitivity.
- -n option will add line numbers
- This also works with IP addresses
- -i option (ignore case) will find the text in single quotes without case sensitivity.
Nano
Nano is an easy to use command line text editor (manual available by typing ‘man nano’). You can use it to create or modify text files. Because it’s command-line based, it uses all keyboard commands and can be a lot faster than notepad for text editing. There may be a bit of a learning curve, but I think in the long run it has saved me a LOT of time. If you’re feeling REALLY adventurous, try vim or vi which is like the notepad++ of command line text editors.
Less
Less is another command line search tool that I use for logs when I’m not positive what I’m looking for that lets me quickly peruse and search (manual available by typing ‘man less’). You just type ‘less [filename]’. Once you’re in a file, you can hit ‘h’ to show help, search for text, open multiple files, search and navigate. This is another tool that I think pays dividends in invested learning time.
Conclusion
I hope someone finds this useful as it has really simplified my work and I wanted to share. It is unbelievably easy to get started with and provides SO much value in my opinion for so little work. I’d also like to publicly thank the person that shared it with me (you know who you are).
LookingPoint offers multiple IT services if you’re interested. Want more information, give us a call! Please reach out to us at sales@lookingpoint.com and we’ll be happy to help!
Ryan Alibrando, Managed Services Team Lead