#安装oh-my-zsh

gitee安装

sudo apt install curl git
sh -c “$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)”

外网安装

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

安装Powerlevel10k主题

git clone --depth=1 powerlevel10k: Official mirror of https://github.com/romkatv/powerlevel10k {ZSH_CUSTOM:-HOME/.oh-my-zsh/custom}/themes/powerlevel10k

配置Powerlevel10k

vim ~/.zshrc编辑.zshrc,将ZSH_THEME项改为:

ZSH_THEME=“powerlevel10k/powerlevel10k”

#安装各种插件
#zsh-autosuggestions
git clone zsh-users/zsh-autosuggestions {ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
#zsh-syntax-highlighting
git clone https://gitee.com/zsh-users/zsh-syntax-highlighting.git {ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
#使插件生效,上述插件安装完成后,需要修改.zshrc文件,编辑plugins项,修改如下:

值得注意的是,根据官方文档,zsh-syntax-highlighting 插件需放在最后

plugins=(
git extract zsh-autosuggestions zsh-syntax-highlighting
)
#使用source ~/.zshrc命令更新。

vim ~/.zshrc编辑,添加以下一行

setopt no_nomatch #解决无法识别*问题

Usagechsh -s /bin/zsh

WSL ubuntu Usage

Windows11 WSL离线安装Ubuntu子系统 - 漫漫长夜何时休 - 博客园

installation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 启用Linux子系统 以管理员身份打开PowerShell
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
# 下载tar文件,最终要获得tar格式的镜像
# ms的官方下载tar
https://learn.microsoft.com/zh-cn/windows/wsl/use-custom-distro
#
https://cloud-images.ubuntu.com/wsl/jammy/20250227/ubuntu-jammy-wsl-amd64-ubuntu22.04lts.rootfs.tar.gz
# 安装
wsl --import <DistroName> <location to Install> <location of wsl.rootfs.tar.gz File>
wsl --import Ubuntu22.04 E:\Ubuntu E:\ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz
# 验证安装是否成功
wsl -l
# 进入ubuntu
wsl -d <DistroName>
wsl -d Ubuntu22.04

DriverInstallation

换源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
 sudo vim /etc/apt/sources.list
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe mult
iverse

sudo apt update
sudo apt upgrade

ZSH

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 安装zsh
sudo apt install zsh
# 然后将zsh设置为默认shell:
chsh -s /bin/zsh
echo $SHELL

#安装oh-my-zsh
# gitee安装
sudo apt install curl git
sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"
# 外网安装
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

# 安装Powerlevel10k主题
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
# 配置Powerlevel10k
# vim ~/.zshrc编辑.zshrc,将ZSH_THEME项改为:
ZSH_THEME="powerlevel10k/powerlevel10k"

#安装各种插件
#zsh-autosuggestions
git clone https://gitee.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
#zsh-syntax-highlighting
git clone https://gitee.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
#使插件生效,上述插件安装完成后,需要修改.zshrc文件,编辑plugins项,修改如下:
# 值得注意的是,根据官方文档,zsh-syntax-highlighting 插件需放在最后
plugins=(
git extract zsh-autosuggestions zsh-syntax-highlighting
)
#使用source ~/.zshrc命令更新。
# vim ~/.zshrc编辑,添加以下一行
setopt no_nomatch #解决无法识别*问题

Usage

User创建

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 删除用户名
userdel outbreak

// 删除组名
groupdel outbreak

// 创建新用户,输入两次密码直接回车
sudo adduser outbreak
// 把新建用户(outbreak)下的所有文件、文件夹的用户名和组名修改为mysql57
// sudo chown -R 用户名:组名 -R 新用户路径
sudo chown -R outbreak:outbreak /home/outbreak
// 赋予新用户sudo权,为了让新用户能够执行管理员操作,需要将其添加到sudo组:

sudo usermod -aG sudo outbreak
// 使用以下命令切换到新用户
su - outbreak
// 直接在powershell进入时候
wsl -u outbreak

安装图形化界面

  • 为了更方便地使用Ubuntu,可以安装图形化界面(如XFCE4)。首先,安装VcXsrv(Windows端的X服务器):

    • 下载并安装VcXsrv:下载链接
  • 在Ubuntu中安装XFCE4:

    1
    sudo apt install xfce4
  • 配置.bashrc文件以启动图形界面:

    1
    2
    3
    4
    5
    echo "export DISPLAY=$(awk '/nameserver / {print $2}' /etc/resolv.conf 2>/dev/null):0" >> ~/.bashrc
    source ~/.bashrc

    echo "export DISPLAY=$(awk '/nameserver / {print $2}' /etc/resolv.conf 2>/dev/null):0" >> ~/.zshrc
    source ~/.zshrc