Skip to content

WSL custom distribution naming convention

A custom naming convention is utilized when managing Windows Subsystem for Linux (WSL) instances to distinguish between different environments or specific user configurations. Instead of relying on default names, users can assign a specific name during the import process using the --import command^[600-developer-tools-windows-wsl-command.md].

Syntax

The custom name is defined by the first argument passed to the --import command^[600-developer-tools-windows-wsl-command.md].

wsl --import [DistributionName] [InstallLocation] [FileName]

For example, to create a distribution named "U20.04-tommy" for a specific user, the command would be^[600-developer-tools-windows-wsl-command.md]:

wsl --import U20.04-tommy D:\install\wsl-work\storage\Ubuntu-20.04-tommy D:\install\wsl-work\image\Ubuntu-20.04-20220121.tar

Management Operations

Once a custom distribution name is established, it is used as the target identifier for subsequent management commands^[600-developer-tools-windows-wsl-command.md].

  • Termination: To stop a specific instance, use wsl --terminate [DistributionName]^[600-developer-tools-windows-wsl-command.md].
  • User Access: To run a specific distribution as a specific user (e.g., root), use the -d flag: wsl -d [DistributionName] -u [UserName]^[600-developer-tools-windows-wsl-command.md].
  • Listing: To view all registered distributions and their states, use wsl --list --verbose^[600-developer-tools-windows-wsl-command.md].
  • Unregistration: To delete a distribution, use wsl --unregister [DistributionName]^[600-developer-tools-windows-wsl-command.md].

Sources

  • 600-developer-tools-windows-wsl-command.md