- Справочник по командам для WSL
- Основные команды
- Установка
- Установка определенного дистрибутива Linux
- Список доступных дистрибутивов Linux
- Список установленных дистрибутивов Linux
- Указание версии WSL (1 или 2)
- Указание версии WSL по умолчанию
- Указание дистрибутива Linux по умолчанию
- Запуск определенного дистрибутива Linux из PowerShell или CMD
- Обновление WSL
- Проверка состояния WSL
- Команда help
- Домашний каталог
- Shutdown
- Завершение
- Экспорт дистрибутива в TAR-файл
- Импорт нового дистрибутива
- Отмена регистрации или удаление дистрибутива Linux
- Подключение диска или устройства
- Command reference for WSL
- Basic commands
- Install
- Install a specific Linux distribution
- List available Linux distributions
- List installed Linux distributions
- Set WSL version to 1 or 2
- Set default WSL version
- Set default Linux distribution
- Run a specific Linux distribution from PowerShell or CMD
- Update WSL
- Check WSL status
- Help command
- Home directory
- Shutdown
- Terminate
- Export a distribution to a TAR file
- Import a new distribution
- Unregister or uninstall a Linux distribution
- Mount a disk or device
- Command reference for WSL
- Basic commands
- Install
- Install a specific Linux distribution
- List available Linux distributions
- List installed Linux distributions
- Set WSL version to 1 or 2
- Set default WSL version
- Set default Linux distribution
- Run a specific Linux distribution from PowerShell or CMD
- Update WSL
- Check WSL status
- Help command
- Home directory
- Shutdown
- Terminate
- Export a distribution to a TAR file
- Import a new distribution
- Unregister or uninstall a Linux distribution
- Mount a disk or device
Справочник по командам для WSL
Ниже приведены основные команды WSL в формате, поддерживаемом PowerShell или командной строкой Windows. Чтобы выполнить эти команды из командной строки дистрибутива Bash или Linux, измените wsl на wsl.exe .
Основные команды
После установки WSL поддерживаются следующие основные команды.
Установка
Устанавливает WSL и дистрибутив Linux Ubuntu. Подробнее.
Установка определенного дистрибутива Linux
Назначьте дистрибутив Linux для установки помимо установленного по умолчанию (Ubuntu), заменив именем дистрибутива. Эту команду можно также указать так: wsl -d .
Список доступных дистрибутивов Linux
Выводит список дистрибутивов Linux, доступных в интернет-магазине. Эту команду можно также указать так: wsl -l -o .
Список установленных дистрибутивов Linux
Выводит список дистрибутивов Linux, установленных на компьютере под управлением Windows, в том числе состояние (независимо от того, запущен дистрибутив или остановлен) и версию WSL, в которой работает дистрибутив (WSL 1 или WSL 2). Применяется в WSL 1 и WSL 2. Эту команду можно также указать так: wsl -l -v . Дополнительные параметры, которые можно использовать с командой list: —all — для перечисления всех дистрибутивов, —running — для вывода списка только тех дистрибутивов, которые запущены в данный момент, —quite — для отображения только имен дистрибутивов.
Указание версии WSL (1 или 2)
Чтобы указать версию WSL (1 или 2), в которой работает дистрибутив Linux, измените на имя дистрибутива, а — на число 1 или 2. Применяется в WSL 1 и WSL 2.
Указание версии WSL по умолчанию
Чтобы задать WSL 1 или WSL 2 как версию по умолчанию, измените на число 1 или 2, чтобы указать версию WSL, которая будет использоваться по умолчанию для установки новых дистрибутивов Linux. Например, wsl —set-default-version 2 . Применяется в WSL 1 и WSL 2.
Указание дистрибутива Linux по умолчанию
Чтобы задать дистрибутив Linux по умолчанию, который команды WSL будут использовать для запуска, измените на имя предпочитаемого дистрибутива Linux.
Запуск определенного дистрибутива Linux из PowerShell или CMD
Чтобы запустить определенный дистрибутив Linux от имени конкретного пользователя, измените на имя предпочитаемого дистрибутива Linux (например, Debian), а — на имя существующего пользователя (например, root). Если указанный пользователь не существует в дистрибутиве WSL, появится сообщение об ошибке. Чтобы ввести имя текущего пользователя, выполните команду whoami .
Обновление WSL
Позволяет обновить версию ядра WSL Linux вручную. Можно также использовать команду wsl —update rollback для отката к предыдущей версии ядра WSL Linux.
Проверка состояния WSL
Отображает общие сведения о конфигурации WSL, такие как тип дистрибутива по умолчанию, дистрибутив по умолчанию и версия ядра.
Команда help
Отображает список параметров и команд, доступных в WSL.
Домашний каталог
можно использовать с WSL для запуска в домашнем каталоге пользователя. Чтобы в командной строке WSL вернуться в домашний каталог из другого, можно использовать команду cd
Shutdown
Немедленно завершает работу всех запущенных дистрибутивов и облегченной служебной виртуальной машины с WSL 2. Эта команда может потребоваться в экземплярах, требующих перезапуска среды виртуальных машин WSL 2, например при изменении ограничений использования памяти или внесении изменений в файл .wslconfig.
Завершение
Чтобы завершить работу определенного дистрибутива или остановить его выполнение, замените именем нужного дистрибутива.
Экспорт дистрибутива в TAR-файл
Экспорт дистрибутива в TAR-файл. Именем файла может быть «-» для стандартного вывода.
Импорт нового дистрибутива
Импорт указанного TAR-файла в качестве нового дистрибутива. Именем файла может быть «-» для стандартного ввода. С этой командой также можно использовать параметр —version , чтобы указать, где будет выполняться импортированный дистрибутив: в WSL 1 или WSL 2.
Отмена регистрации или удаление дистрибутива Linux
Позволяет отменить регистрацию определенного дистрибутива или удалить его, заменив именем целевого дистрибутива. Это приведет к удалению дистрибутива из WSL, а также всех связанных данных. Вы также можете удалить приложение дистрибутива Linux на компьютере под управлением Windows так же, как и любое другое приложение из Store.
Подключение диска или устройства
Позволяет подключить физический диск во всех дистрибутивах WSL 2, изменив на путь к каталогу или файлу, где расположен диск. См. статью Подключение диска Linux в WSL 2. Возможны следующие значения.
- wsl —mount —bare : подключение диска к WSL 2 без подключения к файловой системе.
- wsl —mount —type : тип файловой системы, используемой при подключении диска, если не указано значение по умолчанию (ext4). Эту команду можно также указать так: wsl —mount -t . Тип файловой системы можно определить с помощью команды blkid , например: blkid .
- wsl —mount —partition
: номер раздела для подключения согласно индексу, если не указан вариант по умолчанию (весь диск).
Источник
Command reference for WSL
The basic WSL commands below are listed in a format supported by PowerShell or Windows Command Prompt. To run these commands from a Bash / Linux distribution command line, you must replace wsl with wsl.exe .
Basic commands
The following basic commands are supported after installing WSL.
Install
Install WSL and the Ubuntu distribution of Linux. Learn more.
Install a specific Linux distribution
Designate a distribution of Linux for installation besides the default (Ubuntu) by replacing with the name of the distribution. This command can also be entered as: wsl -d .
List available Linux distributions
See a list of the Linux distributions available through the online store. This command can also be entered as: wsl -l -o .
List installed Linux distributions
See a list of the Linux distributions installed on your Windows machine, including the state (whether the distribution is running or stopped) and the version of WSL running the distribution (WSL 1 or WSL 2). Comparing WSL 1 and WSL 2. This command can also be entered as: wsl -l -v . Additional options that can be used with the list command include: —all to list all distributions, —running to list only distributions that are currently running, or —quite to only show distribution names.
Set WSL version to 1 or 2
To designate the version of WSL (1 or 2) that a Linux distribution is running on, replace with the name of the distribution and replace with 1 or 2. Comparing WSL 1 and WSL 2.
Set default WSL version
To set a default version of WSL 1 or WSL 2, replacing with either the number 1 or 2 to represent which version of WSL you would like the installation to default on for new Linux distribution installations. For example, wsl —set-default-version 2 . Comparing WSL 1 and WSL 2.
Set default Linux distribution
To set the default Linux distribution that WSL commands will use to run, replace with the name of your preferred Linux distribution.
Run a specific Linux distribution from PowerShell or CMD
To run a specific Linux distribution with a specific user, replace with the name of your preferred Linux distribution (ie. Debian) and with the name of an existing user (ie. root). If the user doesn’t exist in the WSL distribution, you will receive an error. To print the current user name, use the command whoami .
Update WSL
Manually update the version of your WSL Linux kernel. You can also use the command: wsl —update rollback to rollback to a previous version of the WSL Linux kernel.
Check WSL status
See general information about your WSL configuration, such as default distribution type, default distribution, and kernel version.
Help command
See a list of options and commands available with WSL.
Home directory
can be used with wsl to start in the user’s home directory. To jump from any directory back to home from within a WSL command prompt, you can use the command: cd
Shutdown
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 or making a change to your .wslconfig file.
Terminate
To terminate the specified distribution, or stop it from running, replace with the name of the targeted distribution.
Export a distribution to a TAR file
Exports the distribution to a tar file. The filename can be — for standard output.
Import a new distribution
Imports the specified tar file as a new distribution. The filename can be — for standard input. The —version option can also be used with this command to designate whether the imported distribution will run on WSL 1 or WSL 2.
Unregister or uninstall a Linux distribution
Unregister or uninstall the specific distribution by replacing with the name of the targeted distribution. This will remove the distribution from WSL and delete all of the associated data. You can also uninstall the Linux distribution app on your Windows machine just like any other store application.
Mount a disk or device
Attach and mount a physical disk in all WSL2 distributions by replacing with the directory\file path where the disk is located. See Mount a Linux disk in WSL 2. Options include:
- wsl —mount —bare : Attach the disk to WSL2, but don’t mount it.
- wsl —mount —type : Filesystem type to use when mounting a disk, if not specified defaults to ext4. This command can also be entered as: wsl —mount -t .You can detect the filesystem type using the command: blkid , for example: blkid .
- wsl —mount —partition
: Index number of the partition to mount, if not specified defaults to the whole disk.
Источник
Command reference for WSL
The basic WSL commands below are listed in a format supported by PowerShell or Windows Command Prompt. To run these commands from a Bash / Linux distribution command line, you must replace wsl with wsl.exe .
Basic commands
The following basic commands are supported after installing WSL.
Install
Install WSL and the Ubuntu distribution of Linux. Learn more.
Install a specific Linux distribution
Designate a distribution of Linux for installation besides the default (Ubuntu) by replacing with the name of the distribution. This command can also be entered as: wsl -d .
List available Linux distributions
See a list of the Linux distributions available through the online store. This command can also be entered as: wsl -l -o .
List installed Linux distributions
See a list of the Linux distributions installed on your Windows machine, including the state (whether the distribution is running or stopped) and the version of WSL running the distribution (WSL 1 or WSL 2). Comparing WSL 1 and WSL 2. This command can also be entered as: wsl -l -v . Additional options that can be used with the list command include: —all to list all distributions, —running to list only distributions that are currently running, or —quite to only show distribution names.
Set WSL version to 1 or 2
To designate the version of WSL (1 or 2) that a Linux distribution is running on, replace with the name of the distribution and replace with 1 or 2. Comparing WSL 1 and WSL 2.
Set default WSL version
To set a default version of WSL 1 or WSL 2, replacing with either the number 1 or 2 to represent which version of WSL you would like the installation to default on for new Linux distribution installations. For example, wsl —set-default-version 2 . Comparing WSL 1 and WSL 2.
Set default Linux distribution
To set the default Linux distribution that WSL commands will use to run, replace with the name of your preferred Linux distribution.
Run a specific Linux distribution from PowerShell or CMD
To run a specific Linux distribution with a specific user, replace with the name of your preferred Linux distribution (ie. Debian) and with the name of an existing user (ie. root). If the user doesn’t exist in the WSL distribution, you will receive an error. To print the current user name, use the command whoami .
Update WSL
Manually update the version of your WSL Linux kernel. You can also use the command: wsl —update rollback to rollback to a previous version of the WSL Linux kernel.
Check WSL status
See general information about your WSL configuration, such as default distribution type, default distribution, and kernel version.
Help command
See a list of options and commands available with WSL.
Home directory
can be used with wsl to start in the user’s home directory. To jump from any directory back to home from within a WSL command prompt, you can use the command: cd
Shutdown
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 or making a change to your .wslconfig file.
Terminate
To terminate the specified distribution, or stop it from running, replace with the name of the targeted distribution.
Export a distribution to a TAR file
Exports the distribution to a tar file. The filename can be — for standard output.
Import a new distribution
Imports the specified tar file as a new distribution. The filename can be — for standard input. The —version option can also be used with this command to designate whether the imported distribution will run on WSL 1 or WSL 2.
Unregister or uninstall a Linux distribution
Unregister or uninstall the specific distribution by replacing with the name of the targeted distribution. This will remove the distribution from WSL and delete all of the associated data. You can also uninstall the Linux distribution app on your Windows machine just like any other store application.
Mount a disk or device
Attach and mount a physical disk in all WSL2 distributions by replacing with the directory\file path where the disk is located. See Mount a Linux disk in WSL 2. Options include:
- wsl —mount —bare : Attach the disk to WSL2, but don’t mount it.
- wsl —mount —type : Filesystem type to use when mounting a disk, if not specified defaults to ext4. This command can also be entered as: wsl —mount -t .You can detect the filesystem type using the command: blkid , for example: blkid .
- wsl —mount —partition
: Index number of the partition to mount, if not specified defaults to the whole disk.
Источник