Windows Subsystem for Linux Commands in Windows 10 PowerShell

You must Know Windows Subsystem for Linux Commands in PowerShell. Linux Distro has become a popular tool operated through terminal without a GUI (Graphical User Interface) support. You can enjoy with its latest version Linux Karnel having more interesting features. Linus distro may be more familiar, if you know various Windows Subsystem for Linux (WSL) Commands to run PowerShell script in Linux. Today in this article, you will know Linux top command in PowerShell.

But before proceeding to main content, you should know how to enable Windows Subsystem for Linux. We may enable through PoweShell Command in Windows 10.

  • Open Windows PowerShell.
  • Make a right click on it.
  • Select Run as Administrator.
  • Now the type the following single command in PowrShell window: –
    • dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

This command will enable Windows Subsystem for Linux in your Windows 10 system. This is the initial version as WSL only. Now you can easily install WSL2. Because no possibility to direct installation of WSL2 version in your windows system.

Windows Subsystem for Linux Commands in PowerShell

If you prefer CLI (Command Line Interface) to GUI (Graphic User Interface), Windows PowerShell is the best medium to execute various command. These commands send the assigned task to computer in typing method. Now we will see how to use various Linux command in PowerShell.


Open /Exit Default Windows Subsystem for Linux

To open the default WSL Linux Distribution by using PowerShell, apply the command

wsl

For exit, type the following command in Windows PowerShell: –

exit


Open a Particular Distro

When you want to launch any specific distribution system, simply go through these command: –

wsl -d <distribution name>

Example, to launch Ubuntu, it would be wsl -d ubuntu


Get Help

If you are facing some issue with Windows Subsystem for Linux, you should ask for help. To obtain help from developer or supporting team, use the following PowerShell Command: –

wsl --help


Identify the Version of WSL

You may use command to identify the version of Windows Subsystem for Linux installed in your system. Go through these commands: –

wsl --list --verbose or wsl -l -v

Through above mentioned commands, you can also identify the name of your default WSL distro. Just remove the word Verbose from the command and you will see only the name of installed Distro.


Set Default Distro by PowerShell Command

If you have not yet set the default distro, don’t worry. Here is the command to run PowerShell script in Windows Subsystem for Linux. Use the following command to set the default distro in your system: –

wsl --set-default <distro> or shorten to wsl -s <distro>

Example – to Set Ubuntu as default WSL, type the following command: –

wsl -s ubuntu



Set WSL2 as Default Version

If you have upgraded the Windows Subsystem for Linux from WSL to WSL2 and you want to set the newly one as default, go through the following commands: –

wsl --set-default-version 2


Change the Version of WSL

If you want to change the version of WSL, use the following command: –

wsl --set -version <distribution name> <version>

Example- To change Ubuntu to WSL 2, use these commands: –

wsl --set -version Ubuntu 2


Windows Subsystem for Linux Commands to Update Distro

For this, you will have to execute simplewsl.exe command in PowerShell. These types of command usually run directly without mentioning an argument. For updating your default Windows Subsystem for Linux, you should simply type the following command: –

wsl sudo apt update

But when you try to update a specific version of Linux then it will only possible with an argument. Suppose, you are using Ubuntu Distro and want to update it which is not a default WSL, then use these command in PowerShell:

wsl --distribution Ubuntu sudo apt update where --distribution or -d is the argument and Ubuntu is your specific version of WSL.


Windows Subsystem for Linux Commands fro installing Software

Some supporting flags such as -y&-u which are standard alone and used to specific function such as Installation of software in Windows Subsystem for Linux. You may call it auto accept command. If you want to install Youtube-dl, you should type the following command including wsl.exe alonwith the flag: –

wsl -d debian sudo apt install youtube-dl -y

You may use this type of command in installation of App. If you have multiple users, -u command will be used. It meant for User name. such as --user <username> or -u <username> It will be mixed with other arguments.



Windows Subsystem for Linux Commands to Export Distribution

These types of command will help you to set up or manage Windows Subsystem for Linux. For exporting your installed distribution use these commands:

wsl --export <distribution> <location> <filename>

Here, in place of distribution, type your distribution name. In place of location, enter the path of file where you want to transfer the distribution. And under filename, nominate your file with type of file. Here is an example:

wsl --export Ubuntu c:\programs\ubuntuexport.zip


Import Distro Command

The same procedure will be adopted to import the distribution from the File explorer. Only one change, you have to made. Replace the word “Export” to “import.

wsl --import Ubuntu c:\programs\ubuntuexport.zip


That’s all.

Leave a Reply

Your email address will not be published. Required fields are marked *