This is a guide on how to open WSL files in Windows File Explorer, with added descriptions.
The best practice for managing project files in WSL is to store your files on the same Operating System as the tools your plan to use. So if the reason you’re using WSL is to develop an app in Linux, then keeping your files in WSL (use Linux root directories, not /mnt/c/Users/etc).
Also to note, copying files to and from WSL and your local Windows machine can usually be avoided by storing all your WSL application code within source control (e.g. Git / Bitbucket).
With that said, there are 2 ways to open WSL directories in Windows Explorer.
The quick way of opening WSL project files in Windows Explorer is to run the following, while in your Linux terminal session –
# open windows explorer from within wsl
explorer.exe .
This opens the directory you are already working in on your Terminal.
… Now follows, the alternative method of opening WSL project files in Windows Explorer.
Open Windows Explorer and navigate to \\wsl$\ as shown –
The above is showing my only running WSL Linux distribution, even though I have 3 WSL distros installed.
I’m going to open the Ubuntu 20.04 distro in a new tab in Windows Terminal to start it up –
Now I can see both distributions files in Windows Explorer –
From here we can drill into the folders and navigate to any directory –
For further reading, see this Microsoft Docs link for more info on WSL Best Practises.
This post is a guide on how to change a WSL distribution, from your default WSL Linux distro in the Windows Subsystem for Linux This is useful when you are managing multiple WSL distros on your computer.
List Installed WSL Distros
First up, we want to display your installed WSL distributions and versions by running the following command.
# show installed wsl distros & versions
wsl -l -v
The star at the distro name indicates the current default WSL Linux distribution.
When we enter WSL by running the wsl command, we will log into the Ubuntu-20.04 distro.
We can run lsb_release -a as above to verify which Linux distribution we are using.
Set Default WSL Linux Distro
To set the default WSL Linux distro we need to run wsl -s <wsl-distribution-name>
Before running this command, the WSL distro name is as-per what is shown in the wsl -l -v command.
# wsl show versions
wsl -l -v
# set default wsl distribution (as per 'wsl -l' name)
wsl -s <wsl-distribution-name>
Noticing here the same ‘lsb_release -a‘ command does not work for me when in the Debian distro – using cat /etc/os-release instead.
This is a post on how to install Postgres on Ubuntu 20.04, on Windows Subsystem for Linux (WSL). This should hopefully be a straightforward installation for you, which is done by following these 2 steps:
The next command will install Postgres. We’re including the ‘-contrib‘ package which will give us extra functionalities. After installing with the first command I need to restart the Postgres Service to resolve an “error: could not connect to server: No such file or directory” error message.
# install postgres on ubuntu
sudo apt install postgresql postgresql-contrib
# restart postgres service ubuntu
sudo service postgresql restart
Once the installation completes, we can enter psql using the ‘postgres’ user that was automatically created during the installation.
# login to psql with the out of box postgres user
sudo -u postgres psql
\q (to quit back to terminal)
To check your installed Windows Subsystem for Linux (WSL) versions, run wsl -l -v. This will show all installed WSL Linux distro names & versions.
WSL allows users to develop and run applications within a GNU/Linux environment on a Windows computer. Previous to this feature release we needed Virtual Machines (VMs), and dual boot setups were much more common if you wanted local test environments.
There are 2 versions of WSL, the old (1), and the new (2). We should ideally be using the latest version like all other software in existence, but there are use cases where we might prefer to use WSL Version 1.
As always, we should look for the most relevant MS Docs when researching a Microsoft Product or Application. The image below shows the current feature differences between WSL 1 and WSL 2.
To check the versions of your installed WSL distros, open a PowerShell Terminal and run wsl -l -v
# wsl check version
wsl -l -v
The command above lists all installed Windows Subsystem Linux distributions on your local machine, including WSL versions (WSL1 or WSL2) and their state (Running or Stopped).
I’m using Windows Terminal in this demo, which is great for managing multiple WSL distributions. We are able to open multiple Linux WSL distros and manage them using tabs as displayed in the screenshot above.
To install WSL (Windows Subsystem for Linux), we first enable the WSL Windows Feature using PowerShell, then install WSL Linux Distributions via the Microsoft Store.
This post will help guide you through enabling and installing Windows Subsystem for Linux (WSL) on your local Windows computer.
WSL allows Windows users to develop and run applications within a GNU/Linux environment. Previous to this feature release we needed Virtual Machines (VMs), and dual boot setups were much more common if you wanted local test environments.
The list of available Linux Distributions for installation, current as of this post date, includes the following:
– Ubuntu 20.04 (LTS / 18.04 LTS) – openSUSE Leap 15.1 – SUSE Linux Enterprise Server (15 SP1 / 12 SP5) – Kali Linux – Debian GNU/Linux – Fedora Remix for WSL – Pengwin (+ Enterprise) – Alpine WSL – Raft (Free Trial)
This blog post is a demo to help you install WSL for the first time on your Windows machine. FYI, there’s a reboot of your computer required at the end of the first step (enabling WSL).
You can find all the WSL Linux Distributions in the Microsoft Store which are available to download from there. This may be restricted by Group Policy if you’re on a Domain (a work/corporate computer).
To check our commit history on a Repository within Git, we use the git log command. When using this command we scroll through the commit log within our Terminal by hitting the Enter key, and then we need to hit q on our keyboard to exit reading the git log.
This post is to demo the --online parameter that can be added to the git log statement. Adding this parameter to the git log command will return a condensed commit log history, which shows the first part of the commit hash and message on one line.
In the following example, I’m running the standard git log command on one of my Repos. This is what we’d use if we want information including full commit hashes, commit dates/times, and authors.
You might think the above shows too many logs on the screen. We can pass in a line number parameter for it to return a specific number of commits.
This next example shows with and without the above –oneline parameter. We limit the number of commits/rows being returned by adding ‘-5‘ (can be any number).
# show most recent 2 commits
git log -2
# show most recent 5 commits on one line
git log -5 --oneline
We can amend the formatting of the returned list, including changing colours, adding in commit times, and adding the contributor.
This would be ideal if it was added as a function on your Terminal Profile.
# show most recent 5 commites on one line, with formatting
git log -5 --graph --pretty=format:'%C(red)%h%Creset -%C(yellow)%d%Creset %s %C(green)(%cr) %C(yellow)<%an>%Creset'
That’s it for this tip, check out my other posts on this topic in the Git Tag if of interest.
This is a post on how to change a Windows Subsystem for Linux (WSL) Distribution from running on Version 2 to Version 1.
WSL has two versions, the latest (2), and the original version (1). You can have many different Linux Distributions installed on your machine, and you can easily change the WSL Version for one of them.
This Microsoft documentation page explains the key differences between versions and will help explain why you might want to downgrade back to version 1 for your particular WSL development needs.
To change one of your WSL Distributions from WSL2 to WSL1, we just need to pass in the –set-version parameter and it’ll be converted very quick. I’m listing my available WSL Distro’s before and after to visually verify the change.
# check wsl distro versions
wsl -l -v
# change wsl distro using name above to desired version
wsl --set-version Ubuntu 1
This is a post on how to reboot a Windows Subsystem for Linux (WSL) virtual machine environment on your local machine. I’ve needed to do this a few times in the past year, my WSL instance throws some random error which was only resolved after a reboot.
As far as I know, we are unable to reboot from within WSL due to the lack of systemd. There are some open-source projects in the works to enable this which I’ve not tried yet. So we need to run a simple ‘wsl’ command to shutdown the host, and the enter WSL to get it back online.
This example shows exactly that, and I’m listing my installed WSL Distributions between each step.
# check wsl version
wsl -l -v
# reboot wsl2 instance
wsl --shutdown
# enter default wsl instance to boot
wsl
If you have multiple Linux Distributions installed on your Windows machine, by default you can only have one of them running, so when you’re switching between using ‘wsl -d <instanceName>’ the other will go offline. There is a way to get multiple WSL instances running at the same time, even with a GUI – have a look at this WSL Distro Manage project in GitHub if of interest.
One last note, the LXSS Manager Service is the broker to the Linux subsystem driver. We can also restart this service or of course reboot our local machine.
WSL allows users to develop and run applications within a GNU/Linux environment on a Windows computer. Previous to this Windows Feature you might have needed VM’s or a dual boot setup for this type of test/development environment.
There are 2 versions of WSL, the old (1), and the new (2). We should ideally be using the latest version like all other software in existence, but there are use cases where we might prefer to use WSL Version 1. This Microsoft documentation page explains the key differences between versions, and this post is to help explain how to check your WSL Version.
Personally I prefer to use WSL Version 2 as we’re able to make use of more apps like Docker. Also, I don’t need to worry about the exceptions for when it’s best to use WSL Version 1.
With descriptions out of the way, we can check our WSL Versions by running the following from a PowerShell Terminal –
# check wsl version
wsl -l -v
The above gives us a list of all installed Linux Distributions on your local machine including WSL Versions.
This post is a how-to for installing & configuring AWS CLI (Version 2) on Windows.
In this guide, we’re going to download the AWS Command Line Interface installation media and run through the simple installation. Once done we’ll configure AWS CLI, which you’ll need an AWS Account to do so.
Download AWS CLI V2 and run through the MSI installer. Run the .msi file you downloaded, and click next, next & done to complete the installation.
Alternatively, we can install AWS CLI using the PowerShell commands below.
# Download AWS CLI msi file, output to current directory
Invoke-WebRequest -Uri https://awscli.amazonaws.com/AWSCLIV2.msi -UseBasicParsing -OutFile 'AWSCLIV2.msi'
# Run AWS CLI install
.\AWSCLIV2.msi
When the installation completes, close and re-open any terminals you have open. You should remember/consider doing this every time you install a package for development, close/reopen your VS Code or Windows Terminal.
Open your command terminal and verify the AWS CLI install by checking the version. Run ‘aws –version‘ as shown in the example below.
Configure AWS CLI V2
Now that we have AWS CLI installed on our machine, we need to open a web browser for the next steps, and head to the AWS Console.
Open AWS IAM and create/select a user with appropriate permissions. My ‘pete‘ login has full Admin (AdministratorAccess Policy) in this case.
Click on the Security Credentials tab within the user properties.
Scroll down to view & create Access Keys. Click to create a new key to see both the Access key ID and Secret Access Key of existing keys.
Open PowerShell and run ‘aws configure‘. You’ll be prompted for: – AWS Access Key ID (above) – AWS Secret Access Key (above) – Default Region Name – Default Output Format
Once you’ve entered these details for the first time it’ll save your details, so for me above I’m just hitting enter at each prompt.
Run ‘aws sts get-caller-identity‘ to confirm what you’re logged in as.