# WSL

## Basic Operation

### Build a wsl

在微软商店中直接安装即可。\
![](https://i.niupic.com/images/2020/03/30/7c0a.png)

以下的操作以 Ubuntu-18.04 为例，可以通过 `wsl -l` 查看自己安装的WSL。

### Run a wsl

```bash
wsl --distribution Ubuntu-18.04-20190707

or

wsl -d Ubuntu-18.04-20190707
```

### Remove a wsl

```bash
wsl --unregister Ubuntu-18.04-20190707
```

### Terminate a wsl

```bash
wsl -t Ubuntu-18.04-20190707

or 

wsl --terminate Ubuntu-18.04-20190707
```

### Back up a wsl

```bash
wsl -t Ubuntu-18.04-20190707 // 必须先停止要备份的WSL
wsl --export Ubuntu-18.04-20190707 path/to/your/backup
```

### Recover a wsl

```bash
wsl --import Ubuntu-18.04-20190707 path/to/your/wsl/location path/to/your/backup
```

注意这里有两个地址的参数，第一个是定义安装WSL在哪里，第二个是WSL的备份在哪里，**可以通过删除再重新定义存放WSL的路径的方式来减少WSL对C盘的占用**。

## Reference

1. [简书 | 简单到极致！Windows 10 Ubuntu子系统的备份/还原教程来了](https://www.jianshu.com/p/8b4ec8fafdca) &#x20;
2.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://legacy.cookielau.com/archives/4-linux/2-wsl.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
