Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Fedora 33 through Microsoft WSL2

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use Fedora 33 through Microsoft's WSL2, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

precondition

To achieve this goal, you need some basic conditions. You should be running Windows 10 and have WSL2 installed. If not, please check the Microsoft documentation and come back here when you are finished. Microsoft recommends that WSL2 be set as the default setting for distributions for simplicity. This guide assumes that you have already done so.

Next, you will need some methods to extract the xz compressed files. You can extract it with another WSL-based distribution, or you can use 7zip.

Download Fedora 33 rootfs

Since Fedora does not provide an actual rootfs archive, we will borrow an archive that is used to generate an image of the Dockerhub container. You need to download the tar.xz file from fedora-cloud 's GitHub repository. Once you have the tar.xz file, extract it, but do not expand the tar package. You will get a file similar to the fedora-33- time tag. Tar. With this file, you can build the image.

Build version of combined WSL Fedora

I like to use the c:\ distros directory, but you can choose almost any location you want. No matter which directory you choose, make sure its top-level path exists before you import the build. Now open a CMD or Powershell prompt, because it's time to import:

Wsl.exe-- import Fedora-33 c:\ distros\ Fedora-33$ HOME\ Downloads\ fedora-33.tar

You will see that Fedora-33 is displayed in the list of WSL:

PS C:\ Users\ jperrin > wsl.exe-l-v NAME STATE VERSION Fedora-33 Stopped 2

Next, you can start playing with Fedora in WSL, but there are a few things we need to do to make it a really useful WSL distribution.

Wsl-d Fedora-33

This starts the WSL instance of Fedora as the root user. Next, you will install some core packages and set up a new default user. You also need to configure sudo, otherwise you will not be able to easily upgrade permissions when you need to install something else in the future.

Dnf updatednf install wget curl sudo ncurses dnf-plugins-core dnf-utils passwd findutils

Wslutilites uses curl and wget to integrate with VS Code, so they are useful. Since you need to use the COPR repository, you need to add dnf functionality.

Add your users

Now is the time to add your user and set it as the default user.

Useradd-G wheel user name passwd user name

Now you have created your user name and added a password to make sure they work. Exit the WSL instance and start it again, this time specifying the user name. You also need to test sudo and check your uid.

Wsl-d Fedora-33-u user name $id-u1000 $sudo cat / etc/shadow

Assuming everything is all right, you are now ready to set the default user for your Fedora environment in Windows. To do this, exit the WSL instance and return to Powershell. This single line of Powershell code will correctly configure your users:

Get-ItemProperty Registry::HKEY_CURRENT_USER\ Software\ Microsoft\ Windows\ CurrentVersion\ Lxss\ *\ DistributionName | Where-Object-Property DistributionName-eq Fedora-33 | Set-ItemProperty-Name DefaultUid-Value 1000

Now you should be able to start WSL again without being specified to be your own user instead of root.

Custom definition!

At this point, you have a basic Fedora 33 environment that can run in WSL, but it doesn't have the Windows integration part yet. If you want this, there is a COPR repository that can be enabled. If you choose to add this section, you can run Windows applications directly in shell, or you can easily integrate your Linux environment with VS Code. It is important to note that COPR is not officially supported by the Fedora infrastructure. Use this software package at your own risk.

Dnf copr enable trustywolf/wslu above is all the contents of the article "how to use Fedora 33 through Microsoft WSL2". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report