在window10上安装Linux的使用方法/wsl/zsh/omz/ohmyzsh

本文指导如何在Windows上安装和配置WSL,使用PowerShell和Windows Terminal安装Debian,并进行Linux环境的优化,包括安装vim、git、gcc等开发工具,以及设置zsh和相关插件。此外,还提供了在CentOS上类似操作的命令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

好东西,VMware滚出我电脑
大体上我们需要4个东西
powershell
wsl
Debian
Windows terminal


分别来介绍他们

1. powershell

总之就是一个终端,跟iterm2一样,比cmd更好用
唤起方法
win+r
在这里插入图片描述

2. windows terminal

一个比powershell更更好用的终端
以后就用这个了,但是在安装的过程中仍然需要powershell的出场
理由是我们需要管理员权限来安装wsl

3. Debian

Linux的主体啦,Ubuntu centos什么都行

4. wsl

shell到Debian的桥梁,实际是在windows上开了个虚拟机


开始安装

1

在这里插入图片描述
搜索wsl
下载他们

2.

下载完成后,打开Debian会看到报错
安装不了
去提示的网站看解决办法
照着操作就行了,简化版我不行,手动操作
2.1 适用于 Linux 的 Windows 子系统
管理员身份运行powershell
在这里插入图片描述

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

2.2 启用虚拟机功能

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

2.3 重启
对,就是重启windows
2.4 下载 Linux 内核更新包
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
运行安装,安装完成后
2.5 将 WSL 2 设置为默认版本

wsl --set-default-version 2

至此就安装完了,powershell也没用了
打开terminal

wsl
cd ~
explorer.exe .

进入新世界
不过现在Debian上啥都没有
没有wget,没有vim

sudo apt-get update
sudo apt-get install wget

打开Windows上的vscode
安装插件Remote - WSL

在terminal上执行

code .

安装一些其他的重要东西

sudo apt install vim
sudo apt-get install git
sudo apt install gcc
sudo apt install g++
sudo apt-get install zsh
cat /etc/shells
ls -l /usr/bin/zsh
chsh -s /usr/bin/zsh
cd
git clone git@github.com:ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
export ZSH_CUSTOM=/home/knoe/.oh-my-zsh/custom
echo $ZSH_CUSTOM
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
or
git clone git@github.com:zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
or
git clone git@github.com:zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

在centos上的按照参考如下命令

yum -y install git
yum -y install g++
yum -y install zsh

修改zshrc文件

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#dfff00,bg=cyan,bold,underline"
# ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=202"
plugins=(
git
pip
zsh-autosuggestions
zsh-syntax-highlighting
)
alias ll='ls -l'
alias grep="grep --color=auto"

最后再执行一遍zsh

装差不多了,c++也能跑了
[note] 如果是mac的partial 自动补全不好用的话,参考
https://stackoverflow.com/questions/6205157/how-to-set-keyboard-shortcuts-to-jump-to-beginning-end-of-line


再美化一点
在terminal内部,按CTRL+,
唤起设置,进入json
修改

 "profiles": 
    {
        "defaults": 
        {
            "useAcrylic": true,
            "opacity": 0.6,
            "bellStyle": "none"
        },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值