You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: WSL/basic-commands.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,11 +15,11 @@ The WSL commands below are listed in a format supported by PowerShell or Windows
15
15
wsl --install
16
16
```
17
17
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`.
19
19
20
-
Options include:
20
+
Options include:
21
21
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`.
23
23
-`--no-launch`: Install the Linux distribution but do not launch it automatically.
24
24
-`--web-download`: Install from an online source rather than using the Microsoft Store.
25
25
@@ -54,7 +54,7 @@ See a list of the Linux distributions installed on your Windows machine, includi
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.
58
58
59
59
> [!WARNING]
60
60
> 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
65
65
wsl --set-default-version <Version>
66
66
```
67
67
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.
69
69
70
70
## Set default Linux distribution
71
71
@@ -97,7 +97,7 @@ To run a specific Linux distribution with a specific user, replace `<Distributio
97
97
wsl --update
98
98
```
99
99
100
-
Update your WSL version to the latest version. Options include:
100
+
Update your WSL version to the latest version. Options include:
101
101
102
102
-`--web-download`: Download the latest update from the GitHub rather than the Microsoft Store.
103
103
@@ -109,13 +109,13 @@ wsl --status
109
109
110
110
See general information about your WSL configuration, such as default distribution type, default distribution, and kernel version.
111
111
112
-
## Check WSL version
112
+
## Check WSL version
113
113
114
114
```powershell
115
115
wsl --version
116
116
```
117
117
118
-
Check the version information about WSL and its components.
118
+
Check the version information about WSL and its components.
119
119
120
120
## Help command
121
121
@@ -156,7 +156,7 @@ For example:
156
156
wsl --shutdown
157
157
```
158
158
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).
160
160
161
161
## Terminate
162
162
@@ -240,7 +240,7 @@ Attach and mount a physical disk in all WSL2 distributions by replacing `<DiskPa
240
240
wsl --unmount <DiskPath>
241
241
```
242
242
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.
Copy file name to clipboardExpand all lines: WSL/build-custom-distro.md
+69-63Lines changed: 69 additions & 63 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,19 +9,19 @@ ms.topic: how-to
9
9
10
10
This guide will walk through the steps to create and distribute a WSL distribution, which is a `.wsl` file.
11
11
12
-
WSL distributions have two parts:
12
+
WSL distributions have two parts:
13
13
14
14
1) A root filesystem (distributed as a tar file)
15
15
2) A manifest entry (which contains the distribution metadata)
16
16
17
17
This guide only applies to [WSL release 2.4.4](https://github.com/microsoft/WSL/releases) and higher.
18
18
19
19
> [!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.
21
21
22
22
## What are WSL root filesystem tar files?
23
23
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.
25
25
26
26
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.
27
27
@@ -32,7 +32,7 @@ Once you have a Linux system that you'd like to make into a WSL distribution, fo
32
32
There are two configuration files that the distribution should include:
33
33
34
34
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).
|`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>`|
67
67
|`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`|
68
68
|`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. |
72
72
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`:
74
74
75
75
```bash
76
76
#!/bin/bash
@@ -107,12 +107,11 @@ done
107
107
108
108
## Generate a Windows Terminal profile
109
109
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`.
111
111
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:
This file doesn’t need to specify the profile `name`, or `commandLine`. Those are automatically added by WSL when generating the terminal profile.
149
148
150
149
### Add a WSL configuration for local settings on a per-distribution basis
151
150
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.
153
152
154
-
```
153
+
```bash
155
154
# /etc/wsl.conf
156
155
157
156
[boot]
158
157
systemd=true|false
159
158
```
160
159
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).
162
161
163
162
See the [Systemd recommendations](#systemd-recommendations) if you chose to enable systemd by default.
164
163
165
164
See [Advanced settings configuration in WSL](./wsl-config.md) for all supported settings in `/etc/wsl.conf`.
166
165
167
166
### Create the tar file
168
167
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.
tar --numeric-owner --absolute-names -c *| gzip --best > ../install.tar.gz
176
175
```
177
176
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).
179
178
180
179
The recommended compression format is gzip. Other compression formats run the risk of breaking compatibility with older WSL versions.
181
180
@@ -199,78 +198,85 @@ The custom Linux distribution tar that you’ve created and renamed with a `.wsl
199
198
200
199
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>`.
201
200
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:
206
202
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
+
]
221
227
}
222
228
}
223
-
224
229
```
225
230
226
231
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.
227
232
228
-
See how `wsl --install` commands work with the below manifest:
233
+
See how `wsl --install` commands work with the below manifest:
229
234
230
-
```
235
+
```json
231
236
{
232
237
"ModernDistributions": {
233
238
"my-distro": [
234
239
{
235
-
"Name": "my-distro-v3",
240
+
"Name": "my-distro-v3",
236
241
"Default": true,
237
242
"FriendlyName": "My distribution version 3 (latest)"
238
-
[...]
243
+
[...]
239
244
},
240
245
{
241
-
"Name": "my-distro-v2",
246
+
"Name": "my-distro-v2",
242
247
"Default": false,
243
248
"FriendlyName": "My distribution version 2"
244
-
[...]
249
+
[...]
245
250
}
246
-
}
251
+
]
252
+
}
247
253
}
248
254
```
249
255
250
-
Sample install commands:
256
+
Sample install commands:
251
257
252
-
```
253
-
$ wsl --install my-distro # Installs 'my-distro-v3' since it's the default for 'my-distro' flavor
## Adding your distribution to `wsl --install` for all WSL users
259
265
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.
261
267
262
268
This pull request will be reviewed by the WSL team.
263
269
264
270
## Adding your distribution to `wsl --install` for your enterprise or business group
265
271
266
272
You can also make your distribution available in `wsl --install` only to a select group by editing registry keys on the chosen Windows devices.
267
273
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`.
269
275
270
276
-`DistributionListUrl`: Overrides the distribution manifest URL
271
277
-`DistributionListUrlAppend`: Add distributions from that manifest URL to the list of installable distributions
272
278
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.
274
280
275
281
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`.
0 commit comments