Getting Started With WSL
Tags: linux, beginners, productivity, dotnet
Published: 2020-02-15 22:26:27

---
title: Getting Started With WSL
published: true
description: Curious about how to run Linux inside of Windows? Here's how you can get started with Windows Subsystem for Linux 
tags: linux, beginner, productivity, dotnet
canonical_url: https://www.jeremymorgan.com/tutorials/linux/getting-started-windows-subsystem-linux/
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/f0g3gyohv5pzcgf92v18.jpg
---

Windows Subsystem for Linux (WSL) is awesome. 

It gives you the power to use Linux within your Windows system. A Linux shell can be difficult to learn, but the payoffs are incredible. You can become insanely productive with it. I encourage every Windows developer to give this a try. 

Early in my development career, I was a Unix/Linux developer, and I loved working with the [shell](http://bit.ly/LinuxCommandLineGuide). In 2010 I was thrust into the world of Windows with GUIS. There was PowerShell and some workarounds, but it wasn't quite the same. While I eventually gained proficiency and speed at first, it was a drag.

The most significant advantage of WSL right now is improving productivity and bringing powerful Linux programs directly to your Windows desktop. So let's try it out! 

## Get WSL

Open up PowerShell as an administrator:

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/dcdblfebaftz8n65g7hz.jpg)

Run the following command

```
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
```

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/w5xlee34ijll7ewxzp54.jpg)


Restart the machine as directed. 

Now we need to install a Linux system. You can find plenty of them in the Microsoft Store: 

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/4fspg2j81k2i9xgsgum6.jpg)

Or you can just install it on the command line. For this tutorial I'll be using Debian. You can install it from a PowerShell prompt with this command:

```
Invoke-WebRequest -Uri https://aka.ms/wsl-debian-gnulinux -OutFile Debian.appx -UseBasicParsing
.\Debian.appx
```

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/66t54bszreraaps7ndyt.jpg)

Now you'll be asked for a username and password. This doesn't have to be your Windows credentials, they're completely separate. 

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/q8ou5tjsxrrjv41p11rb.jpg)

After you enter that, you're done! You've installed Linux on your Windows system. 

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/1azqpyu3gnfaznxlvc5h.jpg)

You can find it in your start menu:  

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/r9npctbfm9199obsnp7l.jpg)

And it's ready to go!

## Install Terminal

So if you're going to be using WSL and doing prompt things, Windows Terminal is pretty awesome. Let's add that. Search the Windows Store for "Windows Terminal"

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/410ax7u57f13f6gfsekz.jpg)
  
Click "Get" then "Install"
  
With Terminal, you can keep PowerShell, command line, WSL prompts, and more all in one place. It's very convenient. 

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/n4h76t1fw1agyk1z4vkt.jpg)
  
So let's do some stuff! 

## The Basics
  
So if you've never used Linux before and want to know how to get around, you've come to the right place. Here are some basic commands you can use to get started. 

### Where am I?

You can find out where you're at on the file system by typing

```
pwd
```
Result:   

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/wwzh0se93iqjcp8t0vd2.jpg)

### Create a Folder

In Linux we call these "directories" and you create new ones by typing in

```
mkdir (name of directory)
```

We'll create one called "stuff". 

```
mkdir stuff
```
  
### Go into that Folder

Now let's go into that folder by typing in **cd** (change directory)

```
cd stuff
```

Now type in pwd and you can see we're in the "stuff" directory. 

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/dzbwp3xi0gyomhxrm0nh.jpg)

Let's create some files in that folder: 

```
touch file1.txt
```

The "touch" command creates an empty file with whatever name you specify. So now we have a blank file named "file1.txt"

Let's create a few more:

```
touch file2.txt file3.txt file4.txt
```

Now we have four files in the folder. But how would we know that?  
  
### Show all the files in a folder

We do that by typing in
```
ls -la
```


![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/s4y72lysuqggpx0uhi0t.jpg)

**ls** is the command to list the directory contents, and the **-la** tells it to list everything, including hidden files. 

We can see every file in the directory. 

Let's create a couple more files:

```
touch testfile1.org testfile2.org testfile3.org
```
  
Now we run ls and see our added files. 

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/3ifnb21dxegq518zul6s.jpg)

But what if we only want to see the .org files we just created?   
  
### Choosing Which Files to Show

We do that with wildcards (*), if we only want to see the .org files, we type in

```
ls *.org
```

The star means "everything," so we want everything with a filename that has .org at the end of it. 

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/b6esr0dxnx1a91z3v3q3.jpg)
  
If we only want to see files with the number 3 in them? 

```
ls *3*
```  
You can place wildcards anywhere in the string, so it shows every file name with a 3 in it:   
  
![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/7e15akqk4s6cdgn7un51.jpg)

Pretty cool huh? What if we want to remove a file?   

```
rm file2.txt 
```
rm will remove the file. If we type in ls we'll see that it's gone now:  

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/k6mpcj1kl2vtt0bjtdeu.jpg)
  
Wildcards also work with rm. We can remove all those .org files we just created:   
  
```
rm *.org
```
Now if we run ls -la again we can see the files are gone:

![Windows Subsystem for Linux WSL](https://dev-to-uploads.s3.amazonaws.com/i/p5w3xil4q2p4tfe020h8.jpg)

### Removing a Folder
  
So what if I want to remove this folder full of files I just created?   
  
To leave the folder and go back to my home folder, I type

```
cd ..
```

then type in

```
rm -rf stuff
```
And that removes the folder. Easy!

### Conclusion
  
So in this tutorial, we got familiar with WSL and how to use it. We did the following:  
  
- Enabled WSL
- Installed Debian Linux
- Installed Windows Terminal
- Created a folder
- Created empty files
- Deleted files

This is enough to get started navigating and moving things around. We're just scratching the surface of all the cool things you can do with WSL. If there's enough interest, I'll keep building more of these tutorials and expand on it.   
  
Want to know more about Linux Commands? Check out [this guide on Linux Command Line Fundamentals](http://bit.ly/LinuxCommandLineGuide)


[Let me know what you think](http://bit.ly/JeremyCMorgan) of this tutorial and some cool things you've done with WSL!!