环境构建

兜兜转转,最后还是回到了双系统…

大一上:分别使用了Ubuntu18.04LTS和Deepin15,体验相当不爽

大一下&大二上:使用WSL2+HyperV,体验良好,但是仍然有不少小bug

现在:Manjaro-Kde+Windows双系统

WSL2使用记录

WSL与WSL2

WSL简介

WSL2相比WSL最大的优势在于速度的提高和一个完整的Linux内核

但是启用了WSL2后(使用了类似于Hyper-V的技术),VMware正式版将无法使用(测试版可以调用Hyper-V,类似于虚拟机套娃,但性能就emmm)

而WSL可以与VMware共存,这是两者的差别,也是WSL的优势

同时WSL2的网络部分与WSL不同,在一些设置上需要特别注意

启用WSL2

在 Windows 10 上安装适用于 Linux 的 Windows 子系统 (WSL)

以管理员身份运行powershell,启用WSL

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

同样以管理员身份运行powershell,将WSL升级到WSL2

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

然后重启电脑

重启完成后,下载WSL2的Linux内核更新包并安装更新

更新 WSL 2 Linux 内核

至此,WSL2已经启用

  • WSL的常用操作
1
2
3
4
5
6
7
8
关闭所有wsl发行版
wsl --shutdown
关闭某个wsl发行版
wsl -t <DistroName>
注销(即卸载)某个发行版
wsl --unregister <DistroName>
设置默认wsl版本
wsl --set-default-version <版本 1或者2>

在WSL2上安装系统

首先,前往Windows store下载Windows terminal

购买 Windows Terminal - Microsoft Store zh-CN

打开Windows terminal,在里面输入wsl --set-default-version 2,将WSL2设置为默认发行版

  1. 通过Windows store下载Debian10(默认安装在系统盘)

购买 Debian - Microsoft Store zh-CN

下载完成,点击启动后,等待一到两分钟来完成初始化,然后输入用户名和密码

进入到Debian后,可以关闭启动产生的命令行窗口,使用Windows terminal,输入wsl即可进入Debian

  1. 通过微软官方下载,可安装在其他位置

Debian10

将下载得到的文件的后缀修改为.zip,解压到安装位置,双击exe文件即可运行安装程序

等待一到两分钟来完成初始化,然后输入用户名和密码

进入到Debian后,可以关闭启动产生的命令行窗口,使用Windows terminal,输入wsl即可进入Debian

Terminal美化(可选)

Fira Code Retina 字体下载链接

Windows Terminal Color Schemes

这是我的配置文件

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// This file was initially generated by Windows Terminal 1.4.3243.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",

"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"alwaysShowTabs": true,
"initialCols": 90,
"initialRows": 30,

// 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,

// A profile specifies a command to execute paired with information about how it should look and feel.
// Each one of them will appear in the 'New Tab' dropdown,
// and can be invoked from the commandline with `wt.exe -p xxx`
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
"profiles":
{
"defaults":
{
"useAcrylic": true,
"acrylicOpacity": 0.5,
"fontFace": "Fira Code Retina",
"fontSize": 14,
"cursorColor": "#FFFFFF"
},
"list":
[
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"colorScheme": "One Half Dark"
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "Command Prompt",
"commandline": "cmd.exe",
"hidden": true
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": true,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
{
"guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
"hidden": false,
"name": "Debian",
"source": "Windows.Terminal.Wsl",
"colorScheme": "One Half Dark"
}
]
},

// 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":
[
// Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
// These two lines additionally bind them to Ctrl+C and Ctrl+V.
// To learn more about selection, visit https://aka.ms/terminal-selection
{ "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
{ "command": "paste", "keys": "ctrl+v" },

// Press Ctrl+Shift+F to open the search box
{ "command": "find", "keys": "ctrl+shift+f" },

// Press Alt+Shift+D to open a new pane.
// - "split": "auto" makes this pane open in the direction that provides the most surface area.
// - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
// To learn more about panes, visit https://aka.ms/terminal-panes
{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
]
}

Linux换源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

sudo rm /etc/apt/sources.list

sudo nano /etc/apt/sources.list

  • Debian10阿里源
1
2
3
4
5
6
7
8
9
10
11
deb http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib

deb http://mirrors.aliyun.com/debian-security buster/updates main
deb-src http://mirrors.aliyun.com/debian-security buster/updates main

deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib

deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib

sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y

配置系统代理(clash)

  • wsl1

.bashrc或者.zshrc中添加如下内容

1
2
3
export https_proxy="http://127.0.0.1:7890";
export http_proxy="http://127.0.0.1:7890";
export all_proxy="socks5://127.0.0.1:7890";
  • wsl2

.bashrc或者.zshrc中添加如下内容

1
2
3
4
export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*');
export https_proxy="http://${hostip}:7890";
export http_proxy="http://${hostip}:7890";
export all_proxy="socks5://${hostip}:7890";

完成后,输入source .bashrc或者source .zshrc

  • apt代理

sudo apt -o Acquire::http::proxy="http://172.27.176.1(此处ip为wsl的ip):7890/" install *********

ZSH&开发环境

  • 安装zsh和基本开发软件

sudo apt install zsh gcc g++ gdb python python3 python-pip python3-pip

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

编辑~/.zshrc
ZSH_THEME的值改为agnoster或保持默认(个人喜好

隐藏用户名
DEFAULT_USER=$USER

安装 syntax-highlighting & zsh-autosuggestions

1
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting && git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions && chmod -R 555 ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting && chmod -R 555 ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

编辑~/.zshrc

plugins=(git z colored-man-pages zsh-autosuggestions zsh-syntax-highlighting)

在切换shell后,.bashrc中的代理设置要复制到.zshrc

使zsh配置生效
source ~/.zshrc

  • 配置pip清华源
1
2
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

或者在~/.pip/pip.conf中添加(建议使用这种方式)

1
2
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
  • clion&vscode链接wsl

在安装完clion和wsl2后以管理员身份运行powershell

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

clion官方文档

wget https://raw.githubusercontent.com/JetBrains/clion-wsl/master/ubuntu_setup_env.sh && bash ubuntu_setup_env.sh

P.S 如果使用的是zsh那么需要将bash中新增的关于自动链接到clion的配置复制到zsh中

在clion中配置wsl的链接

Developing in the Windows Subsystem for Linux with Visual Studio Code

在vscode中安装Remote-WSL插件

Remote - WSL - Visual Studio Marketplace

安装后在你要进行开发的目录下,如~/python_code,输入code .即可进行开发

一些bug

  1. Windows要访问WSL2中的应用(如hexo生成的预览),有时不能直接通过localhost进行访问

  2. 有时候Windwos会因为网络原因无法链接到WSL2

  3. WSL2的文件IO较慢

HyperV使用记录

使用原因

在开启WSL2后,VMware的正式版不能正常使用,所以我一开始尝试了VMware的测试版(现在的15.5版本已经可以支持了)

VMware的博客和对测试版的介绍

VMware的博客和对15.5版的介绍

总的来说,在使用测试版时没有遇到特别大的问题,但是由于是虚拟机套娃,性能严重下降(没有使用过正式版,不清楚是否对其进行了优化),因此我把目光转向了Hyper-V

配置Hyper-V

Hyper-V使用感受

Hyper-V给我的感受是比VMware流畅,且资源占用较低,因为Hyper-V虚拟Windows系统(或者是快速构建中列出的系统)可以使用动态内存分配

而在使用增强模式后,除了拖动窗口有时存在掉帧现象,基本跟实体机没有太大的区别

启用Hyper-V

在BIOS中启用虚拟化选项

在控制面版中选择启用或关闭Windows功能,勾选Hyper-V,等待下载完成后,重启电脑

Ubuntu虚拟机

在任务栏的搜索框中输入Hyper-V,点击Hyper-V管理器

点击右边的快速构建,选择Ubuntu18.04.3LTS,等待下载完成即可(建议使用代理进行下载)(注意在设置用户名和密码时不要勾选自动登录)

然后在弹出的窗口大小确认框中点击确定即可,然后输入用户名和密码,即可使用增强模式

Windows虚拟机

快速构建中的Windows10开发环境使用的是企业评估版(emmmm….),PASS

首先,用MediaCreationTool下载Windows10的ISO镜像文件

下载 Windows 10

在Hyper-V管理器中点击右边的构建,选择虚拟机,代数选择第二代,网络选择Default Switch,安装选项选择使用iso文件

点击新建的虚拟机,在右下角的设置中,先关闭安全启动,并将CPU的核数调整为你的CPU核数,点击链接然后启动即可

安装并初始化完成后,关机,重新开启安全启动

Windows默认使用增强模式,无需手动启用

Ubuntu配置

  • 换源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

sudo rm /etc/apt/sources.list

sudo nano /etc/apt/sources.list

Ubuntu18.04阿里源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y

  • 常用工具配置
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
sudo apt install vim gcc g++ gdb python python3 python-pip python3-pip git wget curl unzip binwalk file ruby-dev foremost aircrack-ng libgmp-dev libmpfr-dev libmpc-dev libssl-dev python-tk cmake python3-docopt python-docopt libgmp3-dev -y
sudo gem install zsteg

sudo apt install qemu

sudo apt-get install gcc-multilib

sudo apt-get install libc6-armhf-cross

配置pip清华源
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

或者在~/.pip/pip.conf中添加

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

git代理
git config --global http.proxy http://xxx.xxx.xxx.xxx:xxx
git config --global https.proxy http://xxx.xxx.xxx.xxx:xxx

pip install opencv-python==4.2.0.32 matplotlib Pillow gmpy2 z3-solver pyasn1
pip3 install scikit-build
pip3 install opencv-python gmpy2 z3-solver

git clone https://github.com/chishaxie/BlindWaterMark.git && git clone https://github.com/lijiejie/GitHack.git && git clone https://github.com/nccgroup/featherduster.git && git clone https://github.com/bwall/HashPump.git && git clone https://github.com/pablocelayes/rsa-wiener-attack.git && git clone https://github.com/RobinDavid/LSB-Steganography.git && git clone https://github.com/livz/cloacked-pixel.git && git clone https://github.com/rocky/python-uncompyle6.git && git clone https://github.com/Ganapati/RsaCtfTool.git && git clone https://github.com/matthewgao/F5-steganography.git && git clone https://github.com/ius/rsatool.git && git clone https://github.com/radareorg/radare2.git && git clone https://github.com/nemanja-m/gaps.git
部分仓库的安装 sudo python setup.py install
radare2安装: sys/install.sh
  • 配置32位环境
1
2
3
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
  • 配置Java环境

Java SE Development Kit 8 Downloads

Java SE Development Kit 8u***界面,选择 jdk-8u***-linux-x64.tar.gz

将下载得到的文件解压,并修改.zshrc 或者.bashrc ,在文件末尾添加

1
2
3
4
JAVA_HOME=~/jdk1.8.0_***
export JRE_HOME=~/jdk1.8.0_***/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

修改完成后, source .zshrc 或者 source .bashrc 使配置生效

Windows配置

可能存在病毒,请勿在实体机上使用

CTF_Tools.7z

Manjaro使用记录

注意事项

  1. 在安装时要找到Windows10的efi分区(100MB那个),选择保留,挂载点/boot/efi,标记勾选boot

  2. 如果安装卡在了93%,可以直接断网,此时已经安装完成

  3. 双系统对时sudo timedatectl set-local-rtc true

  4. 换源sudo pacman-mirrors -c China -m rank

  5. 安装基础包sudo pacman -S base-devel

常用软件

yay sudo pacman -S yay


输入法&字体

wiki指北

yay -S fcitx5-im

nano ~/.pam_environment

1
2
3
4
GTK_IM_MODULE DEFAULT=fcitx
QT_IM_MODULE DEFAULT=fcitx
XMODIFIERS DEFAULT=\@im=fcitx
SDL_IM_MODULE DEFAULT=fcitx

yay -S fcitx5-qt

yay -S fcitx5-gtk

yay -S fcitx5-rime

重启

wiki指北

在输入状态下点击F4更换为简体

思源字体

sudo pacman -S adobe-source-han-sans-cn-fonts


google-chrome yay -S google-chrome

typora yay -S typora

vscode yay -S visual-studio-code-bin

wireshark yay -S wireshark-qt

burpsuite yay -S burpsuite


docker yay -S docker

启动docker sudo systemctl start docker.service

开机自启动 sudo systemctl enable docker.service

将用户添加到Docker组中 sudo usermod -aG docker username

打开或创建/etc/docker/daemon.json文件,将国内加速镜像填入到文件中

1
2
3
4
5
{
"registry-mirrors": [
"url"
]
}

完成后重启docker

sudo systemctl daemon-reload

sudo systemctl restart docker

安装Docker Compose

安装指北

sudo curl -L "https://github.com/docker/compose/releases/download/1.28.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

docker-compose --version


gcc yay -S gcc

gdb yay -S gdb

clion yay -S clion

pycharm yay -S pycharm

phpstorm yay -S phpstorm

binwalk yay -S binwalk

foremost yay -S foremost

zsteg yay -S zsteg

baidunetdisk yay -S baidunetdisk

upx yay -S upx

net-tools yay -S net-tools

010editor yay -S 010editor

notion yay -S notion-app

nodejs yay -S nodejs-lts-fermium

npm yay -S npm

motrix yay -S motrix


VMware

Arch-wiki指北

下载链接https://www.vmware.com/go/getworkstation-linux

当安装程序询问System service scripts directory的设置时,输入/etc/init.d即可

可能需要安装内核

查看本机内核uname -a

查找内核sudo pacman -Ss linux headers

安装内核sudo pacman -S linux***-headers

VMware安装完成后,虚拟机无法启动,输入sudo /etc/init.d/vmware start