Want to learn Linux but don't know how/where to start? WSL may be a good option.
In 2018, Microsoft released the Windows Subsystem for Linux (WSL). WSL lets developers run the GNU/Linux
shell on a Windows 10 PC, a very convenient way to access the beloved tools, utilities and services Linux offers without the overhead of
a VM.
WSL is also the best way to learn Linux on Windows!
About WSL
Currently WSL supports Ubuntu, Debian, Suse and Kali distributions and can:- run bash shell scripts
- run GNU/Linux command-line applications including: vim, emacs, tmux
- run programming languages like JavaScript, Node.js, Ruby, Python, Golang, Rust, C/C++, C# & F#, etc.
- run background services like ssh shells, MySQL, Apache, lighttpd;
- install additional software using own GNU/Linux distribution package manager.
- invoke Windows applications.
- access your Windows filesystem
Installing WSL on Windows 10
Installing WSL is covered by Microsoft on this article and is as easy is two steps.Step 1 - Run a Powershell Command
On your Windows PC, you will need to run this PowerShell script as Administrator (shift + right-click):
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows -Subsystem-Linux
After the installation ends, restart your PC.
Step 2 - Install WSL from the Windows Store
After the reboot, WSL can be installed through the Windows Store. To open the Windows Store on your Windows 10, click:
Start -> Type Store -> Click on the Windows Store:
Then type "Linux" on the search box and you should get something similar results to this:Click on the icon, accept the terms and Windows will download and install WSL for you.
Running WSL
After installation started, you will be prompted to enter your username and password. After done, you'll get a cool Linux terminal to start playing with. You can even have multiple Distros installed on your Windows 10 machine. On mine, I installed Debian and Ubuntu.Using the Terminal
Okay, so now that we have access to our Linux shell, what to do next? Let's go through these use cases:- Accessing my Windows files
- Access internet resources
- I install software
Accessing Windows Files
WSL mounts your Windows files on the /mnt/c mount point. To verify on yours type mount on the command prompt and look for C: on it. Your windows files should be there.In case you don't know Linux, listing files is done with ls . This is the content of my C drive as as seen from WSL:
Accessing the Internet
Your WSL instance should have access to the internet. Testing the internet is as simple as doing a ping to Google:Installing Software
Installing software on Ubuntu/Debian is done by the apt command. For example, this is how we search packages:To install packages, use apt-get install. For example, to install Ruby on the Ubuntu WSL, run the command below:
sudo apt-get install ruby-full
Using git
We can leverage apt and install git with:
sudo apt-get install git
... # apt installs git
git --help # to get help
And, I'd recommend learn to use it on the terminal. Atlassian has an excellent tutorial to learn git.
... # apt installs git
git --help # to get help
Getting Help
Need help? The man tool is there to help you. For example, we could run the commands below to get help on git for example:
man git
Additional tip: try the new Windows Terminal
And, if you want to invest more time on your WSL, I'd suggest that you install the new Windows Terminal. Download the last release from GitHub and install it on your box. It's very customizeable and contains shells for WSL, PowerShell, Azure CLI and the traditional Windows terminal.What's next?
Now that you know how to locate your files, have access to the internet and installed some software, I'd recommend that you:- learn the basic GNU tools (cp, rm, ls, more, less, head, top, mount, etc);
- try to edit files with Vim or Nano;
- install software with apt (for Debian-based systems) and dnf (for RH/CentOS/Fedora);
- try some development (Python, Ruby, Go, Rust or C with gcc);
- try to install and run services such as MariaDB, nginx or Node.js;
- test out cool terminal tools like w3m, Ranger file manager, Reddit, DuckDuckGo on the terminal;
Conclusion
Congratulations! You have the WSL installed on your machine and now you have a Linux terminal to starting playing with. Now what? The first thing I'd recommend is to get comfortable with basic system commands, understand the filesystem, learn to add/remove software and run administrative tasks on the terminal. WSL is perfect for users who want to learn Linux and to those who spent a lot of time on Windows but need access to a Linux terminal.
If you want to know more about my setup, here's why I use Fedora Linux with the fantastic i3 window manager on the desktop and CentOS on servers. Happy hacking!
References
- WSL - FAQ
- WSL - Installing
- WSL - Documentation
- WSL - Command Line Reference
- An A-Z of Linux – 40 Essential Commands You Should Know
- Linux Command Line tips that every Linux user should know
- Must-Know Linux Commands For New Users
See Also
- My journey to 1 million articles read
- Why use Linux
- Why I use Fedora Linux
- How I fell in love with i3
- How to create a Ubuntu Desktop on Azure
- Why developers love Linux
- What is a Linux distribution
- Learn Vim
- Why use CentOS
- How to build and run ASP.NET Core apps on Linux
- How to install and run Docker on Linux
- How to create a CentOS Stream VM on Hyper-V
- How to create a CentOS VM on Azure