Skip to content

Instantly share code, notes, and snippets.

@jimathyp
Last active June 19, 2021 01:10
Show Gist options
  • Save jimathyp/ac4dfaa6ab0c8b34d6e8514aee514e3b to your computer and use it in GitHub Desktop.
Save jimathyp/ac4dfaa6ab0c8b34d6e8514aee514e3b to your computer and use it in GitHub Desktop.
WSL usage

WSL

eg in powershell

PS > wslconfig.exe /? Performs administrative operations on Windows Subsystem for Linux

Usage: /l, /list [/all] Lists registered distributions. /all - Optionally list all distributions, including distributions that are currently being installed or uninstalled.

/s, /setdefault <DistributionName>
    Sets the distribution as the default.

/t, /terminate <DistributionName>
    Terminates the distribution.

/u, /unregister <DistributionName>
    Unregisters the distribution.

/upgrade <DistributionName>
    Upgrades the distribution to the WslFs file system format.

PS > ubuntu1804.exe ? Launches or configures a Linux distribution.

Usage: Launches the user's default shell in the user's home directory.

install [--root]
    Install the distribuiton and do not launch the shell when complete.
      --root
          Do not create a user account and leave the default user set to root.

run <command line>
    Run the provided command line in the current working directory. If no
    command line is provided, the default shell is launched.

config [setting [value]]
    Configure settings for this distribution.
    Settings:
      --default-user <username>
          Sets the default user to <username>. This must be an existing user.

help
    Print usage information.

To change the default user (can be used to reset password)

#. Open PowerShell (Start, type PowerShell) or Win+R 'powershell.exe' #. Type :code:ubuntu then press the Tab key to autocomplete (you will have something similar to :code:ubuntu.exe or :code:ubuntu1804.exe installed) ubuntu.exe config --default-user root #. (Reset password instructions) #. Remember to change default user back once done (get your username from 'whoami' in WSL)

To change password (if you already knopw it)

In PowerShell

wsl -u root
passwd <username>

https://docs.microsoft.com/en-us/windows/wsl/user-support

(older WSL: https://docs.microsoft.com/en-us/windows/wsl/user-support-archived)

utilities

https://github.com/wslutilities/wslu

  • wslusc
  • wslview
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment