Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Configuring and Deploying Windows Subsystem for Linux on Windows 10

Tech May 14 1

The Windows Subsystem for Linux (WSL) provides a compatibility layer for running native Linux ELF64 binaries directly on Windows 10. This integration allows developers to utilize Linux command-line tools and applications without the overhead of a traditional virtual machine.

Activating Developer Mode

To begin, enable Developer Mode in your Windows settings:

  1. Open the Settings application.
  2. Navigate to Update & Security.
  3. Select For developers from the left-hand menu.
  4. Under "Use developer features," choose Developer mode.

Enabling the Windows Subsystem for Linux Feature

Next, activate the core WSL feature within Windows:

  1. Press Win + X to open the Quick Link menu, then select Apps and Features.
  2. Scroll down and click Programs and Features (or search for "Turn Windows features on or off" in the Start menu).
  3. In the "Windows Features" dialog, locate and check the box next to Windows Subsystem for Linux.
  4. Click OK and restart your Windows system when prompted.

Installing a Linux Distribution

After restarting, install your preferred Linux distribution from the Microsoft Store:

  1. Open the Microsoft Store application.
  2. Search for "WSL" or a specific distribution like "Ubuntu".
  3. Select an Ubuntu version, for example, Ubuntu 22.04 LTS.
  4. Click Get or Install to download the distribution.
  5. Once the download completes, click Launch to start your new Linux environment.

Initial Setup of the Linux Environment

Upon the first launch of your Linux distribution, you will be prompted to:

  1. Create a default Unix username.
  2. Set a password for this user.

This user will have sudo privileges, allowing you to execute commands with administrative access by prefixing them with sudo.

Updating Software Repositories

Its good practice to update your package lists and upgrade installed software immediately after installation:

  1. Backup the default sources.list file:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak ```

  1. Edit sources.list to configure package mirrors. For example, to use a common mirror for Ubuntu 22.04 LTS (Jammy Jellyfish):

sudo vim /etc/apt/sources.list ```

Replace existing entries with lines similar to these (or choose a regional mirror as appropriate, e.g., Aliyun mirror for China):

```

deb http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse ```

  1. Update your package list:

sudo apt update ```

Quick Access to the WSL Terminal

You can quickly open a WSL terminal from Windows:

  • Press Win + R, then type bash and press Enter.
  • Alternatively, open Command Prompt or PowerShell and type wsl or the name of your distribution (e.g., ubuntu).

Configuring SSH Server in WSL

To enable remote connections to your WSL instance, install and configure an SSH server:

  1. Check for existing SSH processes:

ps -ef | grep sshd ```

  1. Install the OpenSSH server. If already installed, it's good practice to remove and reinstall to ensure a clean setup:

sudo apt remove openssh-server sudo apt install openssh-server ```

  1. Modify the SSH daemon configuration file to allow password authentication and set the port:

sudo vim /etc/ssh/sshd_config ```

Ensure these lines are present and uncommented (or adjust if commented):

```

Port 22 PasswordAuthentication yes ```

  1. Restart the SSH service to apply changes:

sudo service ssh restart orbash sudo service ssh --full-restart ```

Enabling Root Login via SSH (Use with Caution)

For specific scenarios, you might need to enable direct root login via SSH. This is generally discouraged for security reasons but can be configured as follows:

  1. Edit the SSH daemon configuration file again:

sudo vim /etc/ssh/sshd_config ```

  1. Add or uncomment the line PermitRootLogin yes.

Authentication:

LoginGraceTime 120 #PermitRootLogin without-password PermitRootLogin yes ```

  1. Restart the SSH service:

sudo service ssh restart ```

After these steps, you can connect to your WSL Linux environment using any SSH client (like SecureCRT, PuTTY, or the ssh command in PowerShell/Command Prompt) from your Windows host or another machine, using the IP address of your WSL instance.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.