Install Arch Linux in Windows WSL and Set it Up

Arch Linux is now officially available on WSL. Here's how you can use it with some extra efforts in setting it up post install.
Warp Terminal

WSL feature allows running an actual Linux distribution inside Windows. Ubuntu was the first distro that could be installed this way. Soon, SUSE, Kali Linux and some other Linux distributions joined the WSL bandwagon.

Recently, after much waiting, Arch Linux also became a part of the WSL distributions.

In this article, I show you the steps for using Arch Linux WSL system under WSL 2.

There are some prerequisites.

If your system meets the prerequisites, follow the steps for installing Arch Linux in WSL and setting it up.

Step 1: Installing Arch Linux in WSL

You can install Arch Linux in two different ways in WSL, both producing the same result, a working Arch Linux WSL installation.

  • Install from WSL online repository: Easy and recommend.
  • Install manually using Arch Linux WSL file: For the sake of Arch Linux complexity.

I will discuss the first method in this section. The manual method is discussed later to avoid any confusion.

Since Arch Linux now officially supported in WSL, there is an image available on the WSL online repositories.

List the available WSL distributions using the command:

wsl --list --online
List all the WSL distributions available online that can be installed. Here, you can find Arch Linux is listed with the name archlinux.
List of online distros to spot Arch Linux

Now, to install Arch Linux, use the WSL command below:

wsl --install archlinux

This will download the Arch Linux image and install the distribution.

Installing Arch Linux using the wsl --install command. This will download the image and install Arch Linux for you. You can also see some essential instructions printed on the screen during the launching of installed Arch Linux.
Install Arch Linux using the default WSL install command

Once the installation is finished, you will be logged in as the root.

Step 2: Setting up Arch Linux

The default Arch Linux installation (both official repo and manual) logs you in as a root user. There is no regular admin user created for your day-to-day usages at this stage. But we will create it ourselves.

If you have already installed Ubuntu in WSL, it prompts you to create a user soon after the installation is finished. Since Arch Linux is a DIY Linux distribution, such convenience should not be expected.

๐Ÿšง
Do not close the launched Arch Linux WSL without setting a root password.

Set a root password

Since you currently haven't a root password set up, do that by using the passwd command:

passwd

Type and retype the password to make the change effect. Please note that nothing is displayed on the screen when you type the password. That's normal behavior.

Set a root password for Arch Linux using the passwd command. Type and retype the password to confirm
Set root password

Update the system

Once you have opened the newly installed Arch Linux WSL, use the command below to update the system.

pacman -Syu

Stop Arch Linux and reopen it.

wsl.exe --terminate archlinux

Install sudo

Chances are there that sudo is not installed. If that's the case, you may not be able to access visudo in a later stage to set admin privileges.

To check if sudo is installed, use the command:

pacman -Qs sudo

If sudo is not listed, install sudo using:

pacman -S sudo
Install sudo in Arch Linux WSL using the pacman command
Install sudo in Arch Linux WSL

Create a new user

It is not recommended to log in as the root all the time. You need a regular user who can run administrative commands when needed.

In Arch Linux, you can use the useradd command, to create a new user. Let's create a new user called โ€œteamโ€.

useradd -m team

Here, the -m option will automatically create a home directory for the user at /home/.

Set a password for the user โ€œteamโ€, using:

passwd team

Type and retype password to confirm the change.

Once the user is created, add that user to the wheel group so that it can run the sudo command to access some administrative privileges.

usermod -aG wheel team
Create a new user using the useradd command. Set a password to the user using passwd command. Now, add the newly created user to wheel group.
Create a new user and add a password

But at this point, the wheel group cannot run all the commands. For this, you need to allow the members of the wheel group to run any commands.

Edit the sudoers file with Nano editor.

EDITOR=nano visudo

Locate the line %wheel ALL=(ALL) ALL and uncomment it.

Edit sudoers file in Arch Linux WSL to make wheel group run all commands
Edit sudoers file

Save the document using CTRL + O and exit using CTRL + X.

At this point, you can just terminate the system using the command:

wsl.exe --terminate archlinux

And then reopen it from the Windows terminal.

wsl ~ -d archlinux -u team

Here, you are directly logging in as the normal user (team), that was created in the previous step. The ~ option will land you straight in the home directory of the user.

Or, you can create a file inside the Arch Linux system by running the following command:

sudo nano /etc/wsl.conf
๐Ÿ“‹
Note that we have used the sudo command here, because we are now logged in as normal user team.

Inside this file, add the line:

[user]
default = team

This will set the user โ€œteamโ€ as the default one. You will no longer be logging in as the root.

Now, save the file and exit. Terminate the system using the command:

wsl.exe --terminate ArchLinux

Now, you can restart the system to see that you are logged in with the default regular user instead of root:

wsl ~ -d ArchLinux
Showing fastfetch output in Arch Linux WSL.
Arch Linux Fastfetch

Change hostname

To change the hostname of the WSL, you can add the following line to your /etc/wsl.conf file:

[network]
hostname=new_host_name

That's it. You can enjoy the Arch Linux experience on Windows now.

In case you want to know the manual installation steps

Along with the WSL repo image, Arch Linux also provides a WSL image as part of archlinux-wsl project.

First, download the latest archlinux-xxxx.wsl image from the official downloads page.

Once downloaded the file to a local folder, go to that folder in File Explorer.

Arch Linux WSL file is downloaded to the Downloads folder on system.
Arch Linux WSL File in File Explorer

Select the file and press CTRL+SHIFT+C to copy the path to the file. You can also right-click on the file and select the Copy as Path option.

Now, open a Windows terminal and use the command below to install it.

wsl --install --from-file <PATH-TO-WSL-IMAGE>

In place of PATH-TO-WSL-IMAGE, paste the copied location.

Install Arch Linux in WSL using the official WSL file provided by Arch Linux.
Installing Arch Linux from File

It will be followed by the same post-install steps that you saw earlier.

For advanced setup documentation, you can always refer to the official Arch Wiki page.

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries ๐Ÿ•ต๏ธโ€โ™‚๏ธ

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

itsfoss happy penguin

Great! Youโ€™ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.