Windows Subsystem for Linux (WSL)
Ever since Jessica Deen explained how WSL works at my SVDevOps Meetup, I’ve recommended Windows 10 users run Redis on their own dev machines. Yes, you heard right. Starting with Windows 10 (v1709–2017–09, Fall Creators Update), you can run at least a half-dozen flavors of Linux on the Windows Subsystem for Linux (WSL), and you can run Redis on top of them. No VM required. No Docker. No joke!
How do I know if I have Windows 10 with WSL?
To answer the question “Which version of Windows is my PC is running?” press your Windows logo key + R, type “winver,” then select OK. Starting with version 10, you’ve got a command called “wslconfig.” It lists distros you have and controls which one starts by typing “bash.” Try it out!
How to set up WSL!
- To enable Windows Subsystem for Linux, follow the instructions on Microsoft Docs. The short version is: In Windows 10, Microsoft replaces Command Prompt with PowerShell as the default shell. Open PowerShell as Administrator and run this command to enable Windows Subsystem for Linux (WSL):
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
- Reboot Windows after making the change — note that you only need to do this one time.
- Download and install one of the supported Linux distros from the Microsoft Store.
- Ubuntu 18.04 (installs Redis v4.09)
- Kali Linux (installs Redis v4.10)
- Debian GNU/Linux (installs Redis v3.2.6)
Install and Test Redis
- Launch the installed distro from your Windows Store and then install redis-server. The following example works with Ubuntu (you’ll need to wait for initialization and create a login upon first use):
> sudo apt-get update
> sudo apt-get upgrade
> sudo apt-get install redis-server
> redis-cli -v
2. Restart the Redis server to make sure it is running:
> sudo service redis-server restart
3. Execute a simple Redis command to verify your Redis server is running and available:
127.0.0.1:6379> set user:1 "Jane"
127.0.0.1:6379> get user:1
4. To stop your Redis server:
> sudo service redis-server stop
- How does Linux run within Windows 10? Instead of calling the Linux Kernel, the system calls (syscalls) that these unmodified Linux libraries use are redirected to Windows, which handles the call instead of Linux. For more information about WSL, visit the Windows Subsystem for Linux Documentation on MSDN.
- How do I access files stored in the Linux environment? If you want to edit Windows files in Windows AND in Linux, then keep your files in /mnt/c/ so you can edit them with either OS. Don’t use Windows to “reach into the Linux file system.” As Scott Hanselman says on his WSL blog post, “There be dragons!” For further information about the WSL storage, visit Jack Hammon’s blog post on MSDN titled “WSL File System Support.”
About The Author:
As Head of Ecosystem Programs, Dave engages with emerging technologies and open source projects like Microservices, Serverless & Kubernetes to bring the magic of Redis to the broader developer community. Dave has extensive ecosystem experience from his years of engagement in the web, cloud and big data communities. Prior to Redis Labs, Dave led the relationship between Intel’s Deep Learning in Apache Spark project and public cloud providers; and at PayPal where he helped pioneer web api developer evangelism. Dave is also co-founder of CloudCamp and several Silicon Valley user groups.