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
- List installed WSL distributions:
wsl --list or wsl -l
- List all distributions, including those that aren’t currently installed:
wsl --list --all or wsl -l -a
- Set a default distribution (this is the distribution that will be used if you just type
wsl
into the command prompt):wsl --setdefault <DistributionName>
- Set version of WSL for a distribution (WSL 1 or WSL 2):
wsl --set-version <DistributionName> <VersionNumber>
- Terminate a running WSL distribution:
wsl --terminate <DistributionName>
- Shutdown all running WSL instances:
wsl --shutdown
- 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>
- 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
- Open a new WSL terminal window: Simply type
wsl
into the command prompt or PowerShell. - Run a Linux command without entering the WSL terminal:
wsl <LinuxCommand>
For example, to list files in the Linux home directory:wsl ls -la ~
- 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>/
- Access WSL files from Windows: For WSL 2, you can access the Linux file system by navigating to
\\wsl$\<DistributionName>
in File Explorer.
Configuration
- Edit WSL settings: WSL configurations can be modified by editing the file:
C:\Users\<YourWindowsUsername>\.wslconfig
Latest posts by Rajesh Kumar (see all)
- Installing Jupyter: Get up and running on your computer - November 2, 2024
- An Introduction of SymOps by SymOps.com - October 30, 2024
- Introduction to System Operations (SymOps) - October 30, 2024