Jump to content

List of commands for wsl


Recommended Posts

Windows Subsystem for Linux (WSL) allows you to run a Linux distribution directly on Windows without the overhead of a traditional virtual machine or dual-boot setup. Here are some commonly used commands and operations related to WSL:

Here is a list of some of the most common WSL commands:

  • wsl: This command will start a new WSL session.
  • wsl -l: This command will list all of the installed WSL distributions.
  • wsl -d <distribution name>: This command will start a new WSL session using the specified distribution.
  • wsl --shutdown: This command will shut down all running WSL sessions.
  • wsl --terminate <distribution name>: This command will terminate the WSL session for the specified distribution.
  • wsl --set-version <version number>: This command will set the default WSL version.
  • wsl --status: This command will display the status of all running WSL sessions.
  • wsl --import <distribution name> <tarball path>: This command will import a new WSL distribution from a tarball file.
  • wsl --export <distribution name> <export path>: This command will export a WSL distribution to a tarball file.
  • wsl --mount <source path> <mount point>: This command will mount a Windows file system path to a WSL mount point.
  • wsl --unmount <mount point>: This command will unmount a WSL mount point.
  • wsl --default <distribution name>: This command will set the default WSL distribution.

WSL Management Commands

  1. List installed WSL distributions:wsl --list or wsl -l
  2. List all distributions, including those that aren’t currently installed:wsl --list --all or wsl -l -a
  3. Set a default distribution (this is the distribution that will be used if you just type wsl into the command prompt):wsl --setdefault <DistributionName>
  4. Set version of WSL for a distribution (WSL 1 or WSL 2):wsl --set-version <DistributionName> <VersionNumber>
  5. Terminate a running WSL distribution:wsl --terminate <DistributionName>
  6. Shutdown all running WSL instances:wsl --shutdown
  7. Install a new distribution (this command will install the distribution but allow you to set up a new user, etc., later):wsl --install -d <DistributionName>
  8. Unregister and remove a distribution (WARNING: This will remove the Linux distribution from WSL and also delete the user account and data): wsl --unregister <DistributionName>

General WSL Commands

  1. Open a new WSL terminal window: Simply type wsl into the command prompt or PowerShell.
  2. Run a Linux command without entering the WSL terminal:wsl <LinuxCommand> For example, to list files in the Linux home directory:wsl ls -la ~
  3. Access Windows files from WSL: In WSL, your Windows drives are mounted under the /mnt directory. So, for example, your C drive would be available at /mnt/c/. cd /mnt/c/Users/<YourWindowsUsername>/
  4. Access WSL files from Windows: For WSL 2, you can access the Linux file system by navigating to \\wsl$\<DistributionName> in File Explorer.

Configuration

  1. Edit WSL settings: WSL configurations can be modified by editing the file: C:\Users\<YourWindowsUsername>\.wslconfig

The post List of commands for wsl appeared first on DevOpsSchool.com.

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...