阅读 175

WSL2 安装ArchLinux

WSL2 安装ArchLinux

安装ubuntu测试

从win10商店下载完直接运行一般会出错

The WSL optional component is not enabled. Please enable it and try again.
See https://aka.ms/wslinstall for details.
Error: 0x8007007e
Press any key to continue...

需要运行命令打开WSL的功能,以管理员身份打开powershell运行以下命令

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

安装完成后会提示重启,重启会更新一些组件延后正常打开就会安装了,安装提示输入用户名和密码就可以正常进入系统了。

PS:修改root用户的密码

sudo -s #切换到root用户
passwd  #设置密码

安装Windows Terminal和美化

使用WSL配合windows termianl使用更佳

从win10商店安装直接使用,通过win+r打开运行wt.exe就可以快捷打开

简单美化一下

打开设置,选择开启Json文件,其中是Terminal的配置文件

{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",

    // You can add more global application settings here.
    // To learn more about global settings, visit https://aka.ms/terminal-global-settings

    // If enabled, selections are automatically copied to your clipboard.
    "copyOnSelect": false,

    // If enabled, formatted data is also copied to your clipboard
    "copyFormatting": false,


    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles.
        },
        "list":
        [
            {
                // Make changes here to the powershell.exe profile.
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
			   "useAcrylic" : true,
                "hidden": false
            },
            {
                // Make changes here to the cmd.exe profile.
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "命令提示符",
                "commandline": "cmd.exe",
			   "useAcrylic" : true,
                "hidden": false
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
                "hidden": false,
                "name": "Ubuntu-20.04",
                "source": "Windows.Terminal.Wsl"
            }
        ]
    },

    // Add custom color schemes to this array.
    // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
    "schemes": [],

    // Add custom actions and keybindings to this array.
    // To unbind a key combination from your defaults.json, set the command to "unbound".
    // To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
    "actions":
    [

        { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
        { "command": "paste", "keys": "ctrl+v" },

        { "command": "find", "keys": "ctrl+shift+f" },

        { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
    ]
}

其中profiles对应着每一个终端的配置,添加

"useAcrylic" : true

开启亚克力特效,还可以设置字体等(fontFace),方法类似

开启WSL2

以管理员身份打开Powershell,运行一下命令开启虚拟机平台可选功能

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

安装Linux内核更新包

  • 适用于 x64 计算机的 WSL 2 Linux 内核更新包
  • 适用于 ARM64 计算机的 WSL 2 Linux 内核更新包

设置WSL2为默认版本

wsl --set=default-version 2

尝试切换原来的为wsl的ubuntu为wsl2

wsl --set-version Ubuntu-20.04 2  #--set-version后跟开发版的名字再跟wsl版本

出现以下提示

正在进行转换,这可能需要几分钟时间...
有关与 WSL 2 的主要区别的信息,请访问 https://aka.ms/wsl2
转换完成。

查看,发现版本已经改变了

wsl -l -v

下载 ,下载最新的zip包,解压运行Arch.exe,会在目录下生成系统运行文件,Arch就可以使用了

Arch初始化配置

首先打开/etc/pacman.conf配置文件,配置一下源,打开

[multilib]
Include = /etc/pacman.d/mirrorlist

结尾添加archlinuxcn的源

[archlinuxcn]
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch

更新一下源

pacman -Syy  

初始化一下

pacman-key --init
pacman-key --populate
pacman -S archlinuxcn-keyring

更新

pacman -Syyu  #强烈建议先更新再进行下面的操作

给当前账号设置密码

passwd

安装一些基本的软件

pacman -S base base-devel git curl wget zsh yay

新建用户

useradd -m -G wheel -s /bin/bash <用户名>
passwd <用户名>

将文件/etc/sudoers中的wheel ALL=(ALL) ALL那一行前面的注释去掉

vim /etc/sudoers  #文件为只读文件,不要尝试修改文件权限,强制保存命令 :w !sudo tee %

回到 Windows 中 Arch.exe 所在目录,打开命令提示符并运行 Arch.exe config --default-user $用户名,设置启动默认用户

PS:如果修改sudoers出现问题而又没有备份可以重新安装sudo解决

安装ohmyzsh

原文:https://www.cnblogs.com/yunzimo/p/14993509.html

文章分类
代码人生
文章标签
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐