Installing WSL


Contents

    There is nothing better than kicking back with a nice Thinkpad running Linux on hard metal. However, I understand some people may want to take a softer approach when experimenting with Linux. Fortunately, Windows has a solution that lets us experience some of the greater parts of Linux without having a huge impact on your current system.

    There are countless guides out there that explain how to install WSL and plenty of guides out there about getting started with Linux. My goal for this article, though, is to walk you through the WSL setup, take you straight to an Arch Linux instance, and get you running with a cutting-edge, fully customized system. We will be learning about various package managers (and a particular package manager wrapper), we will be digging into config file, we will learn about some basic Linux file system structures, and more. I’ll talk about Ubuntu, but we won’t be using it. I’ll include some background on some of the topics, but I won’t go too much into details (I’ll let you know if you should google something).

    What is WSL?

    Google it.

    I’m kidding. WSL simply means “Windows Subsystem for Linux.” It is essentially running Linux in a virtual machine, just a little more streamlined. For one, the file system integrates with Windows file system seamlessly. While it is possible to run GUI (Graphical User Interface) apps with WSL, we will not be doing so in this guide. Everything will be entirely in the terminal, that is after WSL is installed.

    If you are interested in more details about WSL and how it differs from classic Virtual Machines it is worth a google search. Windows has comprehensive documentation on WSL, including a nice install guide with some tutorials if you prefer something more formal than what I will have here.

    Requirements

    If it isn’t obvious, you will need a system with Windows on it. Either Windows 10 or 11. As far as hardware, you can likely run WSL on any relatively modern machine. If you plan to run several browser tabs, edit some videos, or run some vector art software while running WSL, you may want a bit more memory and compute power.

    Virtualization

    Now according to Microsofts docs, running the install command is supposed to enable all the settings needed to run WSL. That has not been my experience. What the Microsoft documentation seems to fail to mention, is that hardware virtualization needs to be enabled in the systems BIOS in order to run WSL. Perhaps newer motherboards enable virtualization by default and Microsoft didn’t feel the need to mention it in their docs. However, if you enable all other settings, and it still is not working, you may need to enable virtualization in the BIOS. To do that, you will have to look up the instructions for your specific motherboard/device.

    You may also need to manually enable Hyper-V. To do this, you can pop open your start menu and start typing “Turn on” and an app should pop up that says “Turn Windows features on or off.” Open that up and look for the item labeled “Hyper-V” and check the box. Click okay and when prompted let the app restart your system.

    If you’ve successfully completed those two things, you shouldn’t have any problems moving on to the actual install.

    Install

    There are a couple of approaches you can take at this point. If you wish to grasp on to any GUI you can get, you can open up the Microsoft app store, search for WSL. Navigate to the page for the app and click “GET”. Or if you prefer to condition yourself for the command line, you can open up Windows PowerShell and type the command wsl --install. Both of these methods should get you to the same place. You should have the Linux environment ready to roll. But you still need to choose a distro to run in WSL. Again this can be done either in the app store or the command line. In the app store, back at the WSL search, you will see several apps representing the various available distro’s. The one I am going to point you to is Arch.

    Arch Linux

    If you are at all familiar with the Linux community, you may know that Arch has a bit of a reputation. But I assure you, the reason I’m using it here is for simplicity, which may seem counter-intuitive to those with experience with Arch Linux.

    Ubuntu has long been the go-to distro for those just entering the Linux world. It is a solid distribution that has been around for ages, and it has a huge community as well as a well funded company backing it. When you need to install Linux onto a computer, chances are if you try to install Ubuntu, it will just work. You will not likely run into a situation where a wrong click will bring your whole OS down. This is partly due to the way Ubuntu handles packages. A lot of what distinguishes distros from each other is their package manager and their respective package repositories. Distributions like Ubuntu spend a lot of time making sure that every package available to you via their package manager should work with your system without conflicting with anything. That means that when you download an app through their package manager, you are likely downloading a version that is several versions behind the most recent version. This isn’t always a bad thing, many apps add very few needed features with subsequent updates, and the more popular apps are usually tested and pushed to the repository in a timely manner. But there are a ton of apps that move extremely quickly, and the good folks at Ubuntu just can’t keep up. Which results in a lot of apps recommending installing without using your distro’s package manager.

    So just to recap. People use Ubuntu because it is stable. It is stable (partly) because it uses well tested software. We still want the newest software. We bypass the very thing that makes Ubuntu stable.

    So is there a distro that just uses that newest software all the time? Of course! There is a whole spectrum of distro’s with various levels of stability vs modernity. Arch Linux is on that far end of the spectrum utilizing the newest and greatest versions of software nearly immediately when they become available. If you are looking for a middle ground, a distro like Fedora is a great compromise. Fedora is a fantastic balance of stability with up to date packages.

    Arch, however, does not have a reputation of simplicity. It’s installation process is usually its biggest hurdle. It does not ship with a graphical installer and settings are generally entered manually. It is a grueling process, but it yields an intimate understanding of your system, and allows you take complete control of your OS. But that is not what I am here to walk you through. I am not trying to sell you on installing Arch on bare metal, I only want you to have easy access to the latest and greatest software.

    So Ubuntu is simple and sturdy, but getting the newest software introduces its own form of complexity. Arch is complex and unstable, but getting the newest software is simple. Fortunately, WSL makes this decision an easy one. Installation and setup of Arch is taken care of for you. Stability isn’t much of an issue, because it is just a virtual machine where all the files are accessible through the Windows file system. If you need to wipe the system, no loss, just grab what you need first.

    So you’ve installed WSL via that command line (wsl --install). Now to install Arch Linux, head to the Microsoft app store and search “Arch” or “Linux” or “WSL” or any combination of those key words. Skim the results until you find the “Arch Linux” WSL package. Click “GET” and let it do its thing. You can now launch Arch Linux as any other app on your computer via the Start menu or create a desktop shortcut if you wish. It will launch a command line window and the first launch will prompt you to set a user and a password for your virtual Linux system. I would also recommend downloading “Windows Terminal” from the Microsoft Store as it offers more features and is just a bit more modern than the default command line window.

    Pacman

    Now that you have a fresh install of Arch Linux, its time to get some things installed.

    When you read guides for linux online, you’ll often see commands that involve apt or sudo apt or possibly even apt-get. These commands are associated with the APT package manager. APT is the package manager used by Debian based distro, so by extension, APT is used by the ever popular Ubuntu. Since we are not using Ubuntu (or more specifically a Debian-based distro) we cannot use APT. Arch uses a package manager called Pacman. So, where on you Debian (or Ubuntu) you would use

    sudo apt install <package_name>
    

    on Arch we will use

    sudo pacman -S <package_name>
    

    (sudo is actually its own program that allows us to run commands as the super user without explicitly switching to the super user. It is unrelated to the package manager and you will see it used in conjunction with a wide variety of commands. Anytime you run a command with sudo within a session, you will be prompted to input the password you chose when setting up the system. It is worth noting that when you input the password at this prompt, no placeholder characters are displayed, so it will appear as if you are not typing anything.)

    If you don’t know the specific name of the package you are trying to install, you may use

    pacman -Ss <package_keyword>
    

    which should return a list of packages with the search terms either in the title or the description of the packages.

    Pacman is also used to update the system and all the packages you have installed. To do so use

    sudo pacman -Syu
    

    If you are running into errors with a mention of “invalid or corrupted package (PGP signature)” you will need to run

    sudo pacman -S archlinux-keyring
    

    Yay

    This portion is entirely unnecessary, and many will advice against this entirely, but I like to use a bit of software called Yay. Yay is what is known as a AUR helper program, and it’s purpose is to make it a little easier to install packages that reside in the Arch User Repository (AUR). The AUR is a community-driven repository that allows users to build packages from the source and then install it via pacman. AUR helpers like Yay take care of all that for you and allow you to install packages from the AUR as if they were regular packages in the official Arch repository. To install Yay, run

    pacman -S --needed git base-devel
    git clone https://aur.archlinux.org/yay-bin.git
    cd yay-bin
    makepkg -si
    

    Now every command you would pass to pacman you can now pass to yay but you can omit a few things like sudo. If yay needs super user privileges for its operations it will ask you. Also, to search a package before installing it you can simply run

    yay <keyword>
    

    Then you can select the package to install by choosing the associated number.

    Yay can also be used to update the system by simply running

    yay
    

    You should be all set to start installing software.

    ZSH

    Now I want to start getting you set up with some of the more exciting software. By default, the Linux command line runs a program called Bash. If you fiddle around with Linux enough, you’ll notice the term “shell” being used for several different things that seem somewhat unrelated. One such thing is the Linux command line environment. Without going into to much detail, the “sh” in Bash is short for “shell” and Bash is just certain flavor of the shell. It’s essentially the programming language used to interact with the Linux system via command line. Being the default on nearly all Linux distros, Bash is arguably the most popular shell. And it is really powerful. But there are alternatives that have just a few more features. ZSH is one such alternative.

    So lets install ZSH

    yay zsh
    

    You’ll get a huge list of packages, but the one you want is number 1 so you can simply hit “Enter” to select it. Hit “Enter” at the next two prompts and let it install. It will likely ask for your root password, input your password and hit enter.

    Now we will install an overkill of a plugin system called Oh My Zsh. Run

    sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    

    And again, install the first package.

    Now we want to make Zsh our default shell by running

    chsh -s $(which zsh)
    

    Now when you open the Arch Linux instance, you will automatically load into zsh. We will get into some further customization with zsh a little later. For now, lets get some other things setup.

    Dependencies

    I’m going to get you set with the best text editor of all time, but before we do that, there are a few things we want to install first, just to make things go a little smoother.

    Run the following command to install these packages

    yay -S nodejs npm lazygit ripgrep fd neovim
    

    This will install Node.js, Npm (the Node.js package manager), and a few other tools that will make things just a little fancier. That last one, neovim, is a big one. But as it is, you wont find it much fun. We’ll fix that.

    LazyVim

    As stated earlier, NeoVim IS the greatest text editor ever. But on its own, it can feel a bit barren. Part of what makes it so great though, is its ability to be sculpted and crafted to our specific needs. Now diving straight into the configs and building out your own setup can be quite the barrier. If you are up for the task, I highly recommend seeking out one of the many guides and doing so. But I understand most rational people will opt to bypass that process. For those individuals, there are NeoVim distros. Similar to Linux distros, NeoVim distros build upon the glory of the base program and provide a fully developed configuration. You still have the option to expand upon them and change options to your liking, but they deliver quite a pleasant experience out of the box. There are several options that you can look into, such as NvChad, kickstart.nvim, and LunarVim. LunarVim is an excellent option for beginners as it is quite a comprehensive distro with most everything you would ever want. NvChad may require a little more tweaking, and kickstart.nvim is more of just a scaffolding for you to build your own config out of. But today we are going to install LazyVim, which is a distro built on the latest and greatest lazy.nvim plugin manager. So lets get straight into it. Run

    git clone https://github.com/LazyVim/starter ~/.config/nvim
    

    Then run

    rm -rf ~/.config/nvim/.git
    

    And you are all set! Open it up by running

    nvim
    

    The first time starting it up, it will install a bunch of stuff. It shouldn’t take long, and you should soon be presented with the LazyVim landing screen. If you are not familiar with Vim and Vim motions, before you touch anything type :Tutor and follow the instructions given to you. Run through it a few times if you need to. Get the basics down and then move on. As times go on, you may want to revisit it and refresh your memory on some of the lesser used functions.

    Since you are using LazyVim and not just NeoVim, you have so preset shortcut keys. You can get a menu of some of them by pressing the spacebar (commonly referred to as the <leader> key). For a quick reference of the shortcuts head over to the docs.

    One tool you should be familiar with is :Mason. This will let you browse a list of LSP (language server protocols) among other things and install them with a single keystroke. If you aren’t familiar with LSP’s, they are the tools that provide text editors with hints and autofill options. The same LSP’s that VSCode uses are available in NeoVim, you’ve just got to find them and install them.

    Final Touches

    So now we have a proper text editor fully configured and ready to edit some text. We also have our fancy shell, but it doesn’t really feel any different. Let’s change that.

    In the Linux command line, run

    git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/plugins/zsh-autosuggestions
    

    And

    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
    

    Now I’m finally going to ask you to do something a little bit scary. You are going to edit a config file.

    nvim .zshrc
    

    When we installed Oh My ZSH earlier, that should have generated this file for you, so you should be seeing a fully populated file with a ton of comment blocks. You’ll want to scroll closer to the bottom (preferably using Vim motions) and you should see block of code that looks like this

    plugins=(git)
    

    Change that to look like this

    plugins=(
      git
      zsh-autosuggestions
      zsh-syntax-highlighting
    )
    

    While you are in here, you can change your prompt line theme if you’d like. Toward the top of the file there is a ZSH_THEME value, you can browse a list of themes and just punch in the name of the theme you want in this value. Most of them will work no problem, but some may require other plugins. I personally use “re5et”.

    Anyway, now you can save and quit (:wq) and running

    source ~/.zshrc
    

    You should now find your command line a little more colorful and helpful.


    And that’s it! It’s up to you now to research what your setup is capable of. From here I’d recommend looking through the LazyVim docs to see what you can change. A good first challenge is finding a new colorscheme and figuring out how to install it. Don’t be afraid to break things, and don’t be afraid to fix them. If things get too out of hand, blow it up, uninstall the whole Arch Linux instance and start over. The more you do it all, the more you understand all the tools you are working with.

    I also recommend following some the legends in the NeoVim space on Youtube, Twitch, and X. My suggestions are @ThePrimeagen and @teej_dv.

    If you’ve gotten this far, thanks for reading all this. I sincerely hope this was helpful and I truly hope it has sparked a curiosity in you. For me, coding with VSCode on Windows felt cold and shallow. Dragging myself into the world of Linux and NeoVim, I feel like I’ve learned so much about how these systems work.

    TLDR coming soon…