Difference between revisions of "Windows Subsystem for Linux"
(Add shortcut instructions in TLDR; and also reference to Docker docs on WSL) |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
Like all things Windows, WSL is an executable binary c:\WINDOWS\system32\wsl.exe | Like all things Windows, WSL is an executable binary c:\WINDOWS\system32\wsl.exe | ||
− | == Prerequisites == | + | ==TLDR== |
+ | To get to a Linux command prompt fast, just open a PowerShell window (<kbd class="keyboard-key nowrap">⊞</kbd>+<kbd class="keyboard-key nowrap">R</kbd> type <code>powershell</code> <kbd class="keyboard-key nowrap">↵</kbd>) and type <code>wsl</code><kbd class="keyboard-key nowrap">↵</kbd> to launch an interactive shell in the default Linux container for your local environment. | ||
+ | |||
+ | ==Prerequisites== | ||
To install WSL on Windows, you have one requirement to meet; you must have a Windows 10 64-bit computer Build 18917 '''or later'''. | To install WSL on Windows, you have one requirement to meet; you must have a Windows 10 64-bit computer Build 18917 '''or later'''. | ||
− | Press the 'windows' key <kbd> | + | Press the '[[wp:Windows key|windows' key]] <kbd>⊞</kbd> and type <code>winver</code> to run the Windows Version utility in order to see your current Windows version. |
+ | |||
+ | ==See Also == | ||
+ | https://docs.docker.com/desktop/troubleshoot/topics/#working-with-git-bash | ||
+ | |||
+ | == WSL Cheatsheet == | ||
+ | Once you have WSL plus a distribution installed, all you need to do to open a Linux shell is open the Windows PowerShell, and type <code>wsl</code> which will start the default distro. | ||
+ | |||
+ | <pre> | ||
+ | Copyright (c) Microsoft Corporation. All rights reserved. | ||
+ | |||
+ | Usage: wsl.exe [Argument] [Options...] [CommandLine] | ||
+ | |||
+ | Arguments for running Linux binaries: | ||
+ | |||
+ | If no command line is provided, wsl.exe launches the default shell. | ||
+ | |||
+ | --exec, -e <CommandLine> | ||
+ | |||
+ | Execute the specified command without using the default Linux shell. | ||
+ | |||
+ | --shell-type <Type> | ||
+ | |||
+ | Execute the specified command with the provided shell type. | ||
+ | |||
+ | Types: | ||
+ | |||
+ | standard | ||
+ | |||
+ | Execute the specified command using the default Linux shell. | ||
+ | |||
+ | login | ||
+ | |||
+ | Execute the specified command using the default Linux shell as a login shell. | ||
+ | |||
+ | none | ||
+ | |||
+ | Execute the specified command without using the default Linux shell. | ||
+ | |||
+ | -- | ||
+ | |||
+ | Pass the remaining command line as-is. | ||
+ | |||
+ | Options: | ||
+ | |||
+ | --cd <Directory> | ||
+ | |||
+ | Sets the specified directory as the current working directory. | ||
+ | |||
+ | If ~ is used the Linux user's home path will be used. If the path begins | ||
+ | |||
+ | with a / character, it will be interpreted as an absolute Linux path. | ||
+ | |||
+ | Otherwise, the value must be an absolute Windows path. | ||
+ | |||
+ | --distribution, -d <Distro> | ||
+ | |||
+ | Run the specified distribution. | ||
+ | |||
+ | --user, -u <UserName> | ||
+ | |||
+ | Run as the specified user. | ||
+ | |||
+ | --system | ||
+ | |||
+ | Launches a shell for the system distribution. | ||
+ | |||
+ | Arguments for managing Windows Subsystem for Linux: | ||
+ | |||
+ | --help | ||
+ | |||
+ | Display usage information. | ||
+ | |||
+ | --debug-shell | ||
+ | |||
+ | Open a WSL2 debug shell for diagnostics purposes. | ||
+ | |||
+ | --event-viewer | ||
+ | |||
+ | Opens the application view of the Windows Event Viewer. | ||
+ | |||
+ | --install [Distro] [Options...] | ||
+ | |||
+ | Install a Windows Subsystem for Linux distribution. | ||
+ | |||
+ | For a list of valid distributions, use 'wsl.exe --list --online'. | ||
+ | |||
+ | Options: | ||
+ | |||
+ | --no-launch, -n | ||
+ | |||
+ | Do not launch the distribution after install. | ||
+ | |||
+ | --web-download | ||
+ | |||
+ | Download the distribution from the internet instead of the Microsoft Store. | ||
+ | |||
+ | --mount <Disk> | ||
+ | |||
+ | Attaches and mounts a physical or virtual disk in all WSL 2 distributions. | ||
+ | |||
+ | Options: | ||
+ | |||
+ | --vhd | ||
+ | |||
+ | Specifies that <Disk> refers to a virtual hard disk. | ||
+ | |||
+ | --bare | ||
+ | |||
+ | Attach the disk to WSL2, but don't mount it. | ||
+ | |||
+ | --name <Name> | ||
+ | |||
+ | Mount the disk using a custom name for the mountpoint. | ||
+ | |||
+ | --type <Type> | ||
+ | |||
+ | Filesystem to use when mounting a disk, if not specified defaults to ext4. | ||
+ | |||
+ | --options <Options> | ||
+ | |||
+ | Additional mount options. | ||
+ | |||
+ | --partition <Index> | ||
+ | |||
+ | Index of the partition to mount, if not specified defaults to the whole disk. | ||
+ | |||
+ | --release-notes | ||
+ | |||
+ | Opens a web browser to view the WSL release notes page. | ||
+ | |||
+ | --set-default-version <Version> | ||
+ | |||
+ | Changes the default install version for new distributions. | ||
+ | |||
+ | --shutdown | ||
+ | |||
+ | Immediately terminates all running distributions and the WSL 2 | ||
+ | |||
+ | lightweight utility virtual machine. | ||
+ | |||
+ | --status | ||
+ | |||
+ | Show the status of Windows Subsystem for Linux. | ||
+ | |||
+ | --unmount [Disk] | ||
+ | |||
+ | Unmounts and detaches a disk from all WSL2 distributions. | ||
+ | |||
+ | Unmounts and detaches all disks if called without argument. | ||
+ | |||
+ | --update | ||
+ | |||
+ | Update the Windows Subsystem for Linux package. | ||
+ | |||
+ | Options: | ||
+ | |||
+ | --web-download | ||
+ | |||
+ | Download the update from the internet instead of the Microsoft Store. | ||
+ | |||
+ | --pre-release | ||
+ | |||
+ | Download a pre-release version if available. Implies --web-download. | ||
+ | |||
+ | --version, -v | ||
+ | |||
+ | Display version information. | ||
+ | |||
+ | Arguments for managing distributions in Windows Subsystem for Linux: | ||
+ | |||
+ | --export <Distro> <FileName> [Options] | ||
+ | |||
+ | Exports the distribution to a tar file. | ||
+ | |||
+ | The filename can be - for standard output. | ||
+ | |||
+ | Options: | ||
+ | |||
+ | --vhd | ||
+ | |||
+ | Specifies that the distribution should be exported as a .vhdx file. | ||
+ | |||
+ | --import <Distro> <InstallLocation> <FileName> [Options] | ||
+ | |||
+ | Imports the specified tar file as a new distribution. | ||
+ | |||
+ | The filename can be - for standard input. | ||
+ | |||
+ | Options: | ||
+ | |||
+ | --version <Version> | ||
+ | |||
+ | Specifies the version to use for the new distribution. | ||
+ | |||
+ | --vhd | ||
+ | |||
+ | Specifies that the provided file is a .vhdx file, not a tar file. | ||
+ | |||
+ | This operation makes a copy of the .vhdx file at the specified install location. | ||
+ | |||
+ | --import-in-place <Distro> <FileName> | ||
+ | |||
+ | Imports the specified .vhdx file as a new distribution. | ||
+ | |||
+ | This virtual hard disk must be formatted with the ext4 filesystem type. | ||
+ | |||
+ | --list, -l [Options] | ||
+ | |||
+ | Lists distributions. | ||
+ | |||
+ | Options: | ||
+ | |||
+ | --all | ||
+ | |||
+ | List all distributions, including distributions that are | ||
+ | |||
+ | currently being installed or uninstalled. | ||
+ | --running | ||
+ | |||
+ | List only distributions that are currently running. | ||
+ | |||
+ | --quiet, -q | ||
+ | |||
+ | Only show distribution names. | ||
+ | |||
+ | --verbose, -v | ||
+ | |||
+ | Show detailed information about all distributions. | ||
+ | |||
+ | --online, -o | ||
+ | |||
+ | Displays a list of available distributions for install with 'wsl.exe --install'. | ||
+ | |||
+ | --set-default, -s <Distro> | ||
+ | |||
+ | Sets the distribution as the default. | ||
+ | |||
+ | --set-version <Distro> <Version> | ||
+ | |||
+ | Changes the version of the specified distribution. | ||
+ | |||
+ | --terminate, -t <Distro> | ||
+ | |||
+ | Terminates the specified distribution. | ||
+ | |||
+ | --unregister <Distro> | ||
+ | |||
+ | Unregisters the distribution and deletes the root filesystem.{{References}} | ||
+ | </pre> | ||
{{References}} | {{References}} | ||
+ | |||
+ | [[Category:Linux]] | ||
+ | [[Category:Windows]] | ||
+ | [[Category:OS]] |
Latest revision as of 13:46, 12 October 2023
In order to do my Canasta work, I need Linux. I'm challenging myself at the moment to use a Windows desktop OS in order to learn all the tools and process required by Windows-oriented developers who have never used Linux as their desktop OS and aren't as familiar with the Linux perspective. In Linux, you ask "Where's my shell?" because you can directly use the "shell" interpreter[1] to invoke any number of a seemingly limitless collection of Linux commands. Because Linux has always been a multi-user system, with remote access, all users have a 'shell' environment which is the interface for the remote user. In Windows, everything is point and click, and based on a single user desktop environment. If you click open a 'Windows PowerShell' instance, it might look the same (text on a black background), but it will not understand any of the commands you know from BASH. The way to make PowerShell more powerful[2] is to install the Windows Subsystem for Linux (WSL). The WSL guide over at AdamTheAutomater.com takes you through all the important steps to getting up and running as a (Linux) developer on Windows.
Like all things Windows, WSL is an executable binary c:\WINDOWS\system32\wsl.exe
TLDR[edit | edit source]
To get to a Linux command prompt fast, just open a PowerShell window (⊞+R type powershell
↵) and type wsl
↵ to launch an interactive shell in the default Linux container for your local environment.
Prerequisites[edit | edit source]
To install WSL on Windows, you have one requirement to meet; you must have a Windows 10 64-bit computer Build 18917 or later.
Press the 'windows' key ⊞ and type winver
to run the Windows Version utility in order to see your current Windows version.
See Also[edit | edit source]
https://docs.docker.com/desktop/troubleshoot/topics/#working-with-git-bash
WSL Cheatsheet[edit | edit source]
Once you have WSL plus a distribution installed, all you need to do to open a Linux shell is open the Windows PowerShell, and type wsl
which will start the default distro.
Copyright (c) Microsoft Corporation. All rights reserved. Usage: wsl.exe [Argument] [Options...] [CommandLine] Arguments for running Linux binaries: If no command line is provided, wsl.exe launches the default shell. --exec, -e <CommandLine> Execute the specified command without using the default Linux shell. --shell-type <Type> Execute the specified command with the provided shell type. Types: standard Execute the specified command using the default Linux shell. login Execute the specified command using the default Linux shell as a login shell. none Execute the specified command without using the default Linux shell. -- Pass the remaining command line as-is. Options: --cd <Directory> Sets the specified directory as the current working directory. If ~ is used the Linux user's home path will be used. If the path begins with a / character, it will be interpreted as an absolute Linux path. Otherwise, the value must be an absolute Windows path. --distribution, -d <Distro> Run the specified distribution. --user, -u <UserName> Run as the specified user. --system Launches a shell for the system distribution. Arguments for managing Windows Subsystem for Linux: --help Display usage information. --debug-shell Open a WSL2 debug shell for diagnostics purposes. --event-viewer Opens the application view of the Windows Event Viewer. --install [Distro] [Options...] Install a Windows Subsystem for Linux distribution. For a list of valid distributions, use 'wsl.exe --list --online'. Options: --no-launch, -n Do not launch the distribution after install. --web-download Download the distribution from the internet instead of the Microsoft Store. --mount <Disk> Attaches and mounts a physical or virtual disk in all WSL 2 distributions. Options: --vhd Specifies that <Disk> refers to a virtual hard disk. --bare Attach the disk to WSL2, but don't mount it. --name <Name> Mount the disk using a custom name for the mountpoint. --type <Type> Filesystem to use when mounting a disk, if not specified defaults to ext4. --options <Options> Additional mount options. --partition <Index> Index of the partition to mount, if not specified defaults to the whole disk. --release-notes Opens a web browser to view the WSL release notes page. --set-default-version <Version> Changes the default install version for new distributions. --shutdown Immediately terminates all running distributions and the WSL 2 lightweight utility virtual machine. --status Show the status of Windows Subsystem for Linux. --unmount [Disk] Unmounts and detaches a disk from all WSL2 distributions. Unmounts and detaches all disks if called without argument. --update Update the Windows Subsystem for Linux package. Options: --web-download Download the update from the internet instead of the Microsoft Store. --pre-release Download a pre-release version if available. Implies --web-download. --version, -v Display version information. Arguments for managing distributions in Windows Subsystem for Linux: --export <Distro> <FileName> [Options] Exports the distribution to a tar file. The filename can be - for standard output. Options: --vhd Specifies that the distribution should be exported as a .vhdx file. --import <Distro> <InstallLocation> <FileName> [Options] Imports the specified tar file as a new distribution. The filename can be - for standard input. Options: --version <Version> Specifies the version to use for the new distribution. --vhd Specifies that the provided file is a .vhdx file, not a tar file. This operation makes a copy of the .vhdx file at the specified install location. --import-in-place <Distro> <FileName> Imports the specified .vhdx file as a new distribution. This virtual hard disk must be formatted with the ext4 filesystem type. --list, -l [Options] Lists distributions. Options: --all List all distributions, including distributions that are currently being installed or uninstalled. --running List only distributions that are currently running. --quiet, -q Only show distribution names. --verbose, -v Show detailed information about all distributions. --online, -o Displays a list of available distributions for install with 'wsl.exe --install'. --set-default, -s <Distro> Sets the distribution as the default. --set-version <Distro> <Version> Changes the version of the specified distribution. --terminate, -t <Distro> Terminates the specified distribution. --unregister <Distro> Unregisters the distribution and deletes the root filesystem.{{References}}
References[edit source]
- ↑ The default interpreter for most Linux OS is BASH or the Bourne Again Shell. BASH derives from the Bourne Shell. Gotta love that naming! There are many options for shell scripting interpreters: The KornShell, Z shell, C shell, Emacs shell, etc. https://en.wikipedia.org/wiki/List_of_command-line_interpreters
- ↑ It's almost always the case that when you look at the 'name' given by a corporation for a product, that thing is NOT what the name says. In this case "PowerShell" doesn't have the power of Linux baked in. You have to add a whole subsystem yourself to make it powerful. They should have called it WeakShell, HalfShell, or StarterShell. They could have called it MicrosoftShell or .Net Shell. For various reasons none of the "truthy" alternatives will do, so call it everything that you want it to be: PowerShell.