Unable to Open the Bash Shell in Ubuntu via Windows Subsystem for Linux [SOLVED]

Published: 2021 December 07

system administration Windows OS Windows Subsystem for Linux technical troubleshooting technical troubleshooting - solved

The Problem

When attempting to open the Bash shell in Ubuntu via Windows Subsystem for Linux (WSL) on Windows Terminal only the following message appears:

The Windows Subsystem for Linux instance has terminated.

[process exited with code …]

The Process

Part of the resolution process and sources are lost to me now, but I still want to document the solution that seems to resolve the issue.

A key seems to be running the terminal instance as administrator.

A StackExchange post about Opening up Windows Terminal with elevated privileges offered some insight on how to accomplish that with terminal commands.

The Solution

I edited my Windows Terminal settings.json to add two new profiles:

{
    "guid": "{<<GUID1>>}",
    "name": "Ubuntu",
    "source": "Windows.Terminal.Wsl"
},
{
    "guid": "{<<GUID2>>}",
    "name": "Elevate Terminal",
    "commandline": "powershell.exe Start-Process -Verb RunAs wt",
    "icon": "🔑",
    "hidden": false
},

Note: <<GUID1>> and <<GUID2>> are stand-in values for the actual guids.

I set Ubuntu as the default profile by editing defaultProfile:

"defaultProfile": "{<<GUID1>>}",

Now, when I select the “Elevate Terminal” profile, a new Windows Terminal instance is opened with administrator privileges to the Ubuntu profile. The profile then is able to access the WSL as expected.

Copying Directory Structure With a Bash Script - With Help From ChatGPT AI

Published: 2024 January 22

Setting Up a Raspberry Pi as a Linux Print Server with CUPS

Published: 2024 January 19

Setting Up a Raspberry Pi Zero 2 W with Ubuntu Server

Published: 2024 January 04