Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

List of commands for wsl

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:

You guys might learn these commands in your Computer Science course. While studying CS coursework you might consider expert help in CS HW

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
Rajesh Kumar
Follow me
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x