Windows Subsystem for Linux 2 (WSL 2) Tips, Tricks, and Techniques: Maximise productivity of your Windows 10 development machine with custom workflows and configurations

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

A practical handbook that will help you bridge the gap between Windows and Linux to develop apps that leverage the best features across both ecosystems with seamless interoperability

Key Features

  • Configure and control WSL to suit your needs and preferences
  • Discover tips for working seamlessly between Windows and WSL Linux distros
  • Learn how to work effectively with containers in WSL, as well as how to containerize your development environments with Visual Studio Code to isolate your dependencies

Book Description

Windows Subsystem for Linux (WSL) allows you to run native Linux tools alongside traditional Windows applications. Whether you're developing applications across multiple operating systems or looking to add more tools to your Windows environment, WSL offers endless possibilities.

You'll start by understanding what WSL is and learn how to install and configure WSL along with different Linux distros. Next, you'll learn techniques that allow you to work across both Windows and Linux environments. You'll discover how to install and customize the new Windows Terminal. We'll also show you how to work with code in WSL using Visual Studio Code (VS Code). In addition to this, you'll explore how to work with containers with Docker and Kubernetes, and how to containerize a development environment using VS Code.

While Microsoft has announced support for GPU and GUI applications in an upcoming release of WSL, at the time of writing these features are either not available or only in early preview releases. This book focuses on the stable, released features of WSL and giving you a solid understanding of the amazing techniques that you can use with WSL today.

By the end of this book, you'll be able to configure WSL and Windows Terminal to suit your preferences, and productively use Visual Studio Code for developing applications with WSL.

What you will learn

  • Install and configure Windows Subsystem for Linux and Linux distros
  • Access web applications running in Linux from Windows
  • Invoke Windows applications, file systems, and environment variables from bash in WSL
  • Customize the appearance and behavior of the Windows Terminal to suit your preferences and workflows
  • Explore various tips for enhancing the Visual Studio Code experience with WSL
  • Install and work with Docker and Kubernetes within Windows Subsystem for Linux
  • Discover various productivity tips for working with Command-line tools in WSL

Who this book is for

This book is for developers who want to use Linux tools on Windows, including Windows-native programmers looking to ease into a Linux environment based on project requirements or Linux developers who've recently switched to Windows. This book is also for web developers working on open source projects with Linux-first tools such as Ruby or Python, or developers looking to switch between containers and development machines for testing apps. Prior programming or development experience and a basic understanding of running tasks in bash, PowerShell, or the Windows Command Prompt will be required.

Table of Contents

  1. Introduction to the Windows Subsystem for Linux
  2. Installing and Configuring the Windows Subsystem for Linux
  3. Getting Started with Windows Terminal
  4. Windows to Linux Interoperability
  5. Linux to Windows Interoperability
  6. Getting More from Windows Terminal
  7. Working with Containers in WSL
  8. Working with WSL Distros
  9. Visual Studio Code and WSL
  10. Visual Studio Code and Containers
  11. Productivity Tips with Command-Line Tools

Author(s): Stuart Leeks
Publisher: Packt Publishing
Year: 2020

Language: English
Pages: 246

Cover
Title Page
Copyright and Credits
Dedication
About Packt
Contributors
Preface
Section 1: Introduction, Installation, and Configuration
Chapter 1: Introduction to the Windows Subsystem for Linux
What is WSL?
Exploring the differences between WSL 1 and 2
Overview of WSL 1
Overview of WSL 2
Summary
Chapter 2: Installing and Configuring the Windows Subsystem for Linux
Enabling WSL
Checking for the required Windows version
Checking for the easy install option
Enabling the required Windows features
Installing the Linux Kernel
Installing Linux distros in WSL
Configuring and controlling WSL
Introducing the wsl command
Introducing wsl.conf and .wslconfig
Summary
Chapter 3: Getting Started with Windows Terminal
Introducing Windows Terminal
Installing Windows Terminal
Using Windows Terminal
Learning handy keyboard shortcuts
Configuring Windows Terminal
Customizing profiles
Changing the appearance of Windows Terminal
Summary
Section 2:Windows and Linux – A Winning Combination
Chapter 4: Windows to Linux Interoperability
Accessing Linux files from Windows
Running Linux applications from Windows
Piping into Linux
Piping from Linux
Accessing Linux web applications from Windows
Summary
Chapter 5: Linux to Windows Interoperability
Accessing Windows files from Linux
Calling Windows apps from Linux
Calling Windows scripts from Linux
Passing data between PowerShell and Bash
Interoperability tips and tricks
Creating aliases for Windows applications
Copying output to the Windows clipboard
Using symlinks to make Windows paths easier to access
Using wslview to launch default Windows applications
Mapping paths between Windows and WSL
SSH agent forwarding
Summary
Chapter 6: Getting More from Windows Terminal
Customizing tab titles
Setting tab titles from the context menu
Setting tab titles from your shell using functions
Setting tab titles from the command line
Working with multiple panes
Creating panes interactively
Managing panes
Creating panes from the command line
Adding custom profiles
Summary
Chapter 7: Working with Containers in WSL
Overview of containers
Installing and using Docker with WSL
Running a container with Docker
Building and running a web application in Docker
Introducing Dockerfiles
Building the image
Running the image
Rebuilding the image with changes
Introducing orchestrators
Setting up Kubernetes in WSL
Running a web application in Kubernetes
Creating a deployment
Summary
Chapter 8: Working with WSL Distros
Exporting and importing a WSL distro
Preparing for exporting
Performing the export
Performing the import
Creating and running a custom distro
Finding and pulling the container image
Configuring a container ready for WSL
Converting the container to a WSL distro
Running the new distro
Taking it a step further
Summary
Section 3: Developing with the Windows Subsystem for Linux
Chapter 9: Visual Studio Code and WSL
Introducing Visual Studio Code
Introducing Visual Studio Code Remote
Getting started with Remote-WSL
Opening a folder with Remote-WSL
Running the app
Debugging our app
Tips for working with Remote - WSL
Loading Visual Studio Code from your terminal
Opening an external terminal in Windows Terminal
Using Visual Studio Code as your Git editor
Viewing Git history
Summary
Chapter 10: Visual Studio Code and Containers
Introducing Visual Studio Code Remote-Containers
Installing Remote-Containers
Creating a dev container
Adding and opening a dev container definition
Working in the dev container
Running the code
Working with a containerized app in dev containers
Setting up Docker in the dev container
Building the application Docker image
Running the application container
Working with Kubernetes in dev containers
Options for Kubernetes with dev containers
Setting up kind in a dev container
Running our app in a Kubernetes cluster with kind
Tips for working with dev containers
postCreateCommand and automating pip install
Port forwarding
Mounting volumes and Bash history
Using pinned versions for tools
Always Installed Extensions and dotfiles
Summary
Chapter 11: Productivity Tips with Command-Line Tools
Working with Git
Bash completion with Git
Authentication with Git
Viewing Git history
Git information in the bash prompt
Working with JSON
Using jq
Using PowerShell to work with JSON
Summarizing working with JSON
Working with the Azure CLI (az)
Installing and configuring the Azure CLI
Creating an Azure web app
Querying single values
Querying and filtering multiple values
Working with the Kubernetes CLI (kubectl)
Installing and configuring kubectl
Creating a Kubernetes cluster
Deploying a basic website
Querying with JSONPath
Scaling the website
Querying with jq
Summary
Other Books You May Enjoy
Index