Skip to content

Commit d866b4c

Browse files
Merge pull request #2294 from MicrosoftDocs/main
Merge main to live
2 parents bb3e633 + 6f838f1 commit d866b4c

30 files changed

Lines changed: 1277 additions & 919 deletions

WSL/basic-commands.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ The WSL commands below are listed in a format supported by PowerShell or Windows
1515
wsl --install
1616
```
1717

18-
Install WSL and the default Ubuntu distribution of Linux. [Learn more](./install.md). You can also use this command to install additional Linux distributions by running `wsl --install <Distribution Name>`. For a valid list of distribution names, run `wsl --list --online`.
18+
Install WSL and the default Ubuntu distribution of Linux. [Learn more](./install.md). You can also use this command to install additional Linux distributions by running `wsl --install <Distribution Name>`. For a valid list of distribution names, run `wsl --list --online`.
1919

20-
Options include:
20+
Options include:
2121

22-
- `--distribution`: Specify the Linux distribution to install. You can find available distributions by running `wsl --list --online`.
22+
- `--distribution`: Specify the Linux distribution to install. You can find available distributions by running `wsl --list --online`.
2323
- `--no-launch`: Install the Linux distribution but do not launch it automatically.
2424
- `--web-download`: Install from an online source rather than using the Microsoft Store.
2525

@@ -54,7 +54,7 @@ See a list of the Linux distributions installed on your Windows machine, includi
5454
wsl --set-version <distribution name> <versionNumber>
5555
```
5656

57-
To designate the version of WSL (1 or 2) that a Linux distribution is running on, replace `<distribution name>` with the name of the distribution and replace `<versionNumber>` with 1 or 2. [Comparing WSL 1 and WSL 2](./compare-versions.md). WSL 2 is only available in Windows 11 or Windows 10, Version 1903, Build 18362 or later.
57+
To designate the version of WSL (1 or 2) that a Linux distribution is running on, replace `<distribution name>` with the name of the distribution and replace `<versionNumber>` with 1 or 2. [Comparing WSL 1 and WSL 2](./compare-versions.md). WSL 2 is only available in Windows 11 or Windows 10, Version 1903, Build 18362 or later.
5858

5959
> [!WARNING]
6060
> Switching between WSL 1 and WSL 2 can be time-consuming and result in failures due to the differences between the two architectures. For distributions with large projects, we recommend backing up files before attempting a conversion.
@@ -65,7 +65,7 @@ To designate the version of WSL (1 or 2) that a Linux distribution is running on
6565
wsl --set-default-version <Version>
6666
```
6767

68-
To set a default version of WSL 1 or WSL 2, replace `<Version>` with either the number 1 or 2. For example, `wsl --set-default-version 2`. The number represents the version of WSL to default to for new Linux distribution installations. [Comparing WSL 1 and WSL 2](./compare-versions.md). WSL 2 is only available in Windows 11 or Windows 10, Version 1903, Build 18362 or later.
68+
To set a default version of WSL 1 or WSL 2, replace `<Version>` with either the number 1 or 2. For example, `wsl --set-default-version 2`. The number represents the version of WSL to default to for new Linux distribution installations. [Comparing WSL 1 and WSL 2](./compare-versions.md). WSL 2 is only available in Windows 11 or Windows 10, Version 1903, Build 18362 or later.
6969

7070
## Set default Linux distribution
7171

@@ -97,7 +97,7 @@ To run a specific Linux distribution with a specific user, replace `<Distributio
9797
wsl --update
9898
```
9999

100-
Update your WSL version to the latest version. Options include:
100+
Update your WSL version to the latest version. Options include:
101101

102102
- `--web-download`: Download the latest update from the GitHub rather than the Microsoft Store.
103103

@@ -109,13 +109,13 @@ wsl --status
109109

110110
See general information about your WSL configuration, such as default distribution type, default distribution, and kernel version.
111111

112-
## Check WSL version
112+
## Check WSL version
113113

114114
```powershell
115115
wsl --version
116116
```
117117

118-
Check the version information about WSL and its components.
118+
Check the version information about WSL and its components.
119119

120120
## Help command
121121

@@ -156,7 +156,7 @@ For example:
156156
wsl --shutdown
157157
```
158158

159-
Immediately terminates all running distributions and the WSL 2 lightweight utility virtual machine. This command may be necessary in instances that require you to restart the WSL 2 virtual machine environment, such as [changing memory usage limits](/windows/wsl/disk-space) or making a change to your [.wslconfig file](./manage.md).
159+
Immediately terminates all running distributions and the WSL 2 lightweight utility virtual machine. This command may be necessary in instances that require you to restart the WSL 2 virtual machine environment, such as [changing memory usage limits](./disk-space.md) or making a change to your [.wslconfig file](./manage.md).
160160

161161
## Terminate
162162

@@ -240,7 +240,7 @@ Attach and mount a physical disk in all WSL2 distributions by replacing `<DiskPa
240240
wsl --unmount <DiskPath>
241241
```
242242

243-
Unmount a disk given at the disk path, if no disk path is given then this command will unmount and detach ALL mounted disks.
243+
Unmount a disk given at the disk path, if no disk path is given then this command will unmount and detach ALL mounted disks.
244244

245245
## Deprecated WSL commands
246246

WSL/build-custom-distro.md

Lines changed: 69 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ ms.topic: how-to
99

1010
This guide will walk through the steps to create and distribute a WSL distribution, which is a `.wsl` file.
1111

12-
WSL distributions have two parts:
12+
WSL distributions have two parts:
1313

1414
1) A root filesystem (distributed as a tar file)
1515
2) A manifest entry (which contains the distribution metadata)
1616

1717
This guide only applies to [WSL release 2.4.4]( https://github.com/microsoft/WSL/releases) and higher.
1818

1919
> [!NOTE]
20-
> See [this repository](https://github.com/microsoft/WSL-DistroLauncher) for the previous appx based distribution packaging instructions.
20+
> See [this repository](https://github.com/microsoft/WSL-DistroLauncher) for the previous appx based distribution packaging instructions.
2121
2222
## What are WSL root filesystem tar files?
2323

24-
WSL distributions are defined by a tar file with a `.wsl` file extension on Windows.
24+
WSL distributions are defined by a tar file with a `.wsl` file extension on Windows.
2525

2626
A TAR file (short for Tape Archive) is a type of archive file used to store multiple files together in a single file for easier distribution or backup. The TAR file contains the root file system of a Linux distribution (all the distribution files), as well as the WSL configuration files. WSL configuration files tell the WIndows operating system how to install and launch the distribution.
2727

@@ -32,7 +32,7 @@ Once you have a Linux system that you'd like to make into a WSL distribution, fo
3232
There are two configuration files that the distribution should include:
3333

3434
1. `/etc/wsl-distribution.conf`: A file created by the distribution maintainer responsible for controlling how the Linux distribution should be configured when first launched with WSL.
35-
2. `/etc/wsl.conf`: A file containing global system settings that are specific to the user and control how the distribution is launched. [Learn more about WSL configuration files.](/windows/wsl/wsl-config#what-is-the-difference-between-wslconf-and-wslconfig).
35+
2. `/etc/wsl.conf`: A file containing global system settings that are specific to the user and control how the distribution is launched. [Learn more about WSL configuration files.](./wsl-config.md).
3636

3737
### Add the WSL distribution configuration file
3838

@@ -57,20 +57,20 @@ enabled = true
5757
ProfileTemplate = /usr/lib/wsl/terminal-profile.json
5858
```
5959

60-
WSL distribution file configuration options:
60+
WSL distribution file configuration options:
6161

62-
| key | value | default | notes |
63-
|:-----------|:---------|:--------|:------|
64-
| `oobe.command` | string | `<none>` | OOBE stands for out of box experience. This command runs the first time the user opens an interactive shell in the distribution. If that command returns non zero, it is considered unsuccessful, and the user won't be able to open a shell. |
65-
| `oobe.defaultUid` | integer | `<none>` | The default UID that the distribution starts with. This is useful when the `oobe.command` script creates a new user. |
66-
| `oobe.defaultName`| string | `<none>` | The default name that the distribution is registered under. This default name can be replaced with the command: `wsl.exe --install <distro> --name <name>` |
62+
| Key | Value | Default | Notes |
63+
|:---|:---|:---|:---|
64+
| `oobe.command` | string | None | OOBE stands for out of box experience. This command runs the first time the user opens an interactive shell in the distribution. If that command returns non zero, it is considered unsuccessful, and the user won't be able to open a shell. |
65+
| `oobe.defaultUid` | integer | None | The default UID that the distribution starts with. This is useful when the `oobe.command` script creates a new user. |
66+
| `oobe.defaultName`| string | None | The default name that the distribution is registered under. This default name can be replaced with the command: `wsl.exe --install <distro> --name <name>` |
6767
| `shortcut.icon` | string | The default WSL icon | The icon in the start menu shortcut for the distribution. Must be in `.ico` format with a maximum size of `10MB` |
6868
| `shortcut.enabled` | boolean | true | Whether a start menu shortcut should be created when the distribution is installed. |
69-
| `windowsterminal.profileTemplate` | string | `<none>` | The JSON template to generate a Windows Terminal profile for this distribution. |
70-
| `windowsterminal.enabled` | boolean | true | Whether a terminal profile should be created when the distribution is installed. If `profileTemplate` is not set, a default profile will be generated. |
71-
| `windowsterminal.profileTemplate` | string | Path to a terminal template file | The JSON template to generate a Windows Terminal profile for this distribution. |
69+
| `windowsterminal.profileTemplate` | string | None | The JSON template to generate a Windows Terminal profile for this distribution. |
70+
| `windowsterminal.enabled` | boolean | true | Whether a terminal profile should be created when the distribution is installed. If `profileTemplate` is not set, a default profile will be generated. |
71+
| `windowsterminal.profileTemplate` | string | Path to a terminal template file | The JSON template to generate a Windows Terminal profile for this distribution. |
7272

73-
You need to create an out of box experience (OOBE) first run experience for the distribution. Below is a sample bash script that you can use. This script assumes that `oobe.defaultUid` is set to `1000`:
73+
You need to create an out of box experience (OOBE) first run experience for the distribution. Below is a sample bash script that you can use. This script assumes that `oobe.defaultUid` is set to `1000`:
7474

7575
```bash
7676
#!/bin/bash
@@ -107,12 +107,11 @@ done
107107

108108
## Generate a Windows Terminal profile
109109

110-
WSL automatically generates a Windows Terminal profile when a distribution is installed. Distribution maintainers can customize the generated profile generated by setting ` windowsterminal.profileTemplate` in the WSL configuration file, `/etc/wsl-distribution.conf`.
110+
WSL automatically generates a Windows Terminal profile when a distribution is installed. Distribution maintainers can customize the generated profile generated by setting `windowsterminal.profileTemplate` in the WSL configuration file, `/etc/wsl-distribution.conf`.
111111

112-
The json file follows [the terminal profile json format](/windows/terminal/json-fragment-extensions#structure-of-the-json-files). Here’s an example profile:
113-
114-
```
112+
The json file follows [the terminal profile json format](/windows/terminal/json-fragment-extensions#structure-of-the-json-files). Here’s an example profile:
115113

114+
```json
116115
{
117116
"profiles": [
118117
{
@@ -143,39 +142,39 @@ The json file follows [the terminal profile json format](/windows/terminal/json-
143142
}
144143
]
145144
}
146-
```
145+
```
147146

148147
This file doesn’t need to specify the profile `name`, or `commandLine`. Those are automatically added by WSL when generating the terminal profile.
149148

150149
### Add a WSL configuration for local settings on a per-distribution basis
151150

152-
In the context of a distribution root filesystem, we recommend that you configure systemd settings, including whether systemd starts by default, in the `/etc/wsl.conf` local settings on a per-distribution basis. See the example below.
151+
In the context of a distribution root filesystem, we recommend that you configure systemd settings, including whether systemd starts by default, in the `/etc/wsl.conf` local settings on a per-distribution basis. See the example below.
153152

154-
```
153+
```bash
155154
# /etc/wsl.conf
156155

157156
[boot]
158157
systemd=true|false
159158
```
160159

161-
The distribution author determines whether systemd is enabled by default by setting the `boot.systemd` value to `true` (enabled) or `false` (not enabled).
160+
The distribution author determines whether systemd is enabled by default by setting the `boot.systemd` value to `true` (enabled) or `false` (not enabled).
162161

163162
See the [Systemd recommendations](#systemd-recommendations) if you chose to enable systemd by default.
164163

165164
See [Advanced settings configuration in WSL](./wsl-config.md) for all supported settings in `/etc/wsl.conf`.
166165

167166
### Create the tar file
168167

169-
Once the distribution and configuration files are in place, the root filesystem can be captured in the tar file.
168+
Once the distribution and configuration files are in place, the root filesystem can be captured in the tar file.
170169

171170
The recommended way of creating the tar file:
172171

173-
```
174-
$ cd /path/to/rootfs
175-
$ tar --numeric-owner --absolute-names -c * | gzip --best > ../install.tar.gz
172+
```bash
173+
cd /path/to/rootfs
174+
tar --numeric-owner --absolute-names -c * | gzip --best > ../install.tar.gz
176175
```
177176

178-
The root of the tar should be the root of the filesystem (not a directory containing the root filesystem).
177+
The root of the tar should be the root of the filesystem (not a directory containing the root filesystem).
179178

180179
The recommended compression format is gzip. Other compression formats run the risk of breaking compatibility with older WSL versions.
181180

@@ -199,78 +198,85 @@ The custom Linux distribution tar that you’ve created and renamed with a `.wsl
199198

200199
The [distribution manifest](https://github.com/microsoft/WSL/blob/master/distributions/DistributionInfo.json) contains metadata about the distributions that are available for installation via `wsl --install <distribution>`.
201200

202-
Linux distributions that are tar-based are listed under `ModernDistribution`, with the below format:
203-
204-
```
205-
"ModernDistributions": {
201+
Linux distributions that are tar-based are listed under `ModernDistribution`, with the below format:
206202

207-
"<flavor>": [
208-
209-
{
210-
"Name": "<version name>",
211-
"FriendlyName": "<friendly name>",
212-
"Default": true | false,
213-
"Amd64Url": {
214-
"Url": "<tar url>",
215-
"Sha256": "<tar sha265 hash>"
216-
},
217-
"Arm64Url": {
218-
"Url": "<tar url>",
219-
"Sha256": "<tar sha265 hash>"
220-
}
203+
```json
204+
{
205+
"ModernDistributions": {
206+
"<flavor>": [
207+
{
208+
"Name": "<version name>",
209+
"FriendlyName": "<friendly name>",
210+
"Default": true | false,
211+
"Amd64Url": {
212+
"Url": "<tar url>",
213+
"Sha256": "<tar sha256 hash>"
214+
},
215+
"Arm64Url": {
216+
"Url": "<tar url>",
217+
"Sha256": "<tar sha256 hash>"
218+
}
219+
},
220+
{
221+
...
222+
}
223+
],
224+
"<flavor>": [
225+
...
226+
]
221227
}
222228
}
223-
224229
```
225230

226231
Each `flavor` entry contains a list of installable distributions. Distributions can be installed either via the flavor name (in which case the default entry is installed), or the version name.
227232

228-
See how `wsl --install` commands work with the below manifest:
233+
See how `wsl --install` commands work with the below manifest:
229234

230-
```
235+
```json
231236
{
232237
"ModernDistributions": {
233238
"my-distro": [
234239
{
235-
"Name": "my-distro-v3",
240+
"Name": "my-distro-v3",
236241
"Default": true,
237242
"FriendlyName": "My distribution version 3 (latest)"
238-
[...]
243+
[...]
239244
},
240245
{
241-
"Name": "my-distro-v2",
246+
"Name": "my-distro-v2",
242247
"Default": false,
243248
"FriendlyName": "My distribution version 2"
244-
[...]
249+
[...]
245250
}
246-
}
251+
]
252+
}
247253
}
248254
```
249255

250-
Sample install commands:
256+
Sample install commands:
251257

252-
```
253-
$ wsl --install my-distro # Installs 'my-distro-v3' since it's the default for 'my-distro' flavor
254-
$ wsl --install my-distro-v3 # Installs 'my-distro-v3' explicitly
255-
$ wsl --install my-distro-v2 # Installs 'my-distro-v2' explicitly
258+
```powershell
259+
wsl --install my-distro # Installs 'my-distro-v3' since it's the default for 'my-distro' flavor
260+
wsl --install my-distro-v3 # Installs 'my-distro-v3' explicitly
261+
wsl --install my-distro-v2 # Installs 'my-distro-v2' explicitly
256262
```
257263

258264
## Adding your distribution to `wsl --install` for all WSL users
259265

260-
To make your WSL distribution available to all users, open a pull request on the [WSL GitHub repository](https://github.com/microsoft/wsl) that modifies the [DistributionInfo.json](https://github.com/microsoft/WSL/blob/master/distributions/DistributionInfo.json) file to include your distribution information.
266+
To make your WSL distribution available to all users, open a pull request on the [WSL GitHub repository](https://github.com/microsoft/WSL) that modifies the [DistributionInfo.json](https://github.com/microsoft/WSL/blob/master/distributions/DistributionInfo.json) file to include your distribution information.
261267

262268
This pull request will be reviewed by the WSL team.
263269

264270
## Adding your distribution to `wsl --install` for your enterprise or business group
265271

266272
You can also make your distribution available in `wsl --install` only to a select group by editing registry keys on the chosen Windows devices.
267273

268-
The WSL distribution manifest can be overridden by creating registry values in `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss`.
274+
The WSL distribution manifest can be overridden by creating registry values in `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss`.
269275

270276
- `DistributionListUrl`: Overrides the distribution manifest URL
271277
- `DistributionListUrlAppend`: Add distributions from that manifest URL to the list of installable distributions
272278

273-
Both registry values are strings (REG_SZ) and are expected to be in URL format.
279+
Both registry values are strings (REG_SZ) and are expected to be in URL format.
274280

275281
Starting with WSL release 2.4.4, the `file://` protocol is supported to make local testing easier. The expected format is: `file:///C:/path/to/file`.
276282

@@ -313,7 +319,7 @@ $manifestFile = "$PSScriptRoot/manifest.json"
313319
$manifest | ConvertTo-Json -Depth 5 | Out-File -encoding ascii $manifestFile
314320
315321
316-
Set-ItemProperty -Path "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss" -Name DistributionListUrl -Value "file://$manifestFile" -Type String -Force
322+
Set-ItemProperty -Path "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss" -Name DistributionListUrl -Value "file://$manifestFile" -Type String -Force
317323
```
318324

319325
Then configure the local manifest by running the following command in an elevated Powershell:
@@ -351,7 +357,7 @@ When you're done, you can delete `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
351357

352358
### Systemd recommendations
353359

354-
If systemd is enabled, units that can cause issues with WSL should be disabled or masked.
360+
If systemd is enabled, units that can cause issues with WSL should be disabled or masked.
355361
The below units are known to cause issues in WSL distributions (applies to both system and user units):
356362

357363
- systemd-resolved.service

0 commit comments

Comments
 (0)