Wsl set default linux

Содержание
  1. Справочник по командам для WSL
  2. Основные команды
  3. Установка
  4. Установка определенного дистрибутива Linux
  5. Список доступных дистрибутивов Linux
  6. Список установленных дистрибутивов Linux
  7. Указание версии WSL (1 или 2)
  8. Указание версии WSL по умолчанию
  9. Указание дистрибутива Linux по умолчанию
  10. Запуск определенного дистрибутива Linux из PowerShell или CMD
  11. Обновление WSL
  12. Проверка состояния WSL
  13. Команда help
  14. Домашний каталог
  15. Shutdown
  16. Завершение
  17. Экспорт дистрибутива в TAR-файл
  18. Импорт нового дистрибутива
  19. Отмена регистрации или удаление дистрибутива Linux
  20. Подключение диска или устройства
  21. Command reference for WSL
  22. Basic commands
  23. Install
  24. Install a specific Linux distribution
  25. List available Linux distributions
  26. List installed Linux distributions
  27. Set WSL version to 1 or 2
  28. Set default WSL version
  29. Set default Linux distribution
  30. Run a specific Linux distribution from PowerShell or CMD
  31. Update WSL
  32. Check WSL status
  33. Help command
  34. Home directory
  35. Shutdown
  36. Terminate
  37. Export a distribution to a TAR file
  38. Import a new distribution
  39. Unregister or uninstall a Linux distribution
  40. Mount a disk or device
  41. Command reference for WSL
  42. Basic commands
  43. Install
  44. Install a specific Linux distribution
  45. List available Linux distributions
  46. List installed Linux distributions
  47. Set WSL version to 1 or 2
  48. Set default WSL version
  49. Set default Linux distribution
  50. Run a specific Linux distribution from PowerShell or CMD
  51. Update WSL
  52. Check WSL status
  53. Help command
  54. Home directory
  55. Shutdown
  56. Terminate
  57. Export a distribution to a TAR file
  58. Import a new distribution
  59. Unregister or uninstall a Linux distribution
  60. 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.

Читайте также:  Как переключаться между сетями windows 10

Завершение

Чтобы завершить работу определенного дистрибутива или остановить его выполнение, замените именем нужного дистрибутива.

Экспорт дистрибутива в 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

: номер раздела для подключения согласно индексу, если не указан вариант по умолчанию (весь диск).

  • wsl —mount —options . Некоторые параметры, относящиеся к файловой системе, можно добавить при подключении диска. Например, параметры подключения к ext4: wsl —mount -o «data-ordered» или wsl —mount -o «data=writeback . Но сейчас поддерживаются только параметры, относящиеся к файловой системе. Общие параметры, такие как ro , rw или noatime , не поддерживаются.
  • wsl —unmount . Отключение диска от всех дистрибутивов WSL 2. Если параметр не указан, эта команда отключает ВСЕ подключенные диски.
  • Источник

    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.

  • wsl —mount —options : There are some filesystem-specific options that can be included when mounting a disk. For example, ext4 mount options like: wsl —mount -o «data-ordered» or wsl —mount -o «data=writeback . However, only filesystem-specific options are supported at this time. Generic options, such as ro , rw , or noatime , are not supported.
  • wsl —unmount : Unmount and detach the disk from all WSL 2 distributions. If the is not included, this command will unmount and detach ALL mounted disks.
  • Источник

    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.

  • wsl —mount —options : There are some filesystem-specific options that can be included when mounting a disk. For example, ext4 mount options like: wsl —mount -o «data-ordered» or wsl —mount -o «data=writeback . However, only filesystem-specific options are supported at this time. Generic options, such as ro , rw , or noatime , are not supported.
  • wsl —unmount : Unmount and detach the disk from all WSL 2 distributions. If the is not included, this command will unmount and detach ALL mounted disks.
  • Источник

    Читайте также:  Sync with windows phone
    Оцените статью