Compare commits

..

61 Commits

Author SHA1 Message Date
dichgrem
c883e002ad add:linux_android 2025-11-20 14:18:37 +08:00
dichgrem
a5a811608d update:lazyvim 2025-11-20 12:01:52 +08:00
dichgrem
ad5bc86ddf update:stm32 2025-11-20 11:57:24 +08:00
dichgrem
1164d77a15 add:linux_0 2025-11-17 18:51:43 +08:00
dichgrem
954182c59b update:stm32 2025-11-17 16:30:44 +08:00
dichgrem
1c22b82f58 update:stm32 2025-11-15 19:33:11 +08:00
dichgrem
62217074f2 update:py 2025-11-13 14:37:35 +08:00
dichgrem
4640299780 update:git 2025-11-10 10:37:22 +08:00
dichgrem
30857cbbb3 update:git 2025-11-06 20:24:00 +08:00
dichgrem
83dc86033f chore:backup 2025-11-02 16:09:14 +08:00
dichgrem
9af2aeb13a update:openwrt 2025-11-01 10:42:24 +08:00
dichgrem
434521d632 add:mirror_workflow 2025-10-31 10:48:44 +08:00
dichgrem
51feef5fd8 add:stm32 2025-10-29 15:20:26 +08:00
dichgrem
bcfa288a4e update:win_auto 2025-10-29 14:57:32 +08:00
dichgrem
809591627a update:docker 2025-10-24 21:53:06 +08:00
dichgrem
3373111feb update:win_4 2025-10-16 12:30:13 +08:00
dichgrem
d24b8dd155 remove:gpg_key 2025-10-15 20:19:15 +08:00
dichgrem
203531caa9 add:linux_1 2025-10-15 20:08:49 +08:00
dichgrem
da46fc0cd9 update:op 2025-10-05 19:30:56 +08:00
dichgrem
4bf29e39f7 update:win_5_py 2025-09-27 14:40:07 +08:00
dichgrem
b8bcd064dc update:virtual 2025-09-16 20:21:11 +08:00
dichgrem
a0e34fef4a add:virtual 2025-09-11 14:40:02 +08:00
dichgrem
e68d110af2 update:windows-4-auto 2025-09-10 11:48:56 +08:00
dichgrem
db01994e59 update:windows-1 2025-09-02 11:51:37 +08:00
dichgrem
154b7e15af update:android-tv 2025-08-29 21:18:45 +08:00
dichgrem
2edb923e35 update:android-root 2025-08-29 11:09:02 +08:00
dichgrem
cf318a7643 fix:cumulative_layout_shift 2025-08-28 16:00:12 +08:00
dichgrem
dfd89e0c19 style:color&&font 2025-08-28 15:30:48 +08:00
dichgrem
6704b4369c fix:index_html 2025-08-28 15:08:34 +08:00
dichgrem
4a6c7c6cf2 fix:all_tags 2025-08-28 14:51:28 +08:00
dichgrem
ed263148b7 fix:scale 2025-08-28 10:48:12 +08:00
dichgrem
8d373307c2 fix:page.html 2025-08-28 10:09:59 +08:00
dichgrem
d6677c4963 fix:justfile 2025-08-28 10:05:30 +08:00
dichgrem
5aad129f6a style:tabs 2025-08-28 09:58:50 +08:00
dichgrem
8fe0f821f3 feat:add_ssh 2025-08-27 20:54:59 +08:00
dichgrem
77ffb7cc53 update:atv 2025-08-27 15:39:51 +08:00
dichgrem
4cc105c221 update:yt-dlp 2025-08-27 14:04:53 +08:00
dichgrem
d26638ece4 update:aria2 2025-08-27 10:51:04 +08:00
dichgrem
d406b974c3 add:yt-dlp 2025-08-25 13:03:43 +08:00
dichgrem
309ff158c3 update:sports 2025-08-05 21:41:34 +08:00
dichgrem
c4b73ad16c feat:add_flake 2025-08-04 19:10:59 +08:00
dichgrem
96bbeb99cb update:ventoy 2025-08-02 21:59:55 +08:00
dichgrem
ae4e526ea2 update:openwrt 2025-07-26 11:29:30 +08:00
dichgrem
c72880f07c update:linux 2025-07-21 09:54:11 +08:00
dichgrem
defe396d05 update:openwrt 2025-07-20 14:35:09 +08:00
dichgrem
23db8005e0 update:openwrt 2025-07-15 15:48:52 +08:00
dichgrem
fd5d415988 update:openwrt 2025-07-15 09:57:46 +08:00
dichgrem
80d8c193cc update:openwrt 2025-07-14 22:58:19 +08:00
dichgrem
79c32ed073 update:arch 2025-07-14 19:28:09 +08:00
dichgrem
de0f8c7094 update:openwrt 2025-07-14 19:12:53 +08:00
dichgrem
d1436fdf3d update:openwrt 2025-07-14 14:34:19 +08:00
dichgrem
b3e588daa6 update:win-all 2025-07-13 20:30:53 +08:00
dichgrem
71b4d83675 update:arch 2025-07-11 10:10:24 +08:00
dichgrem
4c4fb9a5d6 update:links 2025-07-10 19:43:21 +08:00
dichgrem
dd3f7f4641 update:arch 2025-07-10 12:07:30 +08:00
dichgrem
5a1be5b33b update:arch 2025-07-10 10:47:08 +08:00
dichgrem
7f4708a6cd update:arch 2025-07-08 18:51:47 +08:00
Dich
9840ee7e42 update:all 2025-07-05 15:03:43 +08:00
Dich
82e748ef73 update:android 2025-07-04 20:36:12 +08:00
Dich
76ce51bd5b update:blog 2025-06-18 21:26:58 +08:00
Dich
a3f9d12e8d fix:remove-public-history 2025-06-18 21:17:41 +08:00
299 changed files with 36514 additions and 718 deletions

View File

@@ -1,42 +0,0 @@
name: Blog CI (Zola)
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Zola
uses: taiki-e/install-action@v2
with:
tool: zola
- name: Install Pagefind
run: |
wget https://github.com/Pagefind/pagefind/releases/download/v1.4.0/pagefind-v1.4.0-x86_64-unknown-linux-musl.tar.gz
tar xvf pagefind-v1.4.0-x86_64-unknown-linux-musl.tar.gz
sudo mv pagefind /usr/local/bin/
- name: Build Zola
run: zola build
- name: Build Pagefind
run: pagefind --site public --root-selector body
- name: Push public to dist
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
publish_branch: dist
force_orphan: true

View File

@@ -0,0 +1,99 @@
+++
title = "Linux之旅(1):构成与发行版"
date = 2023-07-20
[taxonomies]
tags = ["Linux"]
+++
前言 Linux 作为一款强大、灵活且免费的操作系统吸引了越来越多的用户。然而对于初学者来说Linux 可能显得有些陌生,甚至有些令人望而生畏。本文旨在为那些刚踏入 Linux 世界的新手提供一份指南帮助他们更好地了解、使用这个令人着迷的操作系统。我们将探讨Linux的基本概念解释为何选择Linux深入剖析其主要构成要素以及不同的发行版之间的差异。
<!-- more -->
## 一.什么是Linux
Linux 是一种开源的类 UNIX 操作系统内核。它由芬兰的 Linus Torvalds 于1991年开始开发是一个自由、免费的操作系统。Linux 内核是操作系统的核心,负责管理硬件资源,并提供各种系统服务。与 Windows 和 macOS 等操作系统不同Linux 的源代码对所有人开放,任何人都可以查看、修改和重新分发。这使得 Linux 具有极高的自由度和可定制性用户可以根据自己的需求和偏好来定制操作系统。Linux 广泛应用于各种设备,包括个人计算机、服务器、手机、嵌入式系统等,是一个功能强大且灵活多样的操作系统。
## 二.为什么要用Linux
1. **开源免费**Linux 是完全开源的,用户可以免费使用和修改源代码。
2. **稳定性和安全性**Linux 系统以其稳定性和安全性而闻名,适合长时间运行的服务。
3. **灵活性和可定制性**:用户可以根据需要定制 Linux 系统。
4. **广泛的软件支持**:有大量的开源软件可供选择,满足不同需求。
> Liunx可以用来玩游戏吗
实际上著名的 Steam Deck 的系统就是基于Arch linux 的。对于个人使用而言现在有不少原生支持linux 的游戏也可以使用Wine来运行Windows下的游戏。
## 三.Linux的主要构成
Linux操作系统主要由以下几个部分组成
1. **内核**操作系统的核心负责管理系统资源。如Zen内核LTS内核等。
2. **Shell**命令行界面用户通过它与系统交互如Bash,Zsh等。
3. **图形用户界面GUI**提供图形化操作界面如GNOME、KDE、XFCE等。
4. **文件系统**如ext4、Btrfs等用于组织和管理磁盘上的文件。
5. **系统库**:为应用程序提供运行时支持。
6. **应用程序**用户可以直接使用的软件如文本编辑器、网页浏览器等。其中也有著名的GNU工具如Vim,GCC等。
## 四.选择Linux发行版
从上文可以发现选择Linux发行版实际上是在选择 **内核/包管理器/图形界面** 等组件的排列组合。其中最主要的因素是包管理器。
Linux有许多不同的发行版但大致可以分为几个系
**Debian系**
DebianDebian以稳定性安全性和轻量级著称适合用于服务器和桌面环境。我们常说的Ubuntu就是基于Debian的发行版注重用户友好性和易用性。它提供了多种桌面环境选择以及许多现成的软件包。
```
APTAdvanced Package Tool是Debian系发行版的主要包管理器。它使用命令行工具如apt-get、aptitude等来管理软件包。
```
**Red Hat系**
- Red Hat Enterprise LinuxRHELRHEL是一款商业发行版专注于企业级应用和支持。它提供了长期支持和专业技术支持服务适用于企业级服务器和工作站。
- CentOSCentOS是基于RHEL源代码编译而成的免费发行版与RHEL兼容并提供类似的功能和性能。它也提供了长期支持版本和稳定性较高的特点。
- FedoraFedora是由Red Hat支持的社区驱动的发行版注重提供最新的软件特性和技术。它适用于开发者和技术爱好者提供了稳定的发布周期和丰富的软件包。
```
YUMYellowdog Updater, Modified是Red Hat系发行版的主要包管理器。最近的版本也开始采用DNFDandified YUM
```
**Arch系**
Arch LinuxArch Linux是一个简洁、轻量级且灵活的发行版注重简洁性和滚动更新。它采用“滚动发布”的方式用户可以通过自定义安装来构建自己的系统适合有一定Linux经验的用户。
```
PacmanPackage Manager是Arch Linux的主要包管理器。它使用简洁的命令来管理软件包如pacman -S安装软件包、pacman -Syu更新系统等。
```
**Gentoo系**
GentooGentoo是一个源码驱动的发行版用户可以通过源代码自定义编译软件包以满足自己的需求。它注重性能和灵活性适合高级用户和技术爱好者。
```
Portage是Gentoo的包管理器它是一个源代码驱动的包管理器允许用户从源代码构建和安装软件包。
```
除了以上列举的包管理器外还有其他一些较为特殊的包管理器如Slackware系的pkgtool、SUSE系的zypper等。
对于个人使用而言我个人建议新手使用Ubuntu,有比较易用的界面和完善的资料参考如果你是一个系统极客可以使用Arch linux 或者 NixOS。
## 五.个人日常使用需要注意什么?
1. **学习命令行**命令行是Linux的强大工具学习基本命令可以提高效率。
2. **选择合适的发行版**:根据个人需求和技术水平选择适合的发行版。
3. **系统备份**:定期备份重要数据,以防意外丢失。
4. **软件管理**:了解如何安装、更新和卸载软件。
5. **安全设置**:设置强密码,定期更新系统以修复安全漏洞。
6. **社区参与**Linux社区非常活跃遇到问题可以寻求社区帮助。
7. **硬件兼容性**检查你的硬件是否与选择的Linux发行版兼容。
8. **驱动程序**:确保你的硬件设备有可用的驱动程序,以避免兼容性问题。

View File

@@ -0,0 +1,127 @@
+++
title = "Linux之旅(2):FHS与目录结构"
date = 2023-07-21
[taxonomies]
tags = ["Linux"]
+++
前言 在Linux世界中Filesystem Hierarchy StandardFHS是一座引导我们进入系统核心的桥梁它定义了Linux系统中目录结构的规范与作用为我们提供了一张清晰的地图指引我们轻松管理和理解系统。本文将深入探讨FHS规范与Linux系统目录结构解释各个目录的用途与功能帮助我们更好地理解和利用Linux系统。
<!-- more -->
## 一.认识FHS
FHS是Filesystem Hierarchy Standard文件系统层次结构标准的缩写。它是一个定义了Linux系统中目录结构和各个目录作用的规范。FHS规定了Linux系统中各个目录的用途和预期内容以便确保不同Linux发行版之间的兼容性并使得用户能够更轻松地理解和管理系统。
FHS规范最初由Linux基金会Linux Foundation和自由软件基金会Free Software Foundation共同发布并经过多次修订和更新。该规范不仅对Linux系统本身有用也适用于其他类UNIX操作系统。
FHS规范定义了一些基本的目录如/bin、/boot、/dev等并规定了每个目录的作用和预期内容。这样做有助于系统管理员和开发人员更好地组织和管理文件系统并使得用户能够更轻松地找到所需的文件和数据。
## 二.常见目录结构
在刚刚由Windows切换至Linux时往往会对目录感到不解不知道安装的软件放在哪个目录之下
以下是对Linux系统目录结构的详细说明
- **/(根目录)**
根目录是整个文件系统的起点包含了系统中所有其他目录和文件。在Linux系统中根目录被表示为/。
- **/bin二进制文件**
/bin目录存放着一些最基本的系统命令如ls、cp、mv等这些命令通常被所有用户使用。
- **/boot引导文件**
/boot目录存放着启动Linux系统所需的引导文件如内核映像vmlinuz、引导加载程序boot loader配置文件如GRUB配置文件等。
- **/dev设备文件**
/dev目录包含了系统中所有设备的特殊文件如硬盘、键盘、鼠标等。在Linux中一切皆文件设备被抽象为文件通过/dev目录中的特殊文件来表示。
- **/etc配置文件**
/etc目录包含了系统的配置文件如网络配置、用户账户信息、服务配置等。这些配置文件通常以纯文本的形式存在可以由系统管理员进行编辑和修改。
- **/home用户主目录**
/home目录是系统中所有普通用户的主目录所在地每个用户通常都有一个对应的子目录用于存放用户的个人文件和数据。
- **/lib库文件**
/lib目录存放着系统所需的共享库文件这些库文件包含了一些程序运行所需的函数和数据为程序提供了基本的支持。
- **/mnt挂载点**
/mnt目录用于挂载临时文件系统如光盘、移动硬盘等。系统管理员可以将其他设备或文件系统挂载到/mnt目录下以便访问其中的文件和数据。
- **/opt可选软件包**
/opt目录用于存放一些可选的软件包和应用程序这些软件包通常不属于Linux发行版的默认安装范围但可以被用户自行安装和管理。
- **/proc进程信息**
/proc目录是一个虚拟的文件系统包含了系统运行时的各种进程信息和系统状态信息。用户可以通过读取/proc目录中的特殊文件来获取系统信息。
- **/sbin系统命令**
/sbin目录存放着一些系统管理和维护命令这些命令通常只能由超级用户root执行用于系统的管理和维护。
- **/srv服务数据**
/srv目录用于存放一些服务相关的数据文件如Web服务器的网站数据、FTP服务器的文件等。每个服务通常都会有一个对应的子目录。
- **/tmp临时文件**
/tmp目录用于存放临时文件和临时数据这些文件通常在系统重启时会被删除。任何用户都可以在/tmp目录下创建临时文件。
- **/usr用户程序**
/usr目录包含了系统中大部分用户可用的程序和文件如用户应用程序、共享库文件、文档等。它通常是系统的二级目录类似于Windows系统中的Program Files目录。
- **/var可变数据**
/var目录用于存放系统运行时产生的可变数据如日志文件、邮件、缓存文件等。这些数据通常会随着系统的运行而不断变化。
> 注意NixOS不符合FHS标准
## 三.分区大小
对各个分区进行容量分配时,需要根据系统的实际需求和用途来进行规划。一般而言在安装引导时可以选择让程序自动分区。
- **根目录(/**根目录是整个文件系统的起点通常会分配较大的空间以确保系统和应用程序有足够的空间运行。建议分配至少20GB的空间给根目录。
- **/home目录**/home目录用于存放用户的个人文件和数据因此需要根据用户数量和存储需求来进行容量分配。一般情况下建议为每个用户分配至少10GB的空间。
- **/var目录**/var目录用于存放系统运行时产生的可变数据如日志文件、邮件、缓存文件等。根据系统的运行情况和日志文件的大小来进行容量分配一般建议分配10-20GB的空间。
- **/tmp目录**/tmp目录用于存放临时文件和临时数据通常不需要分配太大的空间。建议分配至少1-2GB的空间给/tmp目录。
- **/boot目录**/boot目录存放着启动Linux系统所需的引导文件通常只需要分配几百MB的空间即可。
- **Swap分区**Swap分区是一种虚拟内存用于暂时存放不常用的内存数据。当系统内存不足时Linux会将一部分内存数据移动到Swap分区中以避免内存耗尽导致系统崩溃。Swap分区的大小通常与系统内存大小有关一般建议为系统内存的1.5-2倍。例如如果系统内存为4GB则建议设置Swap分区大小为6-8GB。
> 这里特别讲讲Swap分区
Swap分区可以通过以下几种方式实现
- 交换分区Swap Partition创建一个独立的交换分区通常是一个专门的分区用于存放Swap数据。
- 交换文件Swap File创建一个专门的文件用于存放Swap数据而不是创建独立的分区。这种方式更加灵活可以根据需要动态调整Swap的大小。
- Swap大小Swap的大小应该根据系统的内存大小和使用情况来确定一般建议为系统内存的1.5-2倍。
- Swap分区/文件的位置Swap分区/文件应该位于较快的存储介质上,以确保交换操作的效率。
Swap的优先级如果同时存在多个Swap分区/文件可以通过设置优先级来指定系统使用的Swap空间。
## 四.将 `home` 目录下的文件夹改为英文
可以使用 `xdg-user-dirs-update` 工具来更新用户目录为英文版本。你可以按照以下步骤进行:
1. **编辑用户目录配置文件**
打开或创建 `~/.config/user-dirs.dirs` 文件,用文本编辑器编辑它:
```bash
nano ~/.config/user-dirs.dirs
```
2. **将目录名称更改为英文**
在该文件中,你可以看到类似以下的条目:
```bash
XDG_DESKTOP_DIR="$HOME/桌面"
XDG_DOWNLOAD_DIR="$HOME/下载"
XDG_DOCUMENTS_DIR="$HOME/文档"
XDG_MUSIC_DIR="$HOME/音乐"
XDG_PICTURES_DIR="$HOME/图片"
XDG_VIDEOS_DIR="$HOME/视频"
```
将这些路径改为英文,例如:
```bash
XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_DOCUMENTS_DIR="$HOME/Documents"
XDG_MUSIC_DIR="$HOME/Music"
XDG_PICTURES_DIR="$HOME/Pictures"
XDG_VIDEOS_DIR="$HOME/Videos"
```
3. **重命名现有的文件夹**
手动将 `home` 目录下的文件夹重命名为英文版本:
```bash
mv ~/桌面 ~/Desktop
mv ~/下载 ~/Downloads
mv ~/文档 ~/Documents
mv ~/音乐 ~/Music
mv ~/图片 ~/Pictures
mv ~/视频 ~/Videos
```
4. **应用更改**
完成以上操作后,运行以下命令应用新配置:
```bash
xdg-user-dirs-update
```
这样,`home` 目录下的文件夹就会改为英文,并且系统也会正确识别这些新的目录路径。

View File

@@ -0,0 +1,176 @@
+++
title = "Linux之旅(3):内核/shell/包管理/文件系统/桌面环境"
date = 2023-07-22
[taxonomies]
tags = ["Linux"]
+++
前言 在Linux世界中内核/shell/包管理/文件系统构成了Linux系统的核心它们相互配合共同构建了一个强大而稳定的操作环境。本文将深入探讨这些关键组成部分解释它们的作用和原理帮助读者更好地理解Linux系统的运作机制。
<!-- more -->
## **一.Linux内核**
有许多不同的版本每个版本都包含了一系列的功能改进、bug修复和性能优化。在Linux发行版中通常会使用某个特定版本的Linux内核或者在需要时进行升级。以下是一些常见的Linux内核及其主要特点
**Zen内核**
- Zen内核是Linux内核的一个变体旨在提供更好的性能和响应性。它通常包含了一些特定的调度程序和调优参数以提高系统的负载均衡和响应速度。Zen内核也可能包含一些来自其他内核变体的功能和补丁以进一步优化性能。
**LTS内核**
- LTSLong-Term Support内核是一种长期支持的内核版本它会获得更长时间的更新和维护。LTS内核通常会选择一些相对稳定和经过充分测试的功能并对其进行长期支持以确保系统的稳定性和安全性。
**Real-Time内核**
- Real-Time内核是一种专门针对实时应用场景进行优化的内核变体。它通常包含了一些实时调度算法和机制以确保系统能够及时响应各种事件并满足实时性要求。Real-Time内核适用于一些对实时性要求较高的应用如工业控制、机器人控制等领域。
**Hardened内核**
- Hardened内核是一种针对安全性进行优化的内核变体。它通常包含了一些安全增强功能和补丁以提高系统的安全性和抵御攻击的能力。Hardened内核适用于一些对安全性要求较高的应用如服务器、云计算等场景。
**XanMod内核**
- XanMod内核是一个基于Linux内核的自定义内核旨在提供更好的响应性和性能。它包含了一些针对桌面和工作站系统优化的功能和补丁如MuQSS调度器、BFQ I/O调度器等以提高系统的响应速度和性能稳定性。XanMod内核还支持一些实时性应用如音视频处理等适用于对系统响应速度要求较高的用户。
**CachyOS内核**
- CachyOS内核是一个专门针对缓存优化的Linux内核变体。它包含了一些针对缓存系统优化的功能和调整以提高系统的缓存性能和数据访问速度。CachyOS内核通常适用于需要高性能缓存的应用场景如数据库服务器、Web服务器等。
这些内核变体针对不同的需求和使用场景进行了优化可以根据具体的应用需求来选择合适的内核版本。例如如果您需要更好的性能和响应性可以选择Zen内核如果您需要长期支持和稳定性可以选择LTS内核如果您需要实时性能可以选择Real-Time内核如果您需要更高的安全性可以选择Hardened内核。
## **二.Linux Shell**
在Linux系统中有许多不同的Shell命令行解释器每种Shell都有自己的特点和用途。以下是一些常见的Linux Shell及其主要特点
**BashBourne Again Shell**
- Bash是Linux系统中最常用的Shell之一也是默认的命令行解释器。它是Bourne Shell的增强版提供了丰富的功能和扩展性包括命令历史、命令补全、作业控制等。Bash具有良好的兼容性和易用性适用于日常的系统管理和脚本编程。
**ZshZ Shell**
- Zsh是一种功能强大的Shell提供了丰富的功能和扩展性如更强大的命令补全、自动纠正拼写错误、主题和插件系统等。Zsh具有良好的可定制性和用户体验适用于高级用户和程序员。
**FishFriendly Interactive Shell**
- Fish是一种用户友好的交互式Shell提供了直观的命令提示和自动补全功能以及丰富的语法高亮和命令提示信息。Fish具有良好的用户体验和易用性适用于初学者和普通用户。
**DashDebian Almquist Shell**
- Dash是一种轻量级的Shell专门设计用于系统启动过程和脚本执行。Dash具有较高的执行速度和较低的内存占用适用于系统启动脚本和简单的脚本编程。
Bash是最常用的Shell之一具有良好的兼容性和功能性Zsh提供了更多的高级特性和定制选项适用于高级用户和程序员Fish具有友好的交互式体验和直观的用户界面适用于初学者和普通用户Dash则是一个轻量级的Shell专门用于系统启动过程和简单的脚本编程。用户可以根据自己的需求和偏好选择合适的Shell。
## **三.Linux包管理器**
在Linux系统中有几种常见的包管理器它们各自管理着不同的发行版具有不同的特点和用途。以下是一些常见的Linux包管理器及其主要特点
**APTAdvanced Package Tool**
- APT是Debian系如Debian、Ubuntu中最常用的包管理器之一。它使用基于命令行的工具`apt-get``apt-cache`等来安装、升级和删除软件包。APT还支持依赖关系的自动解决使得软件包的安装和管理变得更加方便。
**YUMYellowdog Updater, Modified**
- YUM是Red Hat系如CentOS、Fedora中常用的包管理器之一。它使用基于命令行的工具`yum`来管理软件包。YUM具有良好的依赖关系解决能力和事务处理功能使得系统升级和软件包管理变得更加简单和可靠。
**DNFDandified YUM**
- DNF是YUM的下一代版本逐渐取代了YUM在Fedora和RHEL系列中的地位。DNF具有更快的包查询和事务处理能力以及更友好的用户界面。它是未来主流的包管理器之一。
**PacmanPackage Manager**
- Pacman是Arch Linux中常用的包管理器也被一些其他发行版如Manjaro采用。Pacman使用简洁的命令`pacman -S`安装软件包、`pacman -Syu`更新系统等来管理软件包。Pacman具有简单、直观的界面和快速的操作速度适用于对系统有一定了解的用户。
**zypper**
- zypper是openSUSE中常用的包管理器它使用基于命令行的工具`zypper install``zypper update`等来管理软件包。zypper具有良好的依赖关系解决能力和事务处理功能使得系统升级和软件包管理变得更加简单和可靠。
**dpkg**
- dpkg是Debian系如Debian、Ubuntu中的低级别软件包管理工具用于直接管理软件包的安装、升级和删除。它提供了一系列的命令`dpkg -i`安装软件包、`dpkg -r`删除软件包等。
**RPMRPM Package Manager**
- RPM是Red Hat系如CentOS、Fedora中的低级别软件包管理工具用于直接管理软件包的安装、升级和删除。它提供了一系列的命令`rpm -i`安装软件包、`rpm -e`删除软件包等。
**Portage**
- Portage是Gentoo Linux中的包管理器它使用源代码进行软件包的安装和管理。Portage具有高度定制化和灵活性允许用户根据需要自定义软件包的编译参数和依赖关系。
**Snap**
- Snap是一种跨发行版的软件包格式和包管理器允许用户在不同的Linux发行版上安装和管理软件包。Snap具有自包含性和隔离性使得软件包的安装和升级变得更加简单和安全。
**Flatpak**
- Flatpak是另一种跨发行版的软件包格式和包管理器类似于Snap允许用户在不同的Linux发行版上安装和管理软件包。Flatpak提供了一种统一的应用分发和运行环境使得软件包的安装和升级更加简单和可靠。
## **四.Linux文件系统**
Linux系统支持多种文件系统每种文件系统都有自己的特点和优势适用于不同的应用场景和需求。以下是一些常见的Linux文件系统及其主要特点
**ext4**
- ext4是Linux系统中最常用的文件系统之一它是ext文件系统的后续版本提供了更好的性能和扩展性。ext4支持更大的文件和分区大小更快的文件系统检查和恢复速度以及更高的性能和稳定性。
**Btrfs**
- Btrfs是一种先进的文件系统具有许多先进的功能和特性如快照、数据校验、数据压缩等。Btrfs支持在线扩展和收缩分区大小以及动态添加和删除磁盘适用于需要高级特性和灵活性的应用场景。此外Btrfs对快照功能支持较好。
> 快照功能是一种文件系统的特性,它允许用户在特定时间点对文件系统的状态进行快照或备份,并且可以在需要时一键恢复到该时间点的状态。
快照允许用户轻松地创建文件系统的历史版本,并在需要时回滚到特定的版本;快照允许用户在文件系统中进行实验和测试,并在测试失败或不需要时轻松地回滚到初始状态,以避免对系统造成影响。在升级或安装过程中出现问题时快速恢复到原始状态
**XFS**
- XFS是一种高性能的日志文件系统适用于大型文件和高吞吐量的应用场景。XFS支持大容量的文件和分区具有较低的碎片化和较高的并发性能适用于大规模存储和数据分析等应用。
**ZFS**
- ZFS是一种先进的文件系统具有强大的数据管理和保护功能如快照、数据校验、数据压缩等。ZFS支持软件RAID和存储池pool以及动态添加和删除磁盘适用于数据中心和大规模存储等应用场景。
**F2FS**
- F2FS是一种针对闪存存储设备进行优化的文件系统具有高性能和高可靠性。F2FS支持闪存特性如块擦除计数block erase count和块生命周期管理block lifetime management适用于固态硬盘SSD和闪存卡等闪存设备。
## **五.Linux桌面环境**
Linux系统有多种不同的桌面环境每种环境都有其独特的特点、风格和用户体验。以下是一些常见的Linux桌面环境及其主要特点
**GNOME**
- GNOME是一个功能强大、现代化的桌面环境具有直观的用户界面和丰富的功能。它采用了扁平化的设计风格和简洁的用户界面提供了丰富的应用程序和插件适用于普通用户和开发人员。
**KDE Plasma**
- KDE Plasma是一个灵活、可定制的桌面环境提供了丰富的特性和选项如桌面特效、窗口管理器、小部件等。它采用了现代化的设计风格和强大的桌面管理功能适用于高级用户和技术爱好者。
**XFCE**
- XFCE是一个轻量级、快速的桌面环境具有简洁的用户界面和低资源消耗。它采用了传统的桌面布局和简约的设计风格提供了基本的桌面管理功能和应用程序适用于老旧计算机和资源有限的环境。
**LXQt**
- LXQt是一个轻量级、快速的桌面环境是LXDE和Razor-qt的合并项目。它采用了现代化的设计风格和简洁的用户界面提供了丰富的特性和可定制选项适用于资源有限的环境和嵌入式系统。
**Cinnamon**
- Cinnamon是一个基于GNOME的桌面环境具有类似于传统Windows桌面的用户界面和功能。它采用了传统的桌面布局和直观的用户体验提供了丰富的特性和可定制选项适用于对传统桌面风格有需求的用户。
GNOME和KDE Plasma提供了丰富的特性和高度定制化选项适用于高级用户和开发人员XFCE和LXQt则提供了轻量级和快速的用户体验适用于资源有限的环境Cinnamon则提供了类似于传统Windows桌面的用户界面和功能适用于对传统桌面风格有需求的用户。可以根据自己的需求和偏好选择合适的桌面环境。
> 当然,也可以使用轻量级的窗口管理器。
窗口管理器是Linux系统中控制窗口布局、管理窗口行为的关键组件。它们决定了窗口的外观和行为方式以及如何管理和排列窗口。以下是一些常见的窗口管理器及其主要特点
**X Window Manager (XWM)**
- X Window Manager是最基本的窗口管理器用于管理X Window系统中的窗口。它提供了最基本的窗口布局和管理功能如窗口移动、调整大小、最小化等。XWM本身并不提供任何外观效果但可以与其他工具配合使用来实现更丰富的窗口管理和外观特性。
**Openbox**
- Openbox是一个轻量级的窗口管理器具有简洁的用户界面和低资源消耗。它提供了丰富的自定义选项和扩展功能如虚拟桌面、窗口装饰、键盘快捷键等。Openbox适用于资源有限的环境和对简洁风格有需求的用户。
**i3**
- i3是一个动态平铺窗口管理器采用了平铺式布局将窗口按照一定规则自动排列在屏幕上。它提供了快速的窗口切换和管理功能支持键盘操作和自动布局调整适用于需要高效多任务处理的用户。
**Awesome**
- Awesome是一个高度可定制的动态平铺窗口管理器具有丰富的特性和扩展功能。它采用Lua脚本语言进行配置和定制支持强大的自定义选项和扩展功能适用于高级用户和技术爱好者。
**KWin**
- KWin是KDE桌面环境中的默认窗口管理器具有丰富的特性和功能。它提供了多种窗口布局和管理选项支持虚拟桌面、窗口效果、窗口组织等功能适用于需要丰富特性和高度定制化的用户。
这些窗口管理器之间的主要异同在于窗口布局、外观效果、自定义选项和功能特性等方面。Openbox和i3提供了简洁的用户界面和低资源消耗适用于资源有限的环境Awesome和KWin则提供了丰富的特性和扩展功能适用于高级用户和技术爱好者。用户可以根据自己的需求和偏好选择合适的窗口管理器。
> Wayland和X11
Wayland和X11都是用于Linux系统的图形显示协议它们负责管理图形用户界面GUI的显示和交互。下面是它们的简要介绍以及异同点
- **X11X Window System**
X11是一个由MIT开发的图形显示协议长期以来一直是Linux系统中最常用的图形显示系统。它采用客户端-服务器模型图形应用程序客户端通过X服务器与显示设备服务器进行通信。X11提供了丰富的图形特性和功能如窗口管理、窗口装饰、多任务处理等。
- **Wayland**
Wayland是一个由Red Hat主导开发的新一代图形显示协议旨在取代X11成为Linux系统的标准图形显示系统。Wayland采用了现代化的设计理念和架构取消了X11中复杂的客户端-服务器模型将图形显示功能直接集成到操作系统中。Wayland具有更低的延迟和更高的性能支持更好的硬件加速和多触摸设备以及更简洁的代码结构。
**异同点**
- **架构差异**X11采用了客户端-服务器模型图形应用程序通过X服务器与显示设备进行通信而Wayland取消了这种模型将图形显示功能直接集成到操作系统中减少了中间层的复杂性。
- **性能差异**Wayland具有更低的延迟和更高的性能支持更好的硬件加速和多触摸设备使得图形显示更加流畅和响应。
- **功能差异**X11提供了丰富的图形特性和功能如窗口管理、窗口装饰、多任务处理等Wayland在功能上相对较少但提供了更简洁的代码结构和更好的性能。
- **兼容性差异**X11在Linux系统中被广泛使用拥有大量的应用程序和工具的支持而Wayland在兼容性方面仍在发展中尚未完全取代X11成为Linux系统的标准图形显示系统。
总的来说Wayland是未来Linux系统中的趋势具有更好的性能和更简洁的架构但在兼容性和功能丰富度上仍有待改进。X11则是当前仍然广泛使用的图形显示系统拥有丰富的生态和大量的应用程序支持。
## **六.后记**
个人使用推荐Zen+Zsh+Pacman+Btrfs+Hyprland,并使用 paru xxx 来搜索软件包使用paru -S xxx 安装软件。

View File

@@ -0,0 +1,82 @@
+++
title = "Linux之旅(4):TerminalConsole and Shell"
date = 2023-07-23
[taxonomies]
tags = ["Linux"]
+++
前言 在linux的学习过程中我们常常遇到诸如 TerminalConsolebash,zsh,shell,tty 等概念,这些概念常常被混淆,似乎都和命令行相关。本文从历史角度出发介绍它们的前世今生。
<!-- more -->
## 终端和控制台
终端,英文叫做 terminal ,通常简称为 term控制台英文叫做 console。
要明白这两者的关系,还得从最初的计算机说起。当时的计算机价格昂贵,一台计算机一般是由多个人同时使用的。在这种情况下一台计算机需要连接上许多套键盘和显示器来供多个人使用。在以前专门有这种可以连上一台电脑的设备,只有显示器和键盘,还有简单的处理电路,本身不具有处理计算机信息的能力,他是负责连接到一台正常的计算机上(通常是通过串口) ,然后登陆计算机,并对该计算机进行操作。当然,那时候的计算机操作系统都是多任务多用户的操作系统。这样一台只有显示器和键盘能够通过串口连接到计算机的设备就叫做终端。
而控制台又是什么回事呢?其概念来自于管风琴的控制台。顾名思义,控制台就是一个直接控制设备的台面(一个面板,上面有很多控制按钮)。 在计算机里,把那套直接连接在电脑上的键盘和显示器就叫做控制台。
终端是通过串口连接上的,不是计算机本身就有的设备,而控制台是计算机本身就有的设备,一个计算机只有一个控制台。计算机启动的时候,所有的信息都会显示到控制台上,而不会显示到终端上。也就是说,控制台是计算机的基本设备,而终端是附加设备。 当然,由于控制台也有终端一样的功能,控制台有时候也被模糊的统称为终端。
以上是控制台和终端的历史遗留区别。现在由于计算机硬件越来越便宜,终端和控制台的概念也慢慢演化了。终端和控制台由硬件的概念,演化成了软件的概念。
  
## 内核与外壳
内核( Kernel )和外壳( Shell )是 linux 的两个主要部分。Kernel 是操作系统的核心,系统的文件管理、进程管理、内存管理、设备管理这些功能,都是由 Kernel 提供的。
用户和操作系统内核交流需要一个工具,那么这个工具就是 Shell。
什么是 Shell在 Linux 中,最常见的 Shell 形式有命令行界面命令行界面和图形界面两种。并不是打开的那个终端窗口就是 Shell如Alacritty、Gnome-Terminal、xterm 、kitty等程序它们不是 Shell而它们里面运行的 Bash、Zsh、fish 等命令行解释器程序,才是 Shell。
那 Alacritty、Gnome-Terminal、xtermxterm 是什么?
它们是终端模拟器。
前面提到过,在远古时代,终端和控制台都是有实体的。控制台直接和计算机在一起,你可以通过控制台控制计算机。终端通过数据线和计算机连接,终端也提供一个键盘和一个屏幕,你可以通过键盘向计算机下达指令,然后通过屏幕观察输出。
但是现在的计算机组成和以前不一样了,一般一台电脑都是自带键盘和屏幕,很少再外接终端设备。
所以 Linux 提供了另外一个更高级的功能,那就是虚拟终端。那就是在一台电脑上,通过软件的模拟,好像有好几个终端连接在这台计算机上一样。
现在说的终端,比如 linux 中的虚拟终端,都是软件的概念。虚拟终端称之为 ttytty 是电传打字机电传打字机 Teletypewriter 的缩写在带显示屏的视频终端出现之前tty是最流行的终端设备。每一个 tty 都有一个编号,在/dev目录下有相应的设备文件。其中/dev/tty1到/dev/tty7可以通过 Ctrl+Alt+F1 到 Ctrl+Alt+F7 进行切换,也可以通过 chvt 命令进行切换,就好比是以前多人公用的计算机中的六个终端设备,这就是为什么这个叫“虚拟终端”的原因。
## 时代变迁
随着时间的推移,我们看到了从硬件到软件的转变,以及从多用户共享到个人使用的转变。这种变迁不仅影响了终端和控制台的概念,也塑造了我们对计算机的理解和期待。

View File

@@ -0,0 +1,130 @@
+++
title = "Linux之旅(5):BIOS-UEFI-MBR-GPT-GRUB"
date = 2023-07-24
[taxonomies]
tags = ["Linux"]
+++
前言 在计算机领域系统引导和磁盘分区是至关重要的。本文将介绍BIOS与UEFIMBR与GPT以及它们之间的异同点。此外我们还会讨论与这些概念密切相关的引导加载程序——GRUB。
<!-- more -->
## BIOS
> `BIOSBasic Input Output System`,直译成中文名称就是"`基本输入输出系统`"。它是一组固化到主板中一个ROM芯片上的程序它可以从CMOS中读写系统设置的具体信息。此程序保存着计算机最重要的基本输入输出程序、开机后的自检程序和系统自启动程序。简单来说BIOS只认识设备不认识分区、不认识文件。
## UEFI
> UEFI统一可扩展固件接口是一个公开的规范定义了操作系统和平台固件之间的软件接口。UEFI 是传统 PC BIOS 的继承者是取代传统BIOS的相比传统BIOS来说它更易实现容错和纠错特性也更强。 它将引导数据存储在 .efi 文件中,而不是固件中。你经常会在新款的主板中找到 UEFI 启动模式。UEFI 启动模式包含一个特殊的 EFI 分区,用于存储 .efi 文件并用于引导过程和引导加载程序。
> UEFI使用GPT的分区引导方案支持更大的硬盘。由于省去了BIOS自检的过程所以启动速度更快。传统BIOS主要支持MBR引导UEFI则是取代传统BIOS它加入了对新硬件的支持其中就有支持2TB以上硬盘。
## MBR
> 全新硬盘在使用之前必须进行分区格式化,硬盘分区初始化的格式主要有两种,分别为`MBR`格式和`GPT`格式。MBR是传统的分区表类型当一台电脑启动时它会先启动主板上的BIOS系统BIOS再从硬盘上读取MBR主引导记录硬盘上的MBR运行后就会启动操作系统但最大的缺点则是不支持容量大于2T的硬盘。
## GPT
> 而GPT是另一种更先进的磁盘系统分区方式它的出现弥补了MBR这个缺点最大支持`18EB`的硬盘,是基于`UEFI`使用的磁盘分区架构。目前所有Windows系统均支持`MBR`,而`GPT`只有`64`位系统才能支持。`BIOS只支持MBR引导系统而GPT仅可用UEFI引导系统`。正因为这样现在主板大多采用BIOS集成UEFI或UEFI集成BIOS以此达到同时兼容MBR和GPT引导系统的目的。
## GRUB
> GRUBGRand unified bootloader,多操作系统启动程序。它允许用户可以在计算机内同时拥有多个操作系统,并在计算机启动时选择希望运行的操作系统。
>
> GRUB可用于选择操作系统分区上的不同内核也可用于向这些内核传递启动参数。`它是一个多重操作系统启动管理器,用来引导不同系统`如Windows、Linux。Linux常见的引导程序包括LILO、GRUB、GRUB2。
## Legacy
> 如果你遇到过刚制作的U盘启动盘无法启动或者新买的固态硬盘做好系统后无法启动那么大概率的问题就出现在BIOS的引导模式的选择上是UEFI还是Legacy。legacy启动模式是指BIOS 固件用来初始化硬件设备的引导过程Legacy启动模式包含一系列已安装的设备这些设备在引导过程中计算机执行 POST (开机自检)测试时会被初始化。传统引导将检查所有连接设备的主引导记录 (MBR),通常位于磁盘的第一个扇区。
当它在设备中找不到引导加载程序时Legacy会切换到列表中的下一个设备并不断重复此过程直到找到引导加载程序否则返回错误。
## 表格
### BIOS/UEFI
| BIOS | UEFI |
| ---------------------------------- | --------------------------------------------------------------- |
| 用于初始化计算机硬件并引导操作系统 | 在计算机启动时运行 |
| 具有较少功能和灵活性 | 具有更多功能和灵活性 |
| | 支持更大的硬盘容量、更快的启动速度、更好的安全性和更多的扩展性v |
| | 通常具有图形用户界面GUI |
### MBR/GPT
| MBR | GPT |
| ----------------------------------------- | ---------------------------------------------------------------------------------- |
| 用于分区磁盘并存储分区布局信息 | 用于分区磁盘并存储分区布局信息 |
| 支持最多4个主分区或3个主分区加1个扩展分区 | 支持最多4个主分区或3个主分区加1个扩展分区支持最多4个主分区或3个主分区加1个扩展分区 |
| | 具有更好的数据完整性和可靠性,使用校验和检测数据损坏 |
| | UEFI需要GPT格式的磁盘才能引导 |
### UEFI/Legacy
| UEFI 引导模式 | Legacy引导模式 |
| ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------- |
| UEFI 提供了更好的用户界面 | Legacy引导模式是传统的且非常基本的 |
| 使用 GPT 分区方案 | 使用 MBR 分区方案 |
| UEFI 提供更快的启动时间 | 相比UEFI它的速度较慢 |
| 由于 UEFI 使用 GPT 分区方案,因此它可以支持多达 9 zB 的存储设备 | Legacy使用的 MBR 分区方案仅支持最多 2 TB 存储设备 |
| UEFI 以 32 位和 64 位运行,支持鼠标和触摸板 | Legacy在仅支持键盘仅 16 位模式下运行 |
| 它允许安全启动防止加载未经授权的应用程序它还可能阻碍双启动因为它将操作系统OS视为应用程序 | 它不提供允许加载未经授权的应用程序的安全启动方法,未限制双启动 |
| 它具有更简单的更新过程 | 与UEFI相比它更复杂 |
## 组合
- **BIOS+MBR**
这是最传统的,系统都会支持;唯一的缺点就是`不支持容量大于2T的硬盘`
- **BIOS+GPT**
BIOS是可以使用GPT分区表的硬盘来作为数据盘的但不能引导系统若电脑同时带有容量小于2T的硬盘和容量大于2T的硬盘`小于2T的可以用MBR分区表安装系统而大于2T的可以使用GPT分区表来存放资料`。但系统须使用64位系统。
- **UEFI+MBR**
可以把UEFI设置成`Legacy模式`传统模式让其支持传统MBR启动效果同`BIOS+MBR`也可以建立FAT分区放置UEFI启动文件来可应用在U盘和移动硬盘上实现双模式启动。
- **UEFI+GPT**
如果要把大于2T的硬盘作为系统盘来安装系统的话就必须`UEFI+GPT`。而且系统须使用64位系统否则无法引导。但系统又不是传统在PE下安装后就能直接使用的引导还得经过处理才行。
## 系统的启动过程
从按下计算机的开机按钮到用户开始使用计算机,涉及了多个步骤和组件,让我们一起详细了解整个过程:
**1. 电源启动**
- 用户按下计算机的开机按钮电源开始供电计算机硬件开始初始化。电源将电流传递到主板上的BIOS/UEFI芯片。
**2. BIOS/UEFI启动**
- BIOS/UEFI芯片接收到电源信号后开始执行初始化过程。它首先进行自检POST检测主板、CPU、内存等硬件设备的工作状态并在显示屏上输出相关信息。
- BIOS/UEFI根据配置的启动顺序通常为硬盘、光盘、USB等搜索启动设备并加载位于启动设备上的引导加载程序。
**3. 引导加载程序加载**
- 引导加载程序如GRUB被加载到内存中它负责后续的操作系统加载过程。GRUB通常会显示启动菜单列出可用的操作系统选项。
- 用户可以在GRUB菜单中选择要启动的操作系统或者等待默认选项启动。
**4. 操作系统加载**
- 一旦选择了启动选项引导加载程序会加载操作系统的内核和初始化RAM磁盘initramfs/initrd
- 内核加载完成后,操作系统开始启动初始化过程,包括加载系统服务、挂载文件系统、启动用户界面等。
**5. 用户登录**
- 操作系统初始化完成后,显示登录界面(如果配置了图形用户界面),用户输入用户名和密码登录系统。
- 如果登录成功,操作系统加载用户的桌面环境或命令行界面,用户开始使用计算机。
## 各种引导加载程序
| 特性 | GRUBGRand Unified Bootloader | LILOLinux Loader | systemd-boot前身为 gummiboot | rEFIndUEFI 引导管理器) |
|--------------------|----------------------------------|-----------------------------------|----------------------------------|------------------------------------|
| **支持的系统类型** | BIOS 和 UEFI | 仅支持 BIOS 模式 | 仅支持 UEFI | 仅支持 UEFI |
| **多系统引导支持** | ✅ 强大支持 | ❌ 不支持多系统引导 | ✅ 支持(需手动配置) | ✅ 自动检测操作系统 |
| **图形界面支持** | ✅ 支持(可自定义主题) | ❌ 不支持 | ❌ 不支持 | ✅ 支持(可自定义主题) |
| **配置方式** | 配置文件(复杂) | 配置文件(简单) | 配置文件(简单) | 配置文件(简单) |
| **命令行支持** | ✅ 支持(交互式命令行) | ❌ 不支持 | ❌ 不支持 | ❌ 不支持 |
| **文件系统支持** | ✅ 支持多种文件系统 | ✅ 支持 ext2/ext3/ext4 等 | ✅ 支持 ext4、FAT 等 | ✅ 支持 ext4、FAT 等 |
| **安全启动支持** | ✅ 支持(需配置) | ❌ 不支持 | ✅ 支持(需配置) | ✅ 支持(需配置) |
| **安装复杂度** | 中等(需配置) | 较低 | 较低 | 中等(需配置) |
| **适用场景** | 多系统引导、复杂配置 | 简单系统引导 | 简单系统引导 | 多系统引导、美观界面 |
## 后记
- [聊聊BIOS、UEFI、MBR、GPT、GRUB……](https://segmentfault.com/a/1190000020850901)

View File

@@ -0,0 +1,231 @@
+++
title = "Linux之旅(6):常用命令与性能分析"
date = 2023-07-25
[taxonomies]
tags = ["Linux"]
+++
前言 在学习Linux操作系统时熟悉常用命令和性能分析工具是至关重要的。让我们一起探索Linux的世界提升技能解锁无限可能
<!-- more -->
> 翻译自https://medium.com/netflix-techblog/linux-performance-analysis-in-60-000-milliseconds-accc10403c55。
## **问题背景**
当登录到一台有性能问题的Linux服务器第一分钟要检查什么
在Netflix我们拥有庞大的EC2 Linux虚拟机云我们有众多性能分析工具来监视和诊断这些Linux服务器的性能。这些工具包括Atlas负责整个虚拟机云的监控和Vector负责按需对虚拟机实例进行性能分析。这些工具可以帮助我们解决大多数问题但有时我们需要登录到虚拟机实例并运行一些标准的Linux性能工具。
## **前60秒摘要**
在本文中Netflix性能工程团队将使用您应该使用的标准Linux工具在命令行中向您展示一个性能诊断过程的前60秒。在60秒内您可以通过运行以下十个命令来了解有关系统资源使用和运行进程的信息。最应该关注的是一些很容易理解的错误、饱和度指标和资源利用率等指标。饱和度是衡量资源负载超出其处理能力的指标它可以通过观察请求队列的长度或等待时间反映出来。
```
uptime
dmesg | tail
vmstat 1
mpstat -P ALL 1
pidstat 1
iostat -xz 1
free -m
sar -n DEV 1
sar -n TCP,ETCP 1
top
```
其中的一些命令需要安装sysstat软件包。这些命令暴露出的指标将帮助您完成一些USE方法一种查找性能瓶颈的方法。它们涉及检查所有资源CPU、内存、磁盘等的利用率饱和度和错误指标。在诊断过程中还应该注意检查和排除某些资源的问题。因为通过排除某些资源的问题可以缩小诊断的范围并指民后续的诊断。
## **uptime**
```
$ uptime
23:51:26 up 21:31, 1 user, load average: 30.02, 26.43, 19.02
```
这是快速查看平均负载的方法该平均负载指标了要运行的任务进程的数量。在Linux系统上这些数字包括要在CPU上运行的进程以及在不中断IO通常是磁盘IO中阻塞的进程。这里给出了资源负载高层次的概览但是没有其它工具就很难正确理解值得快速看一眼。
这三个数字是指数衰减移动平均值分别代表了1分钟、5分钟、15分钟的平均值。这三个数字使我们对负载如何随时间变化有了一定的了解。例如如果您去诊断一个有问题的服务器发现1分钟的值比15分钟的值低很多那么您可能已经登录得太晚了错过了问题。
在上面的例子中平均负载有所增加因为1分钟的值30相对15分钟的值19来说大了一些。数字变大意味着很多种可能有可能是CPU的需求变多了使用3和4中提到的vmstat或mpstat命令将可以进一步确认问题。
## **dmesg|tail**
```
$ dmesg | tail
[1880957.563150] perl invoked oom-killer: gfp_mask=0x280da, order=0, oom_score_adj=0
[...]
[1880957.563400] Out of memory: Kill process 18694 (perl) score 246 or sacrifice child
[1880957.563408] Killed process 18694 (perl) total-vm:1972392kB, anon-rss:1953348kB, file-rss:0kB
[2320864.954447] TCP: Possible SYN flooding on port 7001. Dropping request. Check SNMP counters.
```
该命令展示最近 10条系统消息。在这些系统消息中查找有可能引起性能问题的报错。上面的例子包括oom-killer和TCP丢弃了一个请求。
不能忘记这个步骤dmesg通常对诊断问题很有价值。
```
## **vmstat 1**
$ vmstat 1
procs ---------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
34 0 0 200889792 73708 591828 0 0 0 5 6 10 96 1 3 0 0
32 0 0 200889920 73708 591860 0 0 0 592 13284 4282 98 1 1 0 0
32 0 0 200890112 73708 591860 0 0 0 0 9501 2154 99 1 0 0 0
32 0 0 200889568 73712 591856 0 0 0 48 11900 2459 99 0 0 0 0
32 0 0 200890208 73712 591860 0 0 0 0 15898 4840 98 1 1 0 0
```
vmstat是虚拟内存统计(Virtual Memory Stat)的缩写vmstat(8)是一个通常可用的工具(最初是在之前的BSD时代创建的),它每行打印一行服务器关键统计的概览。
vmstat使用参数1运行意味着每1秒打印打印一次概览。命令输出的第一行展示的是从启动开始的平均值而不是最近一秒的平均值。因此跳过第一行除非您想学习并记住哪一列是哪一列。
要检查的列:
r在CPU上运行并等待回合的进程数。由于它不包含IO因此它比指示CPU饱和的平均负载提供了更多的信息。一个大于CPU核数的r值就是饱和的。
free空闲的内存单位的KB。如果计数很大说明服务器有足够的内存free -m命令将对空闲内存的状态有更好的说明。
si、so交换置入和交换置出。如果这两个值是非空说明物理内存用完了现在在使用交换内存了。
us、sy、id、wa、st这些是CPU时间的分类其是所有CPU的平均值。它们是用户时间、系统时间(内核)、空闲时间、等待IO和被偷窃时间被其它宾客系统进行使用或宾客系统隔离的驱动程序域Xen
通过将用户时间和系统时间这两个分类相加即可判断CPU是否繁忙。一定的等待IO时间说明磁盘有可能是性能瓶颈。你可以认为等待IO时间是另一种形式的空闲时间它提供了它是如何空闲的线索。
IO处理需要占用CPU系统时间。一个较高的CPU系统时间超过20%可能会很有趣有必要进一步研究也许内核在很低效地处理IO。
在上面的示例中CPU时间基本全在用户时间这说明应用程序本身在大量占用CPU时间。CPU的平均利用率也远远超过90%。这不一定是问题可以使用r列来检查饱和度。
## **mpstat -P ALL 1**
```
$ mpstat -P ALL 1
Linux 3.13.0-49-generic (titanclusters-xxxxx) 07/14/2015 _x86_64_ (32 CPU)
07:38:49 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
07:38:50 PM all 98.47 0.00 0.75 0.00 0.00 0.00 0.00 0.00 0.00 0.78
07:38:50 PM 0 96.04 0.00 2.97 0.00 0.00 0.00 0.00 0.00 0.00 0.99
07:38:50 PM 1 97.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 2.00
07:38:50 PM 2 98.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00
07:38:50 PM 3 96.97 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 3.03
[...]
```
此命令显示每个CPU的CPU时间明细可用于检查不平衡的情况。单个热CPU说明是单线程应用程序在大量占用CPU时间。
## **pidstat 1**
```
$ pidstat 1
Linux 3.13.0-49-generic (titanclusters-xxxxx) 07/14/2015 _x86_64_ (32 CPU)
07:41:02 PM UID PID %usr %system %guest %CPU CPU Command
07:41:03 PM 0 9 0.00 0.94 0.00 0.94 1 rcuos/0
07:41:03 PM 0 4214 5.66 5.66 0.00 11.32 15 mesos-slave
07:41:03 PM 0 4354 0.94 0.94 0.00 1.89 8 java
07:41:03 PM 0 6521 1596.23 1.89 0.00 1598.11 27 java
07:41:03 PM 0 6564 1571.70 7.55 0.00 1579.25 28 java
07:41:03 PM 60004 60154 0.94 4.72 0.00 5.66 9 pidstat
07:41:03 PM UID PID %usr %system %guest %CPU CPU Command
07:41:04 PM 0 4214 6.00 2.00 0.00 8.00 15 mesos-slave
07:41:04 PM 0 6521 1590.00 1.00 0.00 1591.00 27 java
07:41:04 PM 0 6564 1573.00 10.00 0.00 1583.00 28 java
07:41:04 PM 108 6718 1.00 0.00 0.00 1.00 0 snmp-pass
07:41:04 PM 60004 60154 1.00 4.00 0.00 5.00 9 pidstat
```
pidstat有点像top的每个进程摘要但是会滚动打印而不是清屏再打印。这对于观察一段时间内的模式以及将所看到的内容复制&粘贴)记录到调查记录中很有用。
上面的示例显示两个Java进程要为消耗大量CPU负责。%CPU这一列是所有CPU核的总和1591%说明Java进程差不多消耗了16个核的CPU。
## **iostat -xz 1**
```
$ iostat -xz 1
Linux 3.13.0-49-generic (titanclusters-xxxxx) 07/14/2015 _x86_64_ (32 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
73.96 0.00 3.73 0.03 0.06 22.21
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
xvda 0.00 0.23 0.21 0.18 4.52 2.08 34.37 0.00 9.98 13.80 5.42 2.44 0.09
xvdb 0.01 0.00 1.02 8.94 127.97 598.53 145.79 0.00 0.43 1.78 0.28 0.25 0.25
xvdc 0.01 0.00 1.02 8.86 127.79 595.94 146.50 0.00 0.45 1.82 0.30 0.27 0.26
dm-0 0.00 0.00 0.69 2.32 10.47 31.69 28.01 0.01 3.23 0.71 3.98 0.13 0.04
dm-1 0.00 0.00 0.00 0.94 0.01 3.78 8.00 0.33 345.84 0.04 346.81 0.01 0.00
dm-2 0.00 0.00 0.09 0.07 1.35 0.36 22.50 0.00 2.55 0.23 5.62 1.78 0.03
[...]
```
这是了解块设备(磁盘),应用的工作负载和产生的性能影响的绝佳工具。重点关注下面的指标:
- r/s、w/s、 rkB/s、 wkB/s这些是设备每秒交付的读取、写入、读取千字节和写入千字节。使用这些来表征块设备的工作负载。性能问题可能是由于向块设备施加了过多的工作负载。
- awaitIO的平均时间以毫秒为单位。这是应用程序所感受到的时间它包括IO排队时间和IO服务时间。大于预期的平均时间可能表示块设备饱和或设备出现问题了。
- avgqu-sz发给设备的平均请求数。值大于1可以表明已达到饱和状态尽管设备通常可以并行处理请求尤其是在多个后端磁盘所组成的前端虚拟设备的情况下
- %util设备利用率。这是一个表征繁忙度的百分比它表示设备每秒工作的时间。尽管它的值取决于设备但值大于60%通常会导致性能不佳也会通过await的值观察到。接近100%的值通常表示饱和。
如果存储设备是有许多后端磁盘组成的前端逻辑磁盘设备则100%的利用率可能仅意味着100%的时间正在处理某些IO但是后端磁盘可能远远没有饱和并且可能还可以处理更多的工作。
请记住性能不佳的磁盘IO不一定是应用问题通常可以使用许多技术以执行异步IO以便使应用程序不会被阻塞住而产生直接产生IO延迟例如预读和缓冲写入技术
## **free -m**
```
$ free -m
total used free shared buffers cached
Mem: 245998 24545 221453 83 59 541
-/+ buffers/cache: 23944 222053
Swap: 0 0 0
```
右边两列:
buffers缓冲区高速缓存用于块设备I / O
cached页面缓存由文件系统使用
我们只需要检查下它们的大小是否接近零。如果接近零的话这可能导致较高的磁盘IO可以使用iostat进行确认和较差的性能。上面的示例看起来不错每列都有较大的数据。
-/+ buffers/cache为已用和空闲内存提供较少让人产生混乱的值。Linux将可用内存用于高速缓存但是如果应用程序需要它们可以快速被回收。因此应以某种方式将缓存的内存包括在free列中这也就是这一行的所做的。甚至还有一个网站专门讨论了这种混乱。
如果在Linux上使用ZFS就像我们对某些服务所做的那么因为ZFS具有自己的文件系统缓存它们并不会反映在free -m的列中因此这种场景下这种混乱还将存在。所以会看到似乎系统的可用内存不足而实际上可根据需要从ZFS缓存中申请到内存。
## **sar -n DEV 1**
```
$ sar -n DEV 1
Linux 3.13.0-49-generic (titanclusters-xxxxx) 07/14/2015 _x86_64_ (32 CPU)
12:16:48 AM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
12:16:49 AM eth0 18763.00 5032.00 20686.42 478.30 0.00 0.00 0.00 0.00
12:16:49 AM lo 14.00 14.00 1.36 1.36 0.00 0.00 0.00 0.00
12:16:49 AM docker0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12:16:49 AM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
12:16:50 AM eth0 19763.00 5101.00 21999.10 482.56 0.00 0.00 0.00 0.00
12:16:50 AM lo 20.00 20.00 3.25 3.25 0.00 0.00 0.00 0.00
12:16:50 AM docker0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
```
此工具可以检查网络接口的吞吐量rxkB/s和txkB/s作为工作负载的度量还可以检查是否已达到网络接口的限制。在上面的示例中eth0接收速率达到22MB/s即176Mbit/s远低于1Gbit/s的网络接口限制假设是千兆网卡
此版本还具有%ifutil用来指示设备利用率全双工双向这也是我们使用的Brendan的nicstat工具测量出来的。就像nicstat一样这个指标很难计算正确而且在本例中好像不起作用数据是0.00)。
## **sar -n TCP,ETCP 1**
```
$ sar -n TCP,ETCP 1
Linux 3.13.0-49-generic (titanclusters-xxxxx) 07/14/2015 _x86_64_ (32 CPU)
12:17:19 AM active/s passive/s iseg/s oseg/s
12:17:20 AM 1.00 0.00 10233.00 18846.00
12:17:19 AM atmptf/s estres/s retrans/s isegerr/s orsts/s
12:17:20 AM 0.00 0.00 0.00 0.00 0.00
12:17:20 AM active/s passive/s iseg/s oseg/s
12:17:21 AM 1.00 0.00 8359.00 6039.00
12:17:20 AM atmptf/s estres/s retrans/s isegerr/s orsts/s
12:17:21 AM 0.00 0.00 0.00 0.00 0.00
```
这是一些关键的TCP指标的摘要包括
- active / s每秒本地启动的TCP连接数例如通过connect
- passive/s每秒远程启动的TCP连接数例如通过accept
- retrans / s每秒TCP重传的次数。
主动和被动计数通常作为服务器TCP负载的粗略度量新接受的连接数被动和新出站的连接数主动。将主动视为出站将被动视为入站可能对理解这两个指标有些帮助但这并不是严格意义上的例如考虑从localhost到localhost的连接
重新传输是网络或服务器问题的迹象它可能是不可靠的网络例如公共Internet也可能是由于服务器过载并丢弃了数据包。上面的示例仅显示每秒一个新的TCP连接。
## **top**
$ top
```
top - 00:15:40 up 21:56, 1 user, load average: 31.09, 29.87, 29.92
Tasks: 871 total, 1 running, 868 sleeping, 0 stopped, 2 zombie
%Cpu(s): 96.8 us, 0.4 sy, 0.0 ni, 2.7 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 25190241+total, 24921688 used, 22698073+free, 60448 buffers
KiB Swap: 0 total, 0 used, 0 free. 554208 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
20248 root 20 0 0.227t 0.012t 18748 S 3090 5.2 29812:58 java
4213 root 20 0 2722544 64640 44232 S 23.5 0.0 233:35.37 mesos-slave
66128 titancl+ 20 0 24344 2332 1172 R 1.0 0.0 0:00.07 top
5235 root 20 0 38.227g 547004 49996 S 0.7 0.2 2:02.74 java
4299 root 20 0 20.015g 2.682g 16836 S 0.3 1.1 33:14.42 java
1 root 20 0 33620 2920 1496 S 0.0 0.0 0:03.82 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:05.35 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
6 root 20 0 0 0 0 S 0.0 0.0 0:06.94 kworker/u256:0
8 root 20 0 0 0 0 S 0.0 0.0 2:38.05 rcu_sched
```
top命令包括我们之前检查的许多指标。运行它可以很方便地查看是否有任何东西与以前的命令有很大不同这表明负载是可变的。
top命令不太好的地方是随着时间的推移很难看到指标变化的模式这在提供滚动输出的vmstat和pidstat之类的工具中可能更清楚一点。如果您没有足够快地暂停输出Ctrl-S暂停Ctrl-Q继续在屏幕输出被top命令清除后间歇性问题的证据也可能被丢失了。

View File

@@ -0,0 +1,48 @@
+++
title = "Linux之旅(7):系统与终端字体设置"
date = 2023-08-01
[taxonomies]
tags = ["Linux"]
+++
前言 一个好看的字体会提高工作效率与审美.Linux 下的字体可以很漂亮,但需要一些设置.
<!-- more -->
随着 FreeType2 由于专利过期默认开启了高质量的 LCD 优化,以及一批高质量的开源字体的公布,Linux 上的中文字体渲染比过去好了太多.
> Windows 的字体渲染从技术上来说是相当先进的,问题是在中文字体的选择上实在是一坨...
## 选择字体
近几年来出现了一大批自由字体(包括工作量极大的 CJK 字体),使 Linux 下的字体选择一下子丰富了起来.如果愿意花一点时间的话,可以去[ArchWiki](https://wiki.archlinux.org/title/Fonts#Font_packages) 上看看,里面涵盖了相当多的自由字体.
### 终端字体
[Maple Mono](https://github.com/subframe7536/maple-font?tab=readme-ov-file),这是一款字形整洁、拥有手写风格的斜体、细粒度配置、内置 Nerd-Font、中英文2:1等宽 的字体.我使用的:
```
MapleMono-Bold
```
### 阅读器字体
[霞鹜文楷](https://github.com/lxgw/LxgwWenKai),一款开源中文字体,基于 FONTWORKS 出品字体 Klee One 衍生.我使用的:
```
LXGW WenKai
```
### 浏览器字体
```
拉丁字体
├── Inter -无衬线,类似于 Roboto 但更适合屏幕显示的字体
├── Noto Serif -衬线
└── Sarasa Term SC -等宽,拉丁文字符严格为半宽的字体,中英文混排时较协调
├── 如果不适应这种较瘦的字体风格, 则可以尝试使用:
│ ├── Adobe Source Pro
│ ├── Cascadia Code
│ └── Fira Code
中文字体
├── Noto Sans CJK SC (思源黑体)
└── Noto Serif CJK SC思源宋体
```
---
**Done.**

View File

@@ -120,7 +120,7 @@ DKIM (DomainKeys Identified Mail) 的缩写,允许发送者通过在邮件的
经过了 SPF 和 DKIM 的保证,是不是就可以完美的发送接收邮件了?其实并不能,我们通过邮件后台来看一下邮件的原始文本。
````bash
````
MIME-Version: 1.0
Return-Path: xxx@fake.com
DKIM-Signature: d=fake.com,b=adceabkekd12

View File

@@ -13,15 +13,15 @@ tags = ["Network"]
## VPS上的配置
### 修改VPS hostname
```bash
```
hostnamectl set-hostname mail.your-domain.com
```
### 修改hosts文件
```bash
```
vim /etc/hosts
```
添加一行
```bash
```
127.0.1.1 localhost.localdomain mail.your-domain.com
```
@@ -30,7 +30,7 @@ vim /etc/hosts
docker compose文件示例
```yaml
```
version: '3.7'
services:

View File

@@ -68,7 +68,7 @@ nexttrace --queries 3 --parallel-requests 4 example.com
nexttrace --table --no-rdns www.example.org
```
### 示例
```bash
```
nexttrace 38.207.170.5x
NextTrace v1.4.0 2025-04-16T01:10:07Z dccc41b
[NextTrace API] preferred API IP - 198.18.0.61 - 601.41ms - 🐠 (Relay) → Misaka.HKG

View File

@@ -36,7 +36,7 @@ Aria2 有以下几个特点:
首先下载[aria2-1.37.0-win-64bit-build1.zip](https://github.com/aria2/aria2/releases/tag/release-1.37.0),将下载好的文件解压并放到你喜欢的目录下,设置系统环境变量,类似``D:\DATA\Data\AriaNg-1.3.10-AllInOne``,随后即可在 CMD 中使用``aria2c -v``查看Aria2 。
然后创建一个配置文件``C:\Users\<你>\.aria2\aria2.conf``,内容如下:
```conf
```
# 下载目录
dir=C:/Users/<你>/Downloads
@@ -53,7 +53,7 @@ rpc-secret=<你的密码>
```
随后在这个项目中[winsw](https://github.com/winsw/winsw)下载 WinSW-x64.exe到一个目录并重命名为 aria2-service.exe并在同目录下创建``aria2-service.xml``,内容如下:
```xml
```
<service>
<id>aria2</id>
<name>Aria2 Service</name>
@@ -71,16 +71,16 @@ rpc-secret=<你的密码>
Arch linux 和大部分常规发行版可以适用此方法。
首先安装aria2本体:
```bash
```
paru -S aria2
```
随后创建配置文件
```bash
```
nano /home/<you-username>/.config/aria2/aria2.conf
```
内容为
```conf
```
enable-rpc=true
rpc-listen-all=true
rpc-allow-origin-all=true
@@ -92,11 +92,11 @@ save-session=/home/<you-username>/.config/aria2/aria2.session
save-session-interval=60
```
保存退出;随后创建守护进程以便开机自启动:
```bash
```
nano ~/.config/systemd/user/aria2.service
```
写入:
```conf
```
[Unit]
Description=Aria2 Daemon
After=network.target
@@ -110,18 +110,18 @@ WantedBy=default.target
```
在更新配置文件和服务文件后,执行以下命令以重启服务:
```bash
```
systemctl --user daemon-reload
systemctl --user enable aria2.service
systemctl --user start aria2.service
```
使用以下命令检查服务状态:
```bash
```
systemctl --user status aria2.service
```
### Nixos
```nix
```
{ lib, pkgs, username, ... }:
{
services.aria2.enable = false;
@@ -151,7 +151,6 @@ systemctl --user status aria2.service
};
}
```
## 命令行用法
如果你不想用浏览器插件或者面板,也可以直接使用命令行操作:

View File

@@ -182,7 +182,7 @@ Netlify在考虑到CDN成本以及可用性的情况下选择了以下这些地
> 需要注意的是有些CDN的回源IP并不用作节点IP比如Cloudflare的回源IP仅作回源IP使用如果要获取Cloudflare的节点IP可前往https://bgp.tools/as/13335#prefixes。而有些CDN的回源IP同时被用作CDN节点比如BunnyCDN和Gcore CDN。
Cloudflare
```bash
```
# https://www.cloudflare.com/ips-v4
103.21.244.0/22
103.22.200.0/22
@@ -210,45 +210,45 @@ Cloudflare
2c0f:f248::/32
```
Gcore
```bash
```
https://api.gcore.com/cdn/public-ip-list
```
BunnyCDN
```bash
```
https://api.bunny.net/system/edgeserverlist
https://api.bunny.net/system/edgeserverlist/plain
```
Cloudfront
```bash
```
https://d7uri8nf7uskq.cloudfront.net/tools/list-cloudfront-ips
https://files.imunify360.com/static/whitelist/v2/cloudfront-cdn.txt
```
CDN77
```bash
```
https://files.imunify360.com/static/whitelist/v2/cdn77.txt
```
Fastly
```bash
```
https://api.fastly.com/public-ip-list
```
Keycdn
```bash
```
https://www.keycdn.com/shield-prefixes.json
```
quic.cloud
```bash
```
https://quic.cloud/ips
```
Google CDN
```bash
```
https://files.imunify360.com/static/whitelist/v2/google-cdn.txt
```
CacheFly
```bash
```
https://cachefly.cachefly.net/ips/cdn.txt
```
Akaima
```bash
```
https://techdocs.akamai.com/origin-ip-acl/docs/update-your-origin-server
```
---

View File

@@ -13,7 +13,7 @@ tags = ["Network"]
这里以Debian12为例
- 官方安装脚本:
```bash
```
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
```
@@ -21,31 +21,31 @@ sudo sh get-docker.sh
使用以下命令安装此方法的先决条件:
````bash
````
sudo apt update && sudo apt install ca-certificates curl gnupg
````
创建一个目录来存储密钥环:
````bash
````
sudo install -m 0755 -d /etc/apt/keyrings
````
使用给定的命令下载 GPG 密钥并将其存储在 `/etc/apt/keyrings/etc/apt/keyrings` 目录中:
````bash
````
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
````
使用 chmod 命令更改 docker.gpg 文件的权限:
````bash
````
sudo chmod a+r /etc/apt/keyrings/docker.gpg
````
使用以下命令为 Docker 设置存储库:
````bash
````
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
@@ -53,7 +53,7 @@ echo \
````
现在可以使用以下命令更新存储库索引并安装 Docker
````bash
````
sudo apt update && sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
````
@@ -177,34 +177,34 @@ sudo apt update && sudo apt-get install docker-ce docker-ce-cli containerd.io do
> 删除所有 Docker 容器和 Docker 本身
1. 首先停止所有正在运行的容器:
```bash
```
docker stop $(docker ps -aq)
```
2. 删除所有容器
删除所有容器(包括停止的容器):
```bash
```
docker rm $(docker ps -aq)
```
3. 删除所有镜像
```bash
```
docker rmi $(docker images -q)
```
4. 删除所有网络
```bash
```
docker network prune -f
```
5. 删除所有未使用的卷
```bash
```
docker volume prune -f
```
6. 卸载 Docker
如果您希望完全删除 Docker 本身,可以执行以下命令:
```bash
```
sudo apt-get purge docker-ce docker-ce-cli containerd.io
sudo apt-get autoremove --purge
sudo rm -rf /var/lib/docker
@@ -221,7 +221,7 @@ sudo rm -rf /etc/docker
- 方法:创建两个 docker-compose 文件,并``使用同一个外部 Docker 网络``使两个服务互联。
0. 首先``创建好工作目录``,例如:
```bash
```
.
└── docker
├── docker-compose.nginx.yml
@@ -234,13 +234,13 @@ sudo rm -rf /etc/docker
```
1. 在启动服务前,首先创建一个 Docker 外部网络(例如命名为 nginx
```bash
```
docker network create nginx
```
这样,无论是哪个 docker-compose 项目中的容器,只要加入此网络,就能直接通信。
2. 编写 searxng 的 docker-compose 文件
```yaml
```
version: '3'
services:
@@ -268,7 +268,7 @@ networks:
3. 编写 Nginx 的 docker-compose 文件
创建 nginx 的 docker-compose 文件,例如:
```yaml
```
version: '3'
services:
@@ -291,7 +291,7 @@ networks:
external: true
```
4. 编写 Nginx 配置文件
```conf
```
server {
listen 80;
server_name searxng.dich.bid;
@@ -320,11 +320,11 @@ server {
5. 启动服务
- 启动 searxng 服务:
```bash
```
docker-compose -f docker-compose.searxng.yml up -d
```
- 启动 nginx 服务:
```bash
```
docker-compose -f docker-compose.nginx.yml up -d
```
由于两者都加入了外部网络 nginxnginx 内的``proxy_pass http://searxng:8080``就能解析到 searxng 容器,实现反向代理效果。现在,访问``http://ip:18080``就可以访问Searxng搜索引擎。
@@ -337,7 +337,7 @@ docker-compose -f docker-compose.nginx.yml up -d
1. 证书生成
- 如果只是用于测试可以生成自签名证书:
```bash
```
mkdir -p /home/dich/docker/nginx/certs
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /home/dich/docker/nginx/certs/privkey.pem \
@@ -346,7 +346,7 @@ openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
```
2. 更改searxng.conf:
```conf
```
server {
listen 443 ssl;
server_name searxng.dich.bid;
@@ -385,7 +385,7 @@ server {
```
3. 更改docker-compose.nginx.yml
```yaml
```
version: '3'
services:
@@ -412,11 +412,11 @@ networks:
4. 启动新配置
- 重启容器
```bash
```
sudo docker compose -f docker-compose.nginx.yml up -d
```
- 查看日志
```bash
```
sudo docker logs searxng
```
## Caddy
@@ -424,7 +424,7 @@ sudo docker logs searxng
> Caddy 自 2015 年起用 Go 语言重写,定位为“开箱即用”的现代 Web 服务器,内置自动 Lets Encrypt 证书管理和续期,默认支持 HTTP/2 及 HTTP/3QUIC并通过简洁明了的 Caddyfile 语法极大降低配置成本.
0. 示例结构:
```bash
```
.
└── compose
├── certs
@@ -437,11 +437,11 @@ sudo docker logs searxng
└── Caddyfile
```
1. 同样创建名为Caddy的docker网络
```bash
```
docker network create caddy
```
2. 编写Caddy的compose可以看到caddy可以自带签发证书
```yaml
```
version: '3.7'
# 自动签发模式
@@ -498,7 +498,7 @@ networks:
external: true
```
3. 编写Caddyfile可以看到自动开启HTTPS模式
```conf
```
# 自动签发模式
searxng.dich.bid {
reverse_proxy searxng:8080 {

View File

@@ -28,7 +28,7 @@ SSH 1 协议存在一些安全漏洞,所以``1996年又提出了 SSH 2 协议
李华是一个大学生现在他买了一台服务器公网IPv4为114.514.114.514,李华打算连到上面看看:
```bash
```
ssh -p 22 root@114.514.114.514
```
随后命令行弹出了密码输入李华输入了初始密码114514,成功登录了进去;现在每次登录只要输入一行命令就可以,大功告成!
@@ -39,7 +39,7 @@ ssh -p 22 root@114.514.114.514
于是,李华查阅了资料,发现有一篇博客[乱七八糟:服务器初始化与安全设置](https://blog.dich.bid/about-server-set/)于是他将openssh-server的端口改成了2333,并开启了fail2ban这下应该安全了
```bash
```
### 更换SSH端口
使用root账户或已经有sudo权限的用户登录到系统。
@@ -88,7 +88,7 @@ sudo systemctl status fail2ban
但是服务器依然在被爆破,李华又又研究了以下教程,决定将自己的服务器由密码登录改为密钥登录,这下没有牛马来爆破了!
```bash
```
#### 执行以下命令生成.pub后缀的公钥和无后缀的密钥
ssh-keygen
@@ -140,7 +140,7 @@ sudo cat /etc/ssh/sshd_config | grep -E 'PasswordAuthentication|PubkeyAuthentica
随后,李华在.ssh文件夹下创建了一个文件名为``config``,并在其中写入以下内容:
```bash
```
Host US
HostName 114.514.114.514
User root
@@ -167,7 +167,7 @@ Host US
首先,将.ssh文件夹中的config进行修改,把私钥文件改为公钥文件,同时创建对应的``~/.ssh/US.pub``公钥文件里面是以ssh-ed25519或者ssh-rsa开头的公钥.
```bash
```
Host US
HostName 114.514.114.514
User root

View File

@@ -54,7 +54,7 @@ python3 -m pip install -U yt-dlp
- Arch / Manjaro`sudo pacman -S yt-dlp`
- Fedora`sudo dnf install yt-dlp`
- Nixos:
```nix
```
{pkgs, ...}: {
home.packages = with pkgs; [
peazip
@@ -74,7 +74,7 @@ python3 -m pip install -U yt-dlp
- **下载B站带字幕视频**:
```bash
```
yt-dlp "https://www.bilibili.com/video/BVxxxxx" --write-subs --embed-subs --sub-langs all,-live_chat
--write-subs: 将字幕文件下载为单独文件 (如 .vtt 或 .ass)
@@ -87,11 +87,11 @@ yt-dlp "https://www.bilibili.com/video/BVxxxxx" --write-subs --embed-subs --sub-
- **下载YouTube视频**
先使用这个命令查看可用格式:
```bash
```
yt-dlp -F https://www.youtube.com/watch?v=xxxxxxxxxxxx
```
然后它会列举出所有可用的格式,如下:
```bash
```
[youtube] MgtOAVOXBWo: Downloading webpage
[youtube] MgtOAVOXBWo: Downloading tv client config
[youtube] MgtOAVOXBWo: Downloading tv player API JSON
@@ -121,13 +121,13 @@ sb0 mhtml 160x90 0 │ mhtml │ images
623 mp4 2560x1440 60 │ ~ 1.00GiB 8945k m3u8 │ vp09.00.50.08 8945k video only Untested
```
我们下载312和233,即视频和音频,使用以下命令:
```bash
```
yt-dlp -f "312+233" -o "<新视频的名字,要短一点>.%(ext)s" https://www.youtube.com/watch?v=xxxxxxxxxxxx
```
这行命令会自动将下载的312的1080p/H.264的视频和233的音频合并为一个mp4视频注意新的名称不能太长否则会下载失败。
如果要下载带字幕的视频,则使用
```bash
```
yt-dlp -f "312+233" --write-subs --write-auto-subs --embed-subs --sub-langs "zh.*,en.*" -o "<新视频的名字,要短一点>.%(ext)s" https://www.youtube.com/watch?v=xxxxxxxxxxx
```
这个命令会:
@@ -139,7 +139,7 @@ yt-dlp -f "312+233" --write-subs --write-auto-subs --embed-subs --sub-langs "zh.
- 参数说明
```bash
```
--write-subs: 下载手动字幕
--write-auto-subs: 下载自动生成的字幕
--embed-subs: 将字幕嵌入到视频中

View File

@@ -103,35 +103,35 @@ tags = ["乱七八糟"]
8. **Docker日志文件**:
使用 `docker ps -a` 命令查找你感兴趣的容器的 ID。
````bash
docker ps -a
````
````
docker ps -a
````
进入容器的日志目录,路径类似于 `/var/lib/docker/containers/<container-id>/`。
````bash
cd /var/lib/docker/containers/<container-id>/
````
````
cd /var/lib/docker/containers/<container-id>/
````
使用命令清理或删除日志文件。你可以删除所有日志文件,或者只删除特定的日志文件。
````bash
# 删除所有日志文件
rm *.log
````
# 删除所有日志文件
rm *.log
# 删除特定日志文件(例如 stdout 和 stderr
rm *-json.log
````
# 删除特定日志文件(例如 stdout 和 stderr
rm *-json.log
````
## **Arch Linux 安装备份**
你可以定期备份 Arch Linux 安装的软件列表,以便在需要时轻松还原。
````bash
````
pacman -Qqe > package-list.txt
````
这将列出所有已安装的软件包,并将其保存到文件 `package-list.txt` 中。在还原系统时,你可以使用以下命令:
````bash
````
sudo pacman -S --needed - < package-list.txt
````

View File

@@ -141,7 +141,7 @@ RSS客户端非常丰富包括 Android 端IOS 端Windows 端linux
3在文件中写入以下内容并保存
```yaml
```
version: '3.4'
services:

View File

@@ -18,7 +18,7 @@ tags = ["乱七八糟"]
> 作者Bill Bynum/Tracy Camp 威廉玛丽学院/科罗拉多矿业学院 2002年11月5日
## 目录
```bash
```
1. 引言
2. C-- 编译器语法
3. 并发结构
@@ -238,7 +238,7 @@ v(sem);
为帮助解释信号量的使用,我们提供以下简短示例:
```java
```
BACI System: C-- to PCODE Compiler, 09:24 2 May 2002
Source file: semexample.cm Sun Apr 28 20:40:12 2002
line pc
@@ -277,7 +277,7 @@ line pc
我们使用以下命令生成上述编译器列表:
```bash
```
prompt% bacc semexample
Pcode and tables are stored in semexample.pco
Compilation listing is stored in semexample.lst
@@ -285,7 +285,7 @@ Compilation listing is stored in semexample.lst
然后可以使用 BACI PCODE 解释器执行 semexample.pco 文件:
```bash
```
prompt% bainterp semexample
Source file: semexample.cm Sun Apr 28 20:40:12 2002
Executing PCODE ...
@@ -295,7 +295,7 @@ before p(count) value of count is 1
这是程序可能产生的三种可能输出之一。另外两种可能的程序输出是:
```bash
```
prompt% bainterp semexample
Source file: semexample.cm Sun Apr 28 20:40:12 2002
Executing PCODE ...
@@ -303,7 +303,7 @@ before p(count) value of count is 0
before v(count) value of count is 0
```
```bash
```
prompt% bainterp semexample
Source file: semexample.cm Sun Apr 28 20:40:12 2002
Executing PCODE ...
@@ -534,7 +534,7 @@ sprintf(x,".%12d. .%-20s. .%q. .%08X.",202,y,z,0x3c03);
以下列表由 C-- BACI 编译器生成。行号右侧的数字是开始该行的指令的 PCODE 偏移量。BACI 编译器从文件 "incremen.cm" 创建此列表。该列表被放置在文件 "incremen.lst" 中。还创建了一个 "incremen.pco" 文件;此文件由解释器使用。
```java
```
BACI System: C-- to PCODE Compiler, 09:24 2 May 2002
Source file: incremen.cm Wed Oct 22 21:18:02 1997
line pc
@@ -566,7 +566,7 @@ line pc
以下列表由 BACI 解释器生成。解释器执行编译到文件 "incremen.pco" 中的程序。
```java
```
Source file: incremen.cm Wed Oct 22 21:18:02 1997
Executing PCODE ...
C n =1 i =A n =1 C2 i =
@@ -600,7 +600,7 @@ dos2unix ~/Git/java/baci/scripts/baci
```
- 编写baci脚本
```bash
```
#!/usr/bin/env bash
# 定位到项目根目录(包含 javabaci 子目录的目录)
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -613,19 +613,19 @@ exec java -cp "$CLASSPATH" "$@"
```
- 给baci授予可执行权限
```bash
```
chmod +x ~/Git/java/baci/scripts/baci
```
- 添加系统环境变量
```bash
```
fish_add_path ~/Git/java/baci/scripts
```
- 查看baci是否存在
```bash
```
which baci
```
- 现在即可编译运行
```bash
```
baci bacc ex3_1.cm
baci bainterp ex3_1
```

View File

@@ -24,7 +24,7 @@ tags = ["乱七八糟"]
- 首先你需要有一台自己的云服务器建议在1核1G以上配置并安装Debian系统
- 随后我们安装1panel执行以下命令一键安装
```bash
```
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sudo bash quick_start.sh
```
> 1panel依赖于docker如果实现没有安装docker脚本会帮你安装。
@@ -54,33 +54,33 @@ curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_
1. **安装Hugo**:选择好你的框架与主题后这里以hugo为例子随后安装hugo以及对应的依赖
- **Windows**
```bash
```
# 打开以管理员模式运行的PowerShell,输入命令安装 Hugo Extended
winget install Hugo.Hugo.Extended
```
- **Arch linux**
```bash
```
paru -S hugo
```
- **检查版本**
```bash
```
hugo version
```
2. **创建新的 Hugo 站点**:选择一个文件夹打开命令行,执行:
```bash
```
hugo new site myblog
```
该命令会在``myblog``文件夹下生成hugo的基础目录。
3. **安装主题**,这里以[hugo-blog-awesome](https://jamstackthemes.dev/theme/hugo-blog-awesome/)主题为例:
```bash
```
cd myblog
git clone https://github.com/hugo-sid/hugo-blog-awesome.git themes/hugo-blog-awesome
```
并在``hugo.toml``顶层添加:
```bash
```
theme = "hugo-blog-awesome"
```
这样 Hugo 在构建时会从 themes/ 目录加载主题文件。后续可使用``git pull``获取主题更新。
@@ -88,7 +88,7 @@ theme = "hugo-blog-awesome"
> 你也可以直接用theme中的文件夹替换掉项目根目录下的同名文件夹并再次修改。
4. **写入文章**:使用 Hugo 提供的命令创建新文章:
```bash
```
hugo new posts/hello-world.md
```
该命令会在``content/posts/``下生成 Markdown 文件,打开后修改``title、date、tags``等前缀然后撰写 Markdown 正文, Markdown 编辑器参考[前文](https://blog.dich.bid/about-markdown/)。
@@ -96,7 +96,7 @@ hugo new posts/hello-world.md
> 注意md文章头部和正文之间得使用``<!-- more -->``隔断
5. **本地测试**:在项目根目录运行:
```bash
```
hugo server -D
```
然后在浏览器访问``http://localhost:1313``即可实时预览并查看更新效果。
@@ -136,7 +136,7 @@ hugo server -D
由于我所使用的平台不支持zola因此我直接在本地编译public并推送这样时间久了.git文件夹大小会非常大记录public的变化我又不想将zola的二进制包放入目录下因此有了这个办法
```bash
```
# 安装git-filter-repo工具
paru git-filter-repo
# 清理public相关的历史

View File

@@ -173,31 +173,6 @@ tags = ["乱七八糟"]
- [离散数学-东北大学](https://www.bilibili.com/video/BV1d7411v7zu/?spm_id_from=333.999.0.0&vd_source=cc4bfbaa0f8c6c363ff9afecce036d91)
- [统计学-个人 UP 主](https://space.bilibili.com/610062295/channel/seriesdetail?sid=2558242&ctype=0)
## 英语相关
| 频道名称 | 频道 URL | 内容类型 | 口音/特色 | 难度 | 推荐理由/备注 |
| :--- | :--- | :--- | :--- | :--- | :--- |
| **Max Amini** | [youtube.com/@MaxAmini](https://www.youtube.com/@MaxAmini) | 娱乐 | 脱口秀 | 高阶 | 男、伊朗裔美国喜剧演员,语速快,内容幽默。 |
| **Michelle Khare** | [youtube.com/@MichelleKhare](https://www.youtube.com/@MichelleKhare) | 兴趣频道 | Vlog | 中阶 | 女、兴趣内容、有挑战自我的性质。 |
| **This Is How We Bingham** | [youtube.com/@ThisIsHowWeBingham](https://www.google.com/search?q=https://www.youtube.com/%40ThisIsHowWeBingham) | 生活 | 美音 | 初阶 | 一家人的生活记录,语速较慢,内容温馨。 |
| **Travel with Wife and Baby** | [youtube.com/@TravelwithWifeandBaby](https://www.google.com/search?q=https://www.youtube.com/%40TravelwithWifeandBaby) | 生活 | 美音 | 初阶 | 男、旅行Vlog语速适中内容有趣。 |
| **MKBHD** | [youtube.com/@mkbhd](https://www.youtube.com/@mkbhd) | 兴趣频道 | 美音 | 高阶 | 男、科技评测频道,语速快,内容专业,适合科技爱好者。 |
| **Mark Wiens** | [youtube.com/@MarkWiens](https://www.youtube.com/@MarkWiens) | 兴趣频道 | 美音 | 中阶 | 男、美食旅行频道,语速适中,内容诱人。 |
| **MrBeast** | [youtube.com/@MrBeast](https://www.youtube.com/@MrBeast) | 娱乐 | 美音 | 初阶 | 男、以大手笔挑战和慈善活动闻名,语速快,内容刺激。 |
| **Medlife Crisis** | [youtube.com/@MedlifeCrisis](https://www.youtube.com/@MedlifeCrisis) | 知识 | 英音 | 中高阶 | 男、医学专业,内容深入浅出,语速较快。 |
| **Learn English with Bob the Canadian** | [youtube.com/@LearnEnglishwithBobtheCanadian/videos](https://www.youtube.com/@LearnEnglishwithBobtheCanadian/videos) | 英文学习 | 美音 | 初中阶 | 男、内容以日常生活为主,语速较慢,发音清晰,适合初学者。 |
| **The Late Late Show with James Corden** | [youtube.com/@TheLateLateShow](https://www.youtube.com/@TheLateLateShow) | 娱乐 | 英音 | 高阶 | James Corden的深夜秀有很多明星访谈和各种有趣的单元如Carpool Karaoke。 |
| **The School of Life** | [youtube.com/@theschooloflifetv](https://www.youtube.com/@theschooloflifetv) | 知识 | 英音 | 中高阶 | 哲学、心理学、社会学等,内容发人深省,语速适中,是很好的听力材料。 |
| **Kurzgesagt In a Nutshell** | [youtube.com/@kurzgesagt](https://www.youtube.com/@kurzgesagt) | 知识 | 英音 | 中高阶 | 科普动画频道,内容严肃有趣,制作精良,适合拓展词汇和知识面。 |
| **The LeBrons** | [youtube.com/@TheLeBrons](https://www.google.com/search?q=https://www.youtube.com/%40TheLeBrons) | 娱乐 | 美音 | 初阶 | 勒布朗·詹姆斯的播客频道。 |
| **Keith Williams** | [youtube.com/@KeithWilliamsvideos](https://www.google.com/search?q=https://www.youtube.com/%40KeithWilliamsvideos) | 英文学习 | 美音 | 初中阶 | 男、视频内容较长、语速适中、发音标准,适合初学者。 |
| **Kevin in Shanghai** | [youtube.com/@KevinInShanghai](https://www.google.com/search?q=https://www.youtube.com/%40KevinInShanghai) | 生活 | 住在华语地区的外国人 | 初中阶 | 男、在上海生活的外国人,语速慢,内容贴近生活。 |
| **Kevin's English Class** | [youtube.com/@KevinsEnglishClass](https://www.youtube.com/@KevinsEnglishClass) | 英文学习 | 美音 | 初阶 | 男、英文教学频道,内容短小精悍,适合碎片时间学习。 |
| **Leo Roget** | [youtube.com/@leoroget](https://www.google.com/search?q=https://www.youtube.com/%40leoroget) | 生活 | 美音 | 初阶 | 男、日常Vlog、语速适中、内容轻松。 |
| **Learners English** | [youtube.com/@LearnersEnglish](https://www.google.com/search?q=https://www.youtube.com/%40LearnersEnglish) | 英文学习 | 美音 | 初阶 | 男、英文学习频道,内容全面、系统性强。 |
| **LangFocus** | [youtube.com/@Langfocus](https://www.youtube.com/@Langfocus) | 知识 | 美音 | 中阶 | 男、语言学频道,内容涉及语言起源、发展、对比等,语速适中,知识点丰富。 |
## 哲学相关
- [中国人民大学:西方哲学史-张志伟](https://www.bilibili.com/video/BV1y64y1r7Mt/?spm_id_from=333.337.search-card.all.click&vd_source=cc4bfbaa0f8c6c363ff9afecce036d91)

View File

@@ -26,19 +26,19 @@ tags = ["乱七八糟"]
## 免密码运行TUN模式:
- 检查 polkit 服务是否正在运行
```bash
```
systemctl status polkit
```
- 若返回状态为除 active (running) 之外的结果,运行
```bash
```
sudo systemctl enable --now polkit
```
- 创建 polkit 策略
```bash
```
sudo vi /etc/polkit-1/rules.d/99-nopassword.rules
```
- 添加以下内容并保存退出
```bash
```
polkit.addRule(function (action, subject) {
if (
(action.id == "org.freedesktop.resolve1.set-domains" ||
@@ -53,11 +53,11 @@ polkit.addRule(function (action, subject) {
});
```
- 将当前用户添加至 wheel 组中,注意Debian 与衍生系统需要先创建 wheel 组,然后运行:
```bash
```
sudo usermod -G wheel 当前用户
```
- 重新加载 polkit 使更改生效
```bash
```
sudo systemctl restart polkit
```

View File

@@ -6,205 +6,451 @@ date = 2023-12-15
tags = ["乱七八糟"]
+++
前言 Git作为现代软件开发中不可或缺的版本控制工具常常让初学者感到困惑。本文旨在介绍 Git 的全流程安装和基本使用,希望能够帮助新手更轻松地理解和掌握 Git 的基本概念和操作。
<!-- more -->
## 安装git
我们以Github为例子过一遍Git的安装/配置/连接和第一次提交.
- Windows[Git-download](https://git-scm.com/download/)
## 1.安装Git
- Archlinux`sudo pacman -S git`
- Windows官网下载[Git-download](https://git-scm.com/download/)或者使用Scoop/WinGet等等.
- LinuxUbuntu:`sudo apt install git` / Arch:`sudo pacman -S git`
安装完成后可以在终端中检测版本:
```
git -v
git version 2.51.2
```
## 2.创建密钥
在推送代码到Github的时候我们需要进行认证有密码认证和密钥认证两种方法现在推荐使用密钥认证。
- 首先生成一对公私钥,这里的邮箱可以随意填写:
```bash
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
```
你会看到如下所示的提示,像我一样填写路径的时候就可以顺便给它改个名字否则会使用默认名id_rsa:
```
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/dich/.ssh/id_rsa): /home/dich/.ssh/Github
```
随后一直按回车即可.
- 生成的这对公私钥位于``~/.ssh/config``路径下在Windows中就是``C盘/User/你的用户名``下,带.pub后缀的文件为公钥不带.pub后缀的为私钥,打开公钥复制全部内容然后将公钥添加到Github的``Settings-SSH and GPG keys``中。
> 当你添加完毕后就无法在Github的设置中再次查看它了确保了安全性.
- 随后编辑 `~/.ssh/config` 文件这个文件的作用是让Git知道主机对应的密钥例如
```bash
# GitHub
Host github
HostName github.com
User git
IdentityFile ~/.ssh/Github
# Gitee
Host gitee
HostName gitee.com
User git
IdentityFile ~/.ssh/Gitee
```
> 这边的IdentityFile是你的私钥位置即为不带pub后缀的文件。如果你不想将私钥放在~/.ssh/下,可以查看我的另一篇[博客](https://blog.dich.bid/network-ssh/)
- 设置好上面这些后就可以测试连接到Github,如果成功则显示successfully.
```bash
ssh -T git@github.com
Hi Dichgrem! You've successfully authenticated, but GitHub does not provide shell access.
```
## 3.配置Git
在正式连接到仓库前我们还需要让Git知道我们的用户名和邮箱地址。
- 显示当前的Git配置
```bash
git config --list
```
- 设置提交代码时的用户信息,这里的name推荐和你的GitHub用户名一致邮箱可以不为真实邮箱比如``no-reply@github.com``
```bash
git config [--global] user.name "[name]"
git config [--global] user.email "[email address]"
```
> 注意如果你填写了你的真实邮箱同时这个仓库又是Public的那么其他人可以看到你的邮箱
- 配置默认主分支为Main
```bash
git config --global init.defaultBranch main
```
这里的设置是因为Git目前默认的主分支名为 master ,而 Github 默认分支名为 main ,这样可以保持一致。
## 4.创建仓库
配置完Git之后我们就可以连接到远程的仓库了。首先创建一个Git仓库一般有两种方法
- 方法一(推荐)在远程创建后下载到本地
我们在Github中的``repositories``下New一个仓库然后在绿色的Code按钮中复制链接克隆远端服务器上的仓库
```
git clone git@github.com:Dichgrem/script.git
```
>如果你前面没有配置密钥就会发现无法使用这个命令克隆仓库。那么什么时候使用HTTPS的克隆呢比如其他人的仓库你没有权限又不想fork一份的情况下就可以使用HTTPS.
- 方法二:在本地初始化之后连接到远程
创建一个新文件夹,然后在那个文件夹下运行以下命令:
```bash
git init --initial-branch=main
```
- 在Github上创建一个同名仓库随后添加远程链接
```bash
git remote add origin <remote_repository_url>
```
> 如果你运行``git remote -v``发现URL为HTTP格式则可以用下面的命令改为Git格式
```bash
# 例如git remote set-url origin git@github.com:Dichgrem/dichos.git
```
## 4.推送代码
- 添加
在Git仓库中新建或修改文件后使用如下命令把它们添加到暂存区
```bash
git add *
```
- 提交
随后使用如下命令提交改动:
```bash
git commit -m "代码提交信息"
# 例如git commit -m "update:mycode"
```
现在,你的改动已经提交到了 **HEAD**,但是还没到你的远端仓库。
- 推送改动
执行如下命令以将这些改动提交到远端仓库,随后即可在GitHub上查看
```bash
git push origin main
```
> 想学习更多Git操作可以使用这个[Git练习网站](https://learngitbranching.js.org/?locale=zh_CN)
## 5.Commit规范
- 提交信息的基本格式,例如
```
feat:add_highlight
```
- 常见的 Commit 类型
```bash
- feat新功能的添加
- fix修复 Bug
- docs文档相关的修改
- style代码格式、排版等不影响代码逻辑的调整
- refactor代码重构不涉及新功能或 Bug 修复
- perf性能优化
- test添加或修改测试代码
- build构建相关的变更如依赖管理、构建脚本等
- ci持续集成相关的修改
- chore其他杂项维护不涉及源代码或测试文件的修改
- revert回滚到上一个版本的提交
```
## 6.Git原理
- 三棵树
## 原理
一个Git仓库的目录里面包括``工作目录``(即我们要追踪的代码)以及``.git``目录Git 在这里存储自己的数据。Git 维护了三棵“树”:第一个是你的 `工作目录`,它持有实际文件;第二个是 `暂存区Index`,它像个缓存区域,临时保存你的改动;最后是 `HEAD`,它指向你最后一次提交的结果。
![git-tree](http://marklodato.github.io/visual-git-guide/basic-usage.svg.png)
- `.git` 目录结构
## 创建新仓库
```bash
首先我们需要得到一个Git仓库一般有两种方法
- 在本地初始化之后连接到远程;
- 在远程创建后”下载“到本地。
**方法一**
创建新文件夹,在你的项目目录中运行以下命令:
```
git init --initial-branch=main
```
这里设置默认仓库主分支名称为 main,避免因为 main/master 名称不同导致的推送问题。
> Git目前默认的主分支为 master和 github 默认分支 main 不同,这使得默认配置下 git 往往连接失败。除了创建的时候设定外还可以通过以下方法改变默认分支。
```
git config --global init.defaultBranch main //将默认分支修改成main
```
**方法二**
克隆远端服务器上的仓库:
- HTTPS方法``git clone https://github.com/Dichgrem/script.git``
- 或者使用SSH方法``git clone git@github.com:Dichgrem/script.git``
>建议使用SSH方法如果你使用HTTPS方法则提交代码时需要手动输入用户名/密码使用SSH方法则只需要在``~/.ssh/config``中配置即可。
## 配置
Git的设置文件为.gitconfig它可以在用户主目录下全局配置也可以在项目目录下项目配置
- 显示当前的Git配置
```
git config --list
```
- 编辑Git配置文件
```
git config -e [--global]
```
- 设置提交代码时的用户信息
```
git config [--global] user.name "[name]"
git config [--global] user.email "[email address]"
```
- 设置大小写敏感windows不区分大小写的解决办法
```
git config core.ignorecase false
```
- 配置git默认使用的编辑器
```
git config --global core.editor "nvim"
```
## 连接远程仓库
连接到远程仓库并推送需要证明你有权写入仓库。早期Github可以使用密码认证现在则使用密钥认证。
- 生成密钥:
```
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
```
- 生成的文件位于``~/.ssh/config``路径下,带.pub后缀的文件为公钥不带.pub后缀的为私钥使用``cat ~/.ssh/id_rsa.pub``将公钥添加到github/gitee的设置-SSH中。
- 随后使用 `ssh-add` 命令将生成的密钥添加到 SSH 代理中。
```
ssh-add ~/.ssh/github_key
ssh-add ~/.ssh/gitee_key
```
- 在 `~/.ssh/config` 文件中配置不同的主机别名以及相应的密钥文件。编辑该文件并添加内容,例如:
```
# GitHub repository 1
Host github1
HostName github.com
User git
IdentityFile ~/.ssh/github_key
# GitHub repository 2
Host github2
HostName gitee.com
User git
IdentityFile ~/.ssh/gitee_key
```
- 连接到github
```
ssh -T git@github.com
```
- 添加远程仓库:
```
git remote add origin <remote_repository_url>
# 例如git remote add origin git@github.com:Dichgrem/dichos.git
```
> 如果你运行``git remote -v``发现URL为HTTP格式则可以用下面的命令改为Git格式
```
# 例如git remote set-url origin git@github.com:Dichgrem/dichos.git
```
## 创建分支
```
git branch main
```
这将创建一个名为 main 的分支。
- 删除分支
```
git branch -d master
```
- 使用大写强制删除
```
git branch -D master
```
## 添加和提交
你可以提出更改(把它们添加到暂存区),使用如下命令:
```
git add <filename>
git add *
```
这是 git 基本工作流程的第一步;使用如下命令以实际提交改动:
```
git commit -m "代码提交信息"
# 例如git commit -m "Initial commit"
```
现在,你的改动已经提交到了 **HEAD**,但是还没到你的远端仓库。
- 添加指定文件到暂存区
```
git add [file1] [file2] ...
```
- 添加指定目录到暂存区,包括子目录
```
git add [dir]
```
- 添加当前目录的所有文件到暂存区
```
git add .
```
添加每个变化前,都会要求确认
- 对于同一个文件的多处变化,可以实现分次提交
```
git add -p
```
- 删除工作区文件,并且将这次删除放入暂存区
```
git rm [file1] [file2] ...
```
- 停止追踪指定文件,但该文件会保留在工作区
```
git rm --cached [file]
```
- 改名文件,并且将这个改名放入暂存区
```
git mv [file-original] [file-renamed]
```
## 推送改动
你的改动现在已经在本地仓库的 **HEAD** 中了。执行如下命令以将这些改动提交到远端仓库:
```
git push origin main
```
可以把 **main** 换成你想要推送的任何分支,如**master**或者**test**
如果你的远程仓库是最新的,可以使用以下命令更新本地仓库:
```
git pull
```
> Verified
在 GitHub 的 commit 历史中看到的 “Verified” 标记,表示该提交是经过 签名验证signed commit 的,也就是 GitHub 能确认这个 commit 的确是由声明的提交者签名并发布的。可以通过GPG或者SSH配置
- GPG方式
```
sudo pacman -S gnupg //安装 GPG
gpg --full-generate-key //生成 GPG 密钥
gpg --list-secret-keys --keyid-format=long //查看你生成的密钥 ID
git config --global user.signingkey ABCDEF1234567890 //让 Git 使用该密钥签名
git config --global commit.gpgsign true //启用自动签名所有提交
gpg --armor --export ABCDEF1234567890 //导出公钥并添加到 GitHub
```
然后前往``GitHub → Settings → SSH and GPG keys → New GPG key``粘贴并保存。
- SSH方式
可以用你平时登录 GitHub 的同一个 SSH 密钥:
```
git config --global gpg.format ssh //让 Git 使用 SSH 格式签名
git config --global user.signingkey ~/.ssh/Github.pub //指定使用的 SSH 公钥
git config --global commit.gpgsign true //表示自动签名所有提交
```
然后前往``Settings → SSH and GPG keys → New SSH key → Signing key``粘贴并保存。
- 本地查看
首先创建这个文件:
```
mkdir -p ~/.ssh
nano ~/.ssh/allowed_signers
```
写入你的 ``test@mail.com ssh-ed25519 AAAABBBBBBBBBBBBBBBBxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx``并保存。
随后配置Git信任该文件
```
git config --global gpg.ssh.allowedSignersFile ~/.ssh/allowed_signers
```
随后使用``git log --show-signature``即可查看本地log中的
```
Good "git" signature for test@mail.com with ED25519 key SHA256:ssh-ed25519 AAAABBBBBBBBBBBBBBBBBBBBB
```
## 合并分支
分支是用来将特性开发绝缘开来的。比如你在本地的test分支新增了一个功能想要合并到主分支中。
创建一个叫做“test”的分支并切换过去
```
git checkout -b test
```
新增某些功能后切换回主分支:
```
git checkout master
```
在主分支上执行合并操作,将 test 分支的改动合并到主分支:
```
git merge test
```
推送完成后可以把新建的分支删掉:
```
git branch -d test
```
### 分支常用操作
```
- 列出所有本地分支
git branch
- 列出所有远程分支
git branch -r
- 列出所有本地分支和远程分支
git branch -a
- 列出所有本地分支,并展示没有分支最后一次提交的信息
git branch -v
- 列出所有本地分支,并展示没有分支最后一次提交的信息和远程分支的追踪情况
git branch -vv
- 列出所有已经合并到当前分支的分支
git branch --merged
- 列出所有还没有合并到当前分支的分支
git branch --no-merged
- 新建一个分支,但依然停留在当前分支
git branch [branch-name]
- 新建一个分支,并切换到该分支
git checkout -b [branch]
- 新建一个与远程分支同名的分支,并切换到该分支
git checkout --track [branch-name]
- 新建一个分支指向指定commit
git branch [branch] [commit]
- 新建一个分支,与指定的远程分支建立追踪关系
git branch --track [branch] [remote-branch]
- 切换到指定分支,并更新工作区
git checkout [branch-name]
- 切换到上一个分支
git checkout -
- 建立追踪关系,在现有分支与指定的远程分支之间
git branch --set-upstream-to=[remote-branch]
git branch --set-upstream [branch] [remote-branch] - 已被弃用
- 合并指定分支到当前分支
git merge [branch]
- 中断此次合并(你可能不想处理冲突)
git merge --abort
- 选择一个commit合并进当前分支
git cherry-pick [commit]
- 删除分支
git branch -d [branch-name]
#新增远程分支 远程分支需先在本地创建,再进行推送
git push origin [branch-name]
- 删除远程分支
git push origin --delete [branch-name]
git branch -dr [remote/branch]
```
## 标签
Git 的 tag 功能主要用于``给仓库历史中的某个特定提交打上“标签”``,通常用于标记版本发布点(例如 v1.0、v2.0 等),以``便于后续的版本定位、回溯和发布管理``。
### 标签类型
Git 提供两种类型的标签:
- 附注标签Annotated Tag会创建成一个完整的 Git 对象,存储打标签者的名字、邮箱、日期和标签说明,还可采用 GPG 进行签名。推荐用于正式发布,因为包含更多元数据和安全信息。
- 轻量标签Lightweight Tag实际上只是对某个提交的引用不保存额外信息类似一个固定的分支。适用于临时标记或非正式用途。
### 创建标签
- 创建附注标签
使用 -a 参数表示“annotated”并用 -m 提供标签说明。例如,给当前提交创建一个名为 v1.0 的附注标签:
```
git tag -a v1.0 -m "发布版本 v1.0"
```
这会在 Git 数据库中生成一个完整的标签对象,可通过 git show v1.0 查看标签信息和对应的提交详情。
如果需要给旧提交贴标签,可以在命令末尾指定提交的 SHA 值(部分 SHA 也可):
```
git tag -a v1.0 <commit-sha> -m "发布版本 v1.0"
```
- 创建轻量标签
直接指定标签名即可,不加任何参数:
```
git tag v1.0-light
```
轻量标签仅仅是一个提交引用,因此查看时不会显示附加信息。
### 列出标签
- 列出所有标签
```
git tag
```
- 还可以使用通配符过滤:
```
git tag -l "v1.*"
```
这样便于管理和筛选大量标签。
- 查看标签详细信息
```
git show v1.0
```
这会显示标签对象的元数据以及对应的提交记录。
### 推送标签
``默认情况下git push 不会将本地标签推送到远程仓库。推送标签有两种方式:``
- 推送单个标签
```
git push origin v1.0
```
- 一次性推送所有标签
```
git push origin --tags
```
### 删除标签
- 删除本地标签
```
git tag -d v1.0
```
- 删除远程标签
```
git push origin --delete v1.0
```
## 日志
如果你想了解本地仓库的历史记录,最简单的命令就是使用:
```
git log
```
- 只看某一个人的提交记录:
```
git log --author=bob
```
- 一个压缩后的每一条提交记录只占一行的输出:
```
git log --pretty=oneline
```
- 看看哪些文件改变了:
```
git log --name-status
```
## 生成补丁
比如你修改了项目中的``fs/proc/base.c``,然后
```
git add fs/proc/base.c
git commit -m "fix:base"
git format-patch origin/16.0
```
即可在目录下生成补丁``0001-fix-base.patch``.
## 删除前一个提交记录
有时候手滑或者不想使用一个commit说明可以用以下命令撤销上一个 commit
```
git reset --soft HEAD~1
```
这个命令会撤销上一个 commit但保留文件修改代码仍然在工作区。适用于 想要重新提交amend或调整 commit 的情况。
如果你想彻底删除更改(不保留代码修改),可以使用:
```
git reset --hard HEAD~1
```
> 注意:--hard 会清除未提交的更改,无法恢复。
## `.git` 目录中主要文件和子目录的结构及其作用
### 📁 `.git` 目录结构概览
```
.git/
├── HEAD
├── config
@@ -225,95 +471,95 @@ feat:add_highlight
│ └── tags/
```
* objects存储 Git 的所有对象,包括:
* blob文件内容
* tree目录结构
* commit提交对象记录提交信息和指向的树对象
* tag标签对象
这些对象以 SHA-1 哈希命名,前两位作为子目录,其余作为文件名
* refs存储所有引用包括
* heads本地分支
* remotes远程分支
* tags标签
* HEAD指向当前检出的分支或提交。例如`ref: refs/heads/main` 表示当前位于 `main` 分支
* config仓库级别的配置文件包含用户名、邮箱、远程仓库等信息
* description用于描述仓库仅供 GitWeb 等工具使用
* hooks存放 Git 钩子脚本的目录,可用于在特定操作前后执行自定义脚本,如 `pre-commit`、`post-merge` 等
* index暂存区staging area的索引文件记录了即将提交的文件信息
* info包含辅助信息如 `exclude` 文件用于定义仓库级别的忽略规则
* logs记录了引用如分支、标签的更新历史有助于追踪操作记录
### 🗂️ 核心文件和目录说明
---
* **HEAD**:指向当前检出的分支或提交。例如,`ref: refs/heads/main` 表示当前位于 `main` 分支。
## 7.Tips
* **config**:仓库级别的配置文件,包含用户名、邮箱、远程仓库等信息.
* **description**:用于描述仓库,仅供 GitWeb 等工具使用。
### Verified
* **hooks/**:存放 Git 钩子脚本的目录,可用于在特定操作前后执行自定义脚本,如 `pre-commit`、`post-merge` 等.
在 GitHub 的 commit 历史中看到的 “Verified” 标记,表示该提交是经过 签名验证signed commit 的,也就是 GitHub 能确认这个 commit 的确是由声明的提交者签名并发布的。可以通过GPG或者SSH配置
* **index**暂存区staging area的索引文件记录了即将提交的文件信息。
- GPG方式
* **info/**:包含辅助信息,如 `exclude` 文件用于定义仓库级别的忽略规则。
```bash
sudo pacman -S gnupg //安装 GPG
gpg --full-generate-key //生成 GPG 密钥
gpg --list-secret-keys --keyid-format=long //查看你生成的密钥 ID
git config --global user.signingkey ABCDEF1234567890 //让 Git 使用该密钥签名
git config --global commit.gpgsign true //启用自动签名所有提交
gpg --armor --export ABCDEF1234567890 //导出公钥并添加到 GitHub
* **logs/**:记录了引用(如分支、标签)的更新历史,有助于追踪操作记录。
* **objects/**:存储 Git 的所有对象,包括:
* **blob**:文件内容。
* **tree**:目录结构。
* **commit**:提交对象,记录提交信息和指向的树对象。
* **tag**:标签对象。
这些对象以 SHA-1 哈希命名,前两位作为子目录,其余作为文件名。
* **refs/**:存储所有引用,包括:
* **heads/**:本地分支。
* **remotes/**:远程分支。
* **tags/**:标签。
## Commit规范
### 提交信息的基本格式
- Header头部
格式:
```
然后前往``GitHub → Settings → SSH and GPG keys → New GPG key``粘贴并保存。
- SSH方式
可以用你平时登录 GitHub 的同一个 SSH 密钥:
```bash
git config --global gpg.format ssh //让 Git 使用 SSH 格式签名
git config --global user.signingkey ~/.ssh/Github.pub //指定使用的 SSH 公钥
git config --global commit.gpgsign true //表示自动签名所有提交
```
然后前往``Settings → SSH and GPG keys → New SSH key → Signing key``粘贴并保存。
- 本地查看
首先创建这个文件:
```bash
mkdir -p ~/.ssh
nano ~/.ssh/allowed_signers
```
写入你的 ``test@mail.com ssh-ed25519 AAAABBBBBBBBBBBBBBBBxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx``并保存。
随后配置Git信任该文件
```bash
git config --global gpg.ssh.allowedSignersFile ~/.ssh/allowed_signers
```
随后使用``git log --show-signature``即可查看本地log中的
```bash
Good "git" signature for test@mail.com with ED25519 key SHA256:ssh-ed25519 AAAABBBBBBBBBBBBBBBBBBBBB
<type>[可选的 scope]: <简短描述>
```
### 生成补丁
type 表示提交类型feat新功能、fix修复bug等。
scope 是可选的,用于指出变更影响的模块或范围。
简短描述 用于概述本次提交的核心内容,通常使用祈使语气。
比如你修改了项目中的``fs/proc/base.c``,然后
- Body正文
用于详细说明变更的动机、方法以及可能的影响,建议每行不超过 72 个字符。
- Footer脚注
可选部分,用来引用相关 issue、任务或说明破坏性变更例如BREAKING CHANGE: ...)。例如:
```bash
git add fs/proc/base.c
git commit -m "fix:base"
git format-patch origin/16.0
```
即可在目录下生成补丁``0001-fix-base.patch``.
### 删除前一个提交记录
有时候手滑或者不想使用一个commit说明可以用以下命令撤销上一个 commit
```bash
git reset --soft HEAD~1
Fixes #123
```
个命令会撤销上一个 commit但保留文件修改代码仍然在工作区。适用于 想要重新提交amend或调整 commit 的情况
可以在提交后自动关闭相关问题
如果你想彻底删除更改(不保留代码修改),可以使用:
```bash
git reset --hard HEAD~1
### 常见的 Commit 类型
```
- feat新功能的添加
示例feat(user): 添加用户注册功能
- fix修复 Bug
示例fix(parser): 修复解析错误导致程序崩溃
- docs文档相关的修改
示例docs(readme): 更新使用说明
- style代码格式、排版等不影响代码逻辑的调整
示例style: 优化代码缩进和空格
- refactor代码重构不涉及新功能或 Bug 修复
示例refactor: 优化数据处理逻辑
- perf性能优化
示例perf: 提升数据查询速度
- test添加或修改测试代码
示例test: 补充用户登录单元测试
- build构建相关的变更如依赖管理、构建脚本等
示例build: 更新 webpack 配置
- ci持续集成相关的修改
示例ci: 调整 GitHub Actions 配置
- chore其他杂项维护不涉及源代码或测试文件的修改
示例chore: 更新项目依赖
- revert回滚到上一个版本的提交
示例revert: 撤销上次提交
```
---
**Done.**

View File

@@ -52,19 +52,19 @@ tags = ["乱七八糟"]
## 安装 GnuPG
```bash
```
paru -S gnupg
```
## 生成公钥与私钥
使用如下命令:
```bash
```
gpg --full-generate-key
```
生成流程:
```bash
```
gpg (GnuPG) 2.4.7; Copyright (C) 2024 g10 Code GmbH
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
@@ -116,7 +116,7 @@ generator a better chance to gain enough entropy.
```
## 列出密钥
```bash
```
gpg --list-secret-keys --keyid-format long
```
@@ -126,18 +126,18 @@ gpg --list-secret-keys --keyid-format long
例如上传你的 key
```bash
```
gpg --send-keys <你的LongKeyID>
```
默认为你的 gpg.conf 中配置的 keyserver也可以显式指定
```bash
```
gpg --keyserver hkps://keys.openpgp.org --send-keys <KeyID>
```
也可以使用如下命令导出公钥为可读 ASCII 格式类似ssh-keys随后即可发布在个人博客上等等。
```bash
```
gpg --armor --export <KeyID> > mypubkey.asc
```
@@ -145,7 +145,7 @@ gpg --armor --export <KeyID> > mypubkey.asc
如果怀疑密钥被泄露或被中间人替换立即发布“撤销证书”revocation certificate并上传到 keyserver。
```bash
```
gpg --gen-revoke <KeyID> > revoke.asc
```
上传撤销证书后,所有人都能知道该公钥已不再可信。

View File

@@ -19,27 +19,27 @@ tags = ["乱七八糟"]
## 安装
首先安装neovim,在arch linux上是
```bash
```
paru -S neovim
```
在Ubuntu上是
```bash
```
sudo add-apt-repository ppa:neovim-ppa/unstable
sudo apt update
sudo apt install -y \ neovim git curl unzip build-essential ripgrep fd-find
```
备份现有配置:
```bash
```
mv ~/.config/nvim ~/.config/nvim.bak
mv ~/.local/share/nvim ~/.local/share/nvim.bak
```
克隆 LazyVim Starter 模板:
```bash
```
git clone https://github.com/LazyVim/starter ~/.config/nvim
```
启动 Neovim
```bash
```
nvim
```
首次启动时LazyVim 会自动安装并配置所需的插件。
@@ -47,7 +47,7 @@ nvim
## 结构
LazyVim 的配置目录通常位于``~/.config/nvim/``中:
``` bash
```
~/.config/nvim
tree
.
@@ -231,7 +231,7 @@ LazyVim 默认使用``<space> 作为 <leader>``\ 作为``<localleader>``
在``~/config/nvim/lua/plugins/``下新建一个mp.lua写入如下配置
```lua
```
return {
{
"iamcco/markdown-preview.nvim",
@@ -243,7 +243,7 @@ return {
```
随后即可在 Neovim 中打开一个 Markdown 文件,执行以下命令启动预览:​
```bash
```
:MarkdownPreview
```

View File

@@ -19,7 +19,7 @@ tags = ["乱七八糟"]
## 三.解决方法
既然是高低电平表述的错误那么我们只需建立DSDT 表副本,将其修改,然后让它优先启动,从而让键盘配置正常;另外还存在 BIOS 修复,内核编译的方法,比较复杂,这里不做说明。
```bash
```
首先建立一个DSDT文件夹
sudo su
mkdir -p /home/dsdt
@@ -75,7 +75,7 @@ reboot
### 修复wifi驱动
```bash
```
# 内核小于5.18的
git clone https://github.com/HRex39/rtl8852be.git
# 内核大于等于5.18的
@@ -89,7 +89,7 @@ sudo modprobe 8852be
### 修复蓝牙驱动
```bash
```
# 内核=5.15
git clone https://github.com/HRex39/rtl8852be_bt.git -b 5.15
# 内核=5.18
@@ -104,13 +104,13 @@ sudo make install
首先去amd官网下载最新的linux-amd驱动
````bash
````
https://www.amd.com/zh-hans/support/linux-drivers // 22.20 for Ubuntu 20.04.5 HWE
````
修改Deepin为ubuntu
````bash
````
sudo vim /etc/os-release // ID=Deepin => ID=ubuntu
sudo apt install ./amdgpu-install_22.20.50200-1_all.deb
@@ -128,7 +128,7 @@ sudo apt install inxi clinfo
`inxi -G`
````bash
````
Graphics: Device-1: AMD Rembrandt driver: amdgpu v: kernel
Display: x11 server: X.Org 1.20.11 driver: amdgpu,ati unloaded: fbdev,modesetting,vesa
resolution: 1920x1080~60Hz
@@ -138,14 +138,14 @@ Graphics: Device-1: AMD Rembrandt driver: amdgpu v: kernel
最后还原最初的修改:
````bash
````
sudo vim /etc/os-release // ID=ubuntu => ID=Deepin
sudo apt purge amdgpu-install
````
看下效果图:
````bash
````
➜ ~ glxinfo -B
name of display: :0
display: :0 screen: 0
@@ -193,7 +193,7 @@ OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
安装下面的三方电源管理工具 `Boost Changer`,选择 `Performance`策略即可
````bash
````
wget https://github.com/nbebaw/boostchanger/releases/download/v4.4.0/boostchanger_4.4.0_amd64.deb
````
## 参考

View File

@@ -22,7 +22,7 @@ tags = ["乱七八糟"]
- **cn 域名有被停用的风险**。2008 年,有人以跳水奥运冠军吴敏霞拼音注册了 wuminxia.cn[结果被中国互联网络信息中心CNNIC回收了域名](https://www.cnbeta.com/articles/tech/62209.htm),并转交给国家体育总局。此域名在 2021 年 2 月 28 日被优视科技[注册](https://whois.cnnic.cn/WhoisServlet?queryType=Domain&domain=wuminxia.cn)呵呵。2009 年,牛博网被域名注册商万网停止解析。
## VPS
```bash
```
# 更新系统
apt update && apt upgrade -y
apt install wget curl vim sudo neofetch
@@ -33,15 +33,15 @@ sudo usermod -aG sudo xxx
## BBR
- 查询系统所支持的拥塞控制算法
````bash
````
sysctl net.ipv4.tcp_available_congestion_control
````
- 查询正在使用中的拥塞控制算法Linux 绝大部分系统默认为 Cubic 算法)
````bash
````
sysctl net.ipv4.tcp_congestion_control
````
- 指定拥塞控制算法为 bbr
````bash
````
echo net.ipv4.tcp_congestion_control=bbr >> /etc/sysctl.conf && sysctl -p
````
@@ -56,43 +56,43 @@ echo net.ipv4.tcp_congestion_control=bbr >> /etc/sysctl.conf && sysctl -p
打开SSH配置文件`sshd_config`可以使用文本编辑器如nano或vi。以下是使用nano编辑器的示例
````bash
````
sudo vim /etc/ssh/sshd_config
````
在配置文件中找到以下行:
````bash
````
Port 22
````
这是SSH默认的端口号你可以将其更改为你想要的任何未被占用的端口号。例如将端口更改为2222
````bash
````
Port 2222
````
保存并关闭文本编辑器。重新启动SSH服务以应用更改
````bash
````
sudo service ssh restart
````
或者如果你的系统使用systemd可以使用以下命令
````bash
````
sudo systemctl restart ssh
````
### 安装 UFW
````bash
````
sudo apt install ufw
````
**如果你在远程位置连接你的服务器,在启用 UFW 防火墙之前,你必须显式允许进来的 SSH 连接。否则,你将永远都无法连接到机器上。**
````bash
````
sudo ufw allow 22/tcp
````
@@ -100,37 +100,37 @@ sudo ufw allow 22/tcp
**启动 UFW**
````bash
````
sudo ufw enable
````
### 安装 Fail2ban
````bash
````
sudo apt-get install fail2ban
````
**2、Debian 12 及以上的版本需要手动安装 rsyslog**
````bash
````
sudo apt-get install rsyslog
````
**3、启动 Fail2ban 服务**
````bash
````
sudo systemctl start fail2ban
````
**4、开机自启动**
````bash
````
sudo systemctl enable fail2ban
````
**5、查看 Fail2ban 服务状态。**
````bash
````
sudo systemctl status fail2ban
````
@@ -139,7 +139,7 @@ sudo systemctl status fail2ban
### 改为密钥登录
- 执行以下命令生成.pub后缀的公钥和无后缀的密钥
```bash
```
ssh-keygen
```
注意不同密钥对名称不能相同;同时可以为这两个文件用密码加密;
@@ -147,11 +147,11 @@ ssh-keygen
- 随后将.pub后缀的公钥中的内容写入服务器的``~/.ssh/authorized_keys``中;
- 使用以下命令编译服务器的SSH配置
```bash
```
vim /etc/ssh/sshd_config
```
将其中的该行改为``PasswordAuthentication no``,保存退出;随后使用
```bash
```
sudo systemctl restart sshd
```
重启SSH即可禁用密码登录
@@ -159,7 +159,7 @@ sudo systemctl restart sshd
- 将**PermitRootLogin**一栏改为**PermitRootLogin prohibit-password**即可实现仅root用户密钥登录
- 使用以下命令查看输出,
```bash
```
sudo cat /etc/ssh/sshd_config | grep -E 'PasswordAuthentication|PubkeyAuthentication'
```
如有**PasswordAuthentication no → 禁用密码登录**以及**PubkeyAuthentication yes → 允许密钥登录**则成功。
@@ -170,33 +170,33 @@ sudo cat /etc/ssh/sshd_config | grep -E 'PasswordAuthentication|PubkeyAuthentica
- ALL
```bash
```
apt install curl wget gpg vim nano sudo neofetch openssh-server
```
- C/C++
```bash
```
sudo apt install build-essential gdb cmake clangd clang-format libstdc++-dev
```
- Miniconda
```bash
```
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
```
- UV
```bash
```
curl -LsSf https://astral.sh/uv/install.sh | sh
```
- Docker
```bash
```
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
```
- OpenCV
```bash
```
sudo apt install tree libx11-dev libgtk-3-dev freeglut3-dev libopencv-dev libdlib-dev
```
- Vmware
```bash
```
sudo apt install open-vm-tools
sudo apt install open-vm-tools-desktop
```
@@ -211,7 +211,7 @@ Set-Content "$env:USERPROFILE\.ssh\known_hosts"
执行如下命令一键安装 1Panel:
````bash
````
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sudo bash quick_start.sh
````
@@ -220,27 +220,27 @@ curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_
### 禁用 IPv6
手动 禁用 VPS 的 IPv6 命令:
```bash
```
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
```
如果想重启系统也生效, 执行:
```bash
```
echo 'net.ipv6.conf.all.disable_ipv6=1' >> /etc/sysctl.conf
echo 'net.ipv6.conf.default.disable_ipv6=1' >> /etc/sysctl.conf
```
手动 启用 VPS 的 IPv6 命令:
```bash
```
sysctl -w net.ipv6.conf.all.disable_ipv6=0
sysctl -w net.ipv6.conf.default.disable_ipv6=0
```
重新载入 sysctl 配置
```bash
```
sysctl --system # reload sysctl
```
如果重载, 还无效果, 可能要 reboot 重启下.
查看 VPS 的 IPv6 信息
```bash
```
ip -6 addr show scope global
或者 curl ipv6.ip.sb
@@ -253,13 +253,13 @@ ip -6 addr show scope global
- 然后在VPS上输入以下命令
```bash
```
mkdir -p ./.well-known/pki-validation
```
- 随后在ZeroSSL中将所给出的类似**B992F08CB46748D02E4C553A4038BC.txt**复制;
- 将从ZeroSSL下载得到的文件打开复制里面的东西形成以下的格式:``将pki-validation/之后EOF之前的内容``替换为你自己的。
```bash
```
cat << EOF | sudo tee ./.well-known/pki-validation/B992F08CB46748D02E4C553A4038BC.txt
254563C20918258D661E7D43D6A43A2A258857E191977DD5F740FBB9ABD25279
comodoca.com
@@ -268,7 +268,7 @@ EOF
```
随后在VPS上运行该命令。
- 开启一个临时HTTP服务器
```bash
```
python3 -m http.server 80
```
- 随后即可在ZeroSSL中验证证书并开启SSL。
@@ -285,15 +285,15 @@ python3 -m http.server 80
- 进入恢复模式后,选择`root Drop to root shell prompt`进入 root shell不需要密码
- 挂载文件系统为可写模式:
```bash
```
mount -o remount,rw /
```
- 将用户添加到 sudo 组:
```bash
```
usermod -aG sudo 用户名
```
- 重启计算机:
```bash
```
reboot
```
@@ -315,7 +315,7 @@ sudo apt update
```
3. 搜索可用内核
```bash
```
apt search xanmod
sudo apt install linux-image-6.8.6-x64v3-xanmod1 linux-headers-6.8.6-x64v3-xanmod1
```

View File

@@ -72,13 +72,13 @@ Hyper-V 是微软内建的虚拟化平台native hypervisor。开启后
* PowerShell以管理员权限运行
```bash
```
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
```
* DISM部署映像服务和管理工具
```bash
```
DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V
```
@@ -90,23 +90,23 @@ DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V
## 关闭 Hyper-V
* PowerShell管理员权限
```bash
```
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
```
* DISM
```bash
```
DISM /Online /Disable-Feature:Microsoft-Hyper-V
```
* 用 bcdedit 修改启动配置,使系统启动时不加载 HypervisorHyper-V 的虚拟化内核)但保留功能安装:
```bash
```
bcdedit /set hypervisorlaunchtype off
```
若要恢复加载,则:
```bash
```
bcdedit /set hypervisorlaunchtype auto
```
* Windows 功能 GUI 中,取消勾选 Hyper-V 相应项。
@@ -118,21 +118,21 @@ bcdedit /set hypervisorlaunchtype auto
1. **给 VMware 或 VirtualBox 使用环境临时关闭 Hyper-V**
```bash
```
bcdedit /set hypervisorlaunchtype off
```
然后重启 Windows就能让这些软件正常启动虚拟机。要还原 Hyper-V改为 `auto` 或 `on`:
```bash
```
bcdedit /set hypervisorlaunchtype auto
```
2. **从命令行完全关闭 Hyper-V 功能**
```bash
```powershell
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
```
或者用 DISM
```bash
```
DISM /Online /Disable-Feature:Microsoft-Hyper-V
```

View File

@@ -52,14 +52,14 @@ MCSManager 面板简称MCSM 面板)是一款全中文,轻量级,开
## 换源
**禁用 Ceph 企业仓库:**
```bash
```
nano /etc/apt/sources.list.d/ceph.list
```
将文件内容注释掉或删除。
**编辑仓库源文件:**
```bash
```
nano /etc/apt/sources.list.d/pve-enterprise.list
```
将文件内容注释掉或删除;
@@ -67,11 +67,11 @@ nano /etc/apt/sources.list.d/pve-enterprise.list
**启用社区仓库:**
确保社区仓库已启用。编辑社区仓库文件:
```bash
```
nano /etc/apt/sources.list.d/pve-no-subscription.list
```
确保文件内容如下:
```bash
```
deb http://download.proxmox.com/debian/pve bookworm pve-no-subscription
```
## 二.新建虚拟机并安装Debian
@@ -95,12 +95,12 @@ deb http://download.proxmox.com/debian/pve bookworm pve-no-subscription
在安装步骤进入到选择安装的桌面环境和软件时, 键入 Ctrl+Alt+F2 可以看到从图形界面转到了tty命令终端, 键入 Enter
这里修改软件源配置文件
```bash
```
nano /target/etc/apt/sources.list
```
修改debian-security源地址  `http://mirrors.ustc.edu.cn ` 目测最快
```bash
```
deb http://mirrors.ustc.edu.cn/debian-security bullseye-security main
```
修改后 Ctrl+X 退出保存,然后退出终端重新进入界面继续安装,键入 Ctrl+Alt+F5。
@@ -144,7 +144,7 @@ deb http://mirrors.ustc.edu.cn/debian-security bullseye-security main
在 PVE-防火墙中打开它们。如果还是不行,执行如下命令:
```bash
```
systemctl stop firewalld
systemctl disable firewalld

View File

@@ -79,7 +79,7 @@ X86还是Arm两者之间各有优点截止到今天各种Arm电视盒子
- 随后在设置 > 设备首选项 > 关于 > 状态中找到并记下IP 地址然后用ADB连接上去这里使用命令``adb connect <IP 地址>:<端口> ``随后在ATV端授权连接例如
```bash
```
adb connect 192.168.1.666:9527
connected to 192.168.1.666:9527
@@ -93,7 +93,7 @@ xxxxxxxxx sideload
**一些 ADB 常用命令**
```bash
```
adb reboot #将重启 Android 设备。
adb reboot recovery #将设备重新启动到恢复模式。
@@ -136,13 +136,13 @@ adb kill server #切断 PC 和 Android TV 之间的连接。
1. ADB连接连接到ADB成功后我们使用``adb shell``进入shell随后使用命令``pm list packages``列出所有软件包;
```bash
```
pm list packages -s 列出系统软件包
pm list packages -3 列出第三方软件包
```
2. 获取包名:对于暂时无法确定包名的软件,可以先打开,再使用
```bash
```
adb shell dumpsys activity activities | grep mResumedActivity
```
@@ -150,13 +150,13 @@ adb shell dumpsys activity activities | grep mResumedActivity
3. 删除软件:可以先使用
```bash
```
pm disable-user --user 0 com.dangbei1.tvlauncher
```
禁用软件,确认没有问题之后再用
```bash
```
pm uninstall -k --user 0 com.dangbei1.tvlauncher
```
@@ -164,20 +164,20 @@ pm uninstall -k --user 0 com.dangbei1.tvlauncher
4. 备份软件对于想要备份的软件可以使用1和2中的方法获取软件包名然后使用例如以下命令
```bash
```
adb shell pm path org.videolan.vlc
package:/data/app/~~hY2Y0_PdaDlasfVwkUNcoQ==/org.videolan.vlc-WnNhCJLQUJdZYYzUxzBNBA==/base.apk
```
获取到安装路径随后将apk包拿走就可以
```bash
```
adb pull /data/app/~~hY2Y0_PdaDlasfVwkUNcoQ==/org.videolan.vlc-WnNhCJLQUJdZYYzUxzBNBA==/base.apk ./Downloads/
```
5. 备份分区如果你想要修改当前系统的img可以用adb提取并导出
```bash
```
# 确定分区对应关系
ls -l /dev/block
ls -l /dev/block/platform
@@ -202,7 +202,7 @@ adb pull /sdcard/odm.img
```
5. 修改桌面可以进入安卓原生设置里面将默认主屏幕应用改为ATV代替掉自带的桌面,并使用
```bash
```
adb shell pm disable-user --user 0 com.google.android.tvlauncher
adb shell pm disable-user --user 0 com.google.android.tungsten.setupwraith
```

View File

@@ -140,12 +140,12 @@ tags = ["综合工程"]
**使用adb备份分区**
```bash
```
adb shell ls -l /dev/block/bootdevice/by-name
```
可以看到有很多分区,例如这些
```bash
```
...
lrwxrwxrwx 1 root root 15 1970-12-24 11:30 frp -> /dev/block/sda5
lrwxrwxrwx 1 root root 16 1970-12-24 11:30 fsc -> /dev/block/sdf13
@@ -156,14 +156,14 @@ lrwxrwxrwx 1 root root 16 1970-12-24 11:30 hyp_b -> /dev/block/sde40
```
随后使用root备份分区到手机上
```bash
```
adb root
adb shell "dd if=/dev/block/sda2 of=/sdcard/partition_backup/persist.img"
```
然后可以上传到PC端
```bash
```
adb pull /sdcard/partition_backup/ ./backup/
```

View File

@@ -31,7 +31,7 @@ tags = ["综合工程"]
随后安装常用开源软件(KDE环境省略file和wayland)
```bash
```
# gui
paru -S floorp-bin keepassxc qemu-full virt-manager materialgram-bin legcord-bin onlyoffice-bin localsend-bin kazumi-bin foliate vlc krita qtscrcpy strawberry oculante obs-studio
@@ -90,7 +90,7 @@ paru -S hyprland waybar wofi network-manager-applet swww wl-gammarelay-rs bright
输入法我们采用雾凇拼音即前面我们安装的fcitx5系列软件包的一个输入方案这里我们使用[自动部署脚本](https://github.com/Mark24Code/rime-auto-deploy)
```bash
```
# step1: 克隆/下载 latest 最新的稳定版到本地
git clone --depth=1 https://github.com/Mark24Code/rime-auto-deploy.git --branch latest
# step2: 进入项目目录
@@ -109,7 +109,7 @@ cd rime-auto-deploy
安装完毕后可以看到KDE的界面较为简陋这里给出笔者的美化配置
- 在设置中找到Colors&Themes分别设置为
```bash
```
- ColorBreeze Dark
- Application StyleBreeze
- Plasma StyleSweet
@@ -164,27 +164,27 @@ V2EX PolishV站美化
如果Grub引导菜单中没有windows选项可以通过以下方法添加
- 安装 os-prober首先确保系统中安装了 os-prober这是一个用于检测其他操作系统的工具。
```bash
```
sudo pacman -S os-prober
sudo os-prober
```
- 打开 /etc/default/grub 文件进行编辑:
```bash
```
sudo nano /etc/default/grub
# 确保 GRUB_DISABLE_OS_PROBER 设置为 false
```
- 保存文件并退出编辑器后,运行以下命令更新 GRUB 配置:
```bash
```
sudo grub-mkconfig -o /boot/grub/grub.cfg
```
或者``手动添加``
```bash
```
nano /etc/grub.d/40_custom
```
```bash
```
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
@@ -204,26 +204,26 @@ menuentry "Windows 11 (Manual)" {
如果virt-manager报错无法找到Qemu
- ​如果 libvirtd 服务未运行virt-manager 将无法连接到虚拟化环境。​
```bash
```
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
```
- 用户权限问题:​​将当前用户添加到 libvirt 组,以获得必要的权限。​
```bash
```
sudo usermod -aG libvirt $(whoami)
```
- 虚拟网络未激活virt-manager 可能无法连接到默认的虚拟网络。​
```bash
```
sudo virsh net-start default
```
默认网络在系统启动时自动启动,可以执行:
```bash
```
sudo virsh net-autostart default
```
- 配置文件权限问题:​配置文件的权限设置可能导致访问问题。
```bash
```
sudo chown $(whoami):libvirt /var/run/libvirt/libvirt-sock
```
随后安装虚拟机,流程大概为``选择镜像和系统类型--设置CPU/内存--设置空间大小--编辑配置项--开启UEFI引导和3D加速``.
@@ -231,7 +231,7 @@ sudo chown $(whoami):libvirt /var/run/libvirt/libvirt-sock
**开启3D加速**
- NIC
```xml
```
<graphics type="spice">
<listen type="none"/>
<image compression="off"/>
@@ -240,7 +240,7 @@ sudo chown $(whoami):libvirt /var/run/libvirt/libvirt-sock
```
- video virtio
```xml
```
<video>
<model type="virtio" heads="1" primary="yes">
<acceleration accel3d="yes"/>
@@ -255,17 +255,17 @@ sudo chown $(whoami):libvirt /var/run/libvirt/libvirt-sock
如果安装了多个linux内核可以使用以下方法调整启动顺序
- 使用以下命令查看内核名称:
```bash
```
ls /boot/vmlinuz*
```
- 在 /etc/default/grub 中添加或修改如下行:
```bash
```
GRUB_TOP_LEVEL="/boot/vmlinuz-linux-cachyos"
```
需要注意,这种方法会关闭 GRUB 的“记住上次启动项”的功能。
- 修改完 /etc/default/grub 后,记得重新生成 GRUB 配置文件:
```bash
```
sudo grub-mkconfig -o /boot/grub/grub.cfg
```
**图形界面更改方法:**
@@ -273,12 +273,12 @@ sudo grub-mkconfig -o /boot/grub/grub.cfg
可以使用grub-customizer来修改Grub这里以ubuntu为例子
- 添加PPA源并更新软件列表
```bash
```
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt update
```
- 安装GRUB Customizer
```bash
```
sudo apt install grub-customizer
```
随后在grub-customizer中将要默认启动的选项放在首位即可。
@@ -286,13 +286,13 @@ sudo apt install grub-customizer
## 开机自启动
**设置Syncthing开机自启动**
```bash
```
sudo systemctl enable --now syncthing@<username>.service
```
**设置Aria2开机自启动**
```conf
```
[Unit]
Description=Aria2c - lightweight multi-protocol & multi-source command-line download utility
After=network.target
@@ -315,41 +315,41 @@ WantedBy=multi-user.target
## 开启BBR
- 确保你的内核版本 >= 4.9
```bash
```
uname -r
```
- 启用 BBR
你只需要设置两个 sysctl 参数即可:
```bash
```
sudo sysctl -w net.core.default_qdisc=fq
sudo sysctl -w net.ipv4.tcp_congestion_control=bbr
```
要让它们永久生效,把它们写入配置文件:
```bash
```
sudo nano /etc/sysctl.d/99-bbr.conf
```
加入以下内容:
```bash
```
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
```
然后重新加载配置:
```bash
```
sudo sysctl --system
```
- 验证 BBR 是否启用
```bash
```
sysctl net.ipv4.tcp_congestion_control
```
应该输出:
```bash
```
net.ipv4.tcp_congestion_control = bbr
```
## 性能模式切换
需要安装``power-profiles-daemon``
```bash
```
# 查看可用的电源配置文件profiles
powerprofilesctl list
@@ -367,7 +367,7 @@ sudo powerprofilesctl set power-saver
```
## 其他性能优化
```bash
```
Profilesyncdaemon
将浏览器配置文件和缓存挂载到内存,退出时再写回磁盘:
@@ -395,7 +395,7 @@ sudo systemctl enable --now ananicy-cpp
## 常用命令
```bash
```
更新系统sudo pacman -Syu
重新安装所有软件包sudo pacman -Qq | sudo pacman -S -
@@ -426,28 +426,28 @@ sudo reflector --latest 10 --sort rate --save /etc/pacman.d/mirrorlist
## 在Arch Linux上安装Docker
一般推荐在qemu虚拟机中安装这里仅做示例
```bash
```
sudo pacman -S docker
```
安装完成后需要启动Docker服务并设置为开机自启
```bash
```
sudo systemctl start docker
sudo systemctl enable docker
```
运行以下命令来验证Docker是否正常工作
```bash
```
sudo docker run hello-world
```
默认情况下只有root用户才能运行Docker命令。为了避免每次运行Docker命令时都需要使用sudo可以将当前用户添加到docker组
```bash
```
sudo usermod -aG docker $USER
```
之后,需要注销并重新登录,或者重启系统以使更改生效。
安装Docker Compose
```bash
```
sudo pacman -S docker-compose
```
---

View File

@@ -129,7 +129,7 @@ uci commit luci
- **编译依赖**
```bash
```
sudo apt update
sudo apt install -y \
ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \
@@ -147,32 +147,32 @@ sudo apt install -y \
```
- **清理**
```bash
```
sudo apt autoremove --purge
sudo apt clean
```
- **新建一个用户,用于编译固件(可选)**
```bash
```
useradd -m openwrt # 新建一个名为 openwrt 的用户
```
> 不可以使用Root用户进行编译!!!
- **修改用户默认的 Shell**
```bash
```
apt install -y sudo
usermod -s /bin/bash openwrt
```
- **切换用户**
```bash
```
su openwrt
cd ~
```
- **拉取源码,这里用的是 ImmortalWrt 24.10 分支源码:**
```bash
```
git clone https://github.com/immortalwrt/immortalwrt.git
cd immortalwrt
```
@@ -180,11 +180,11 @@ cd immortalwrt
- **选择分支**
如果你想要编译稳定版(stable),使用
```bash
```
git checkout xxx #例如git checkout v24.10.2
```
如果你想要编译最新版(snapshot),使用
```bash
```
git switch xxx #例如git switch openwrt-24.10
```
@@ -211,19 +211,19 @@ git switch xxx #例如git switch openwrt-24.10
- **添加软件源,可自行添加软件源至 feeds.conf.default 文件**
```bash
```
vim feeds.conf.default
```
**常用源**
```bash
```
src-git kenzo https://github.com/kenzok8/openwrt-packages
src-git small https://github.com/kenzok8/small
src-git haibo https://github.com/haiibo/openwrt-packages
src-git liuran001 https://github.com/liuran001/openwrt-packages
```
**常用仓库**
```bash
```
src/gz kwrt_core https://dl.openwrt.ai/releases/24.10/targets/x86/64/6.6.83
src/gz kwrt_base https://dl.openwrt.ai/releases/24.10/packages/x86_64/base
src/gz kwrt_packages https://dl.openwrt.ai/releases/24.10/packages/x86_64/packages
@@ -234,12 +234,12 @@ src/gz kwrt_kiddin9 https://dl.openwrt.ai/releases/24.10/packages/x86_64/kiddin9
- **单独添加**(在更新并安装插件之前执行)例如:
```bash
```
git clone https://github.com/chenmozhijin/turboacc.git
```
- **更新并安装插件**
```bash
```
./scripts/feeds clean
./scripts/feeds update -a
./scripts/feeds install -a
@@ -251,7 +251,7 @@ git clone https://github.com/chenmozhijin/turboacc.git
- **自定义配置**
```bash
```
#!/usr/bin/env bash
# diy-part2.sh — 在镜像生成时注入默认设置和定制 SSH 横幅及模型修复
@@ -319,7 +319,7 @@ chmod +x package/base-files/files/etc/uci-defaults/99-model-fix
### **编译配置菜单说明(部分)**
```bash
```
Target System (x86) # 选择目标平台
└── Subtarget (x86_64) # 选择 64-bit 子架构
└── Target Profile (Generic) # “Generic” 表示通用 x86_64 设备
@@ -369,21 +369,21 @@ Xorg # 桌面环境支持X11 图形系统)
```
- **预下载编译所需的软件包**
```bash
```
make download -j8
```
- **检查文件完整性**
```bash
```
find dl -size -1024c -exec ls -l {} \;
```
检查文件完整性命令可以列出下载不完整的文件小于1k的文件属于下载不完整如果存在则用下面的命令删除然后重新下载编译所需的软件包再次检查.确认所有文件完整可大大提高编译成功率,避免浪费时间
```bash
```
find dl -size -1024c -exec rm -f {} \;
```
- **最后编译固件(-j 后面是线程数首次编译推荐用单线程编译完成后输出路径是bin/targets.**
```bash
```
make V=s -j1
或者使用 make world -j1 V=s 2>&1 | tee world_debug.log
@@ -411,7 +411,7 @@ make V=s -j1
| `make distclean` | 删除 `make dirclean` 的所有内容 + feeds 下载文件 + `.config`、patch 等所有状态 | 只有源码目录保持不变 | 专用于回到一个“零配置、重做一切”的状态,完全从头开始构建。 |
恢复所有修改(包括未跟踪文件):
```bash
```
git clean -fd
git restore --source=v24.10.2 --staged --worktree .
```
@@ -437,26 +437,26 @@ git restore --source=v24.10.2 --staged --worktree .
要启用的软件包:
**base**
```bash
```
autocore base-files bash block-mount ca-bundle coremark curl dnsmasq-full dropbear ds-lite e2fsprogs fdisk firewall4 fstools grub2-bios-setup htop kmod-8139cp kmod-8139too kmod-amazon-ena kmod-amd-xgbe kmod-atlantic kmod-bnx2 kmod-bnx2x kmod-button-hotplug kmod-drm-amdgpu kmod-drm-i915 kmod-dwmac-intel kmod-e1000 kmod-e1000e kmod-forcedeth kmod-fs-f2fs kmod-fs-vfat kmod-i40e kmod-iavf kmod-igb kmod-igbvf kmod-igc kmod-ixgbe kmod-ixgbevf kmod-lib-zstd kmod-mlx4-core kmod-mlx5-core kmod-mmc kmod-pcnet32 kmod-phy-broadcom kmod-r8101 kmod-r8125 kmod-r8126 kmod-r8168 kmod-sdhci kmod-tcp-bbr kmod-tg3 kmod-tulip kmod-usb-hid kmod-vmxnet3 libc libgcc libustream-mbedtls lm-sensors-detect logd lsblk luci-app-fan luci-app-filemanager luci-app-firewall luci-app-log-viewer luci-app-package-manager luci-app-syscontrol luci-app-upnp luci-base luci-compat luci-lib-fs luci-lib-ipkg mkf2fs mtd nano netifd odhcp6c odhcpd-ipv6only openssh-sftp-server opkg partx-utils pciutils ppp ppp-mod-pppoe resolveip swconfig uci uclient-fetch urandom-seed urngd usbutils wget-ssl zram-swap
```
**cli**
```bash
```
btop iperf3 tcpdump
```
**luci**
```bash
```
luci-app-argon luci-app-upnp luci-app-ttyd luci-app-eqosplus luci-app-timecontrol luci-app-parentcontrol luci-app-homeproxy luci-app-daed
```
**lib**
```bash
```
kmod-ipt-conntrack kmod-ipt-nat kmod-nft-compat kmod-ipt-fullconenat kmod-ip6tables ca-certificates
```
## 使用SDK快速编译包
首先新建一个文件夹并将SDK克隆下来
```bash
```
mkdir imwrt-sdk
cd ./imwrt-sdk
wget https://downloads.immortalwrt.org/snapshots/targets/mediatek/filogic/immortalwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64.tar.zst
@@ -464,13 +464,13 @@ wget https://downloads.immortalwrt.org/snapshots/targets/mediatek/filogic/immort
新版本的SDK使用ZSTD压缩因此解压的命令为
```bash
```
tar -I zstd -xvf ./immortalwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64.tar.zst
```
随后进入该目录并和一般流程一样更新Feeds
```bash
```
cd ./immortalwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/
./scripts/feeds update -a
./scripts/feeds install -a
@@ -478,7 +478,7 @@ cd ./immortalwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/
更新完成后克隆你要编译的包的源码到package下
```bash
```
cd ./package/
git clone https://github.com/Dichgrem/luci-app-nyn.git
cp ./luci-app-nyn/luci-app-zzz ./
@@ -489,7 +489,7 @@ cd ../
随后开始编译编译结果在对应架构的base目录下
```bash
```
make package/luci-app-zzz/compile V=s
~/imwrt-sdk/immortalwrt-sdk-24.10.3-x86-64_gcc-13.3.0_musl.Linux-x86_64 dich@uos
@@ -497,19 +497,16 @@ make package/luci-app-zzz/compile V=s
./bin/packages/x86_64/base/zzz_0.1.1-r1_x86_64.ipk
```
## 常用命令
> 注意不能升级kmod前缀的软件包base-files是危险包谨慎升级
```bash
## 常用命令:
```
# 更新软件列表
opkg update
# 列出可升级的非内核包
opkg list-upgradable | grep -vE '^(kmod-|kernel)'
# 更新所有 LUCI 插件
opkg list-upgradable | grep luci- | cut -f 1 -d ' ' | xargs opkg upgrade
# 升级单个软件包
opkg upgrade 包名
# 如果要更新所有软件,包括 OpenWRT 内核、固件等
opkg list-upgradable | cut -f 1 -d ' ' | xargs opkg upgrade
# 固件版本号
vim /etc/os-release

View File

@@ -28,21 +28,21 @@ Waydroid是Anbox配合Halium技术开发的LXC Android容器可在GNU/Linux
目前Waydroid只支持Intel和AMD的显卡对于 NVIDIA 显卡(除 Tegra 系列外Waydroid 不支持硬件加速推荐使用软件渲染或QEMU方案。
- Waydroid必须使用Wayland用此命令检查当前系统是否为Wayland
```bash
```
echo $XDG_SESSION_TYPE
```
若显示X11代表不是Wayland。GNOME和KDE可在登入画面切换至Wayland工作阶段。
- Waydroid要求Linux核心支持binder核心模组但Arch Linux预设的linux核心並无开启此选项因此需要从AUR安装binder_linux-dkms补齐。
```bash
```
paru -S binder_linux-dkms
```
- 安装后载入binder核心模组
```bash
```
sudo modprobe binder-linux devices=binder,hwbinder,vndbinder
```
- 设定开机自动载入核心模组
```bash
```
echo "binder_linux" | sudo tee -a /etc/modules-load.d/binder_linux.conf
echo "options binder_linux devices=binder,hwbinder,vndbinder" | sudo tee -a /etc/modprobe.d/binder_linux.conf
@@ -51,36 +51,36 @@ echo "options binder_linux devices=binder,hwbinder,vndbinder" | sudo tee -a /etc
## 安装Waydroid
- 安装以下软件包让Linux与Waydroid共享剪切板
```bash
```
paru -S wl-clipboard xclip
paru -S python-pyclip
```
- 安装Waydroid
```bash
```
paru -S waydroid
```
- 初始化Waydroid下载含有GAPPS的Android系统映像档
```bash
```
sudo waydroid init -s GAPPS -f
```
- 启动Waydroid容器服务
```bash
```
sudo systemctl start waydroid-container
```
## 常用命令
- 开机自动启动
```bash
```
sudo systemctl enable waydroid-container
```
- 点选应用列表的「Waydroid」图示开启主画面或者使用命令
```bash
```
waydroid show-full-ui
```
- 若Waydroid无法连上网路开放UFW防火墙
```bash
```
sudo ufw allow 53
sudo ufw allow 67
sudo ufw default allow FORWARD
@@ -88,21 +88,21 @@ sudo ufw reload
sudo systemctl restart waydroid-container
```
- 重启Waydroid
```bash
```
sudo systemctl restart waydroid-container
```
- 启动/停止Waydroid容器服务
```bash
```
sudo systemctl start waydroid-container
sudo systemctl stop waydroid-container
```
- 用命令开启Waydroid主画面
```bash
```
waydroid show-full-ui
```
- 查看系统错误讯息
```bash
```
waydroid log
sudo waydroid logcat
```
@@ -116,35 +116,35 @@ sudo waydroid logcat
安装Package Manager用於查看APP的软件包名称。
部份APP会要求开启Wifi才能上网那么就如它所愿开启fake wifi
```bash
```
waydroid prop set persist.waydroid.fake_wifi "软件包名称"
```
例如给Fate/Go游戏开启模拟Wifi
```bash
```
waydroid prop set persist.waydroid.fake_wifi "com.aniplex.fategrandorder"
```
- 模拟触控功能
安装Package Manager用於查看APP的软件包名称。有些APP认不到鼠标点击需要启用模拟触控(fake touch)
```bash
```
waydroid prop set persist.waydroid.fake_touch "软件包名称"
```
例如给Fate/Go游戏开启模拟触控
```bash
```
waydroid prop set persist.waydroid.fake_touch "com.aniplex.fategrandorder"
```
- 用命令安装APK
```bash
```
waydroid app install <APK档案路径>.apk
```
- 进入ADB Shell
```bash
```
sudo waydroid shell
```
- 开启多视窗模式
Waydroid的多视窗模式看起来像Linux的原生应用。启动后按F11改回来。
```bash
```
waydroid prop set persist.waydroid.multi_windows true
sudo systemctl restart waydroid-container
```
@@ -154,13 +154,13 @@ sudo systemctl restart waydroid-container
Waydroid第一次开机可能会收到``Device is not Play Protect certified``的通知无法登入Google账号。
用以下命令取得Waydroid的装置ID。该命令会印出一长串数字。
```bash
```
sudo waydroid shell
ANDROID_RUNTIME_ROOT=/apex/com.android.runtime ANDROID_DATA=/data ANDROID_TZDATA_ROOT=/apex/com.android.tzdata ANDROID_I18N_ROOT=/apex/com.android.i18n sqlite3 /data/data/com.google.android.gsf/databases/gservices.db "select * from main where name = \"android_id\";"
```
开启装置注册页面登入Google账号输入装置ID注册等个半小时应该就能登入Google账号了。如果还是不行就重新启动Waydroid容器服务
```bash
```
sudo systemctl restart waydroid-container
```
现在可以安装APP了Google Play和F-Droid会自动筛出適合x86架构的APP。
@@ -267,18 +267,18 @@ ReDroidRemote-Android是一款开源的容器化 Android 解决方案,
## 日常使用
- **ADB 连接与屏幕镜像**
```bash
adb connect localhost:5555
scrcpy -s localhost:5555 --audio-codec=aac
```
```bash
adb connect localhost:5555
scrcpy -s localhost:5555 --audio-codec=aac
```
- **安装 APK**
- 使用 `adb install your_app.apk`
- 或在 Scrcpy 界面中拖拽 APK 文件进行安装
- **停止与重启**
```bash
sudo docker compose down
sudo docker compose up -d
```
```bash
sudo docker compose down
sudo docker compose up -d
```
- **数据持久化**:所有数据保存在 `~/redroid/redroid-11-data`,可备份或运行多实例。
## 高级操作与安全建议

View File

@@ -211,7 +211,7 @@ Linux 的权限可以简单理解为``UGO+RWX``.
- Linux命令查询[linux-command](https://wangchujiang.com/linux-command/hot.html)
- Linux常用命令表[Quick Reference](https://wangchujiang.com/reference/docs/linux-command.html)
```bash
```
date
Sun Nov 16 09:16:15 PM +08 2025
uname -a
@@ -243,7 +243,7 @@ which ls
- 在一些精简 Linux例如 Alpine、OpenWrt中命令不来自 GNU coreutils而来自一个叫 **BusyBox** 的单程序。BusyBox 只一个二进制文件,但内部包含了上百个命令,这种方式体积小,适用于嵌入式设备。
```bash
```
/bin/busybox ls
/bin/busybox cp
/bin/busybox tar

View File

@@ -15,7 +15,7 @@ tags = ["Linux"]
- **Ubuntu**
以ubuntu24.04为例,首先安装这些包,包括连接工具,工具链和调试器等等。
```bash
```shell
sudo apt update
sudo apt install -y git python3 scons openocd stlink-tools gcc-arm-none-eabi gdb-multiarch
```
@@ -58,7 +58,7 @@ sudo apt install -y git python3 scons openocd stlink-tools gcc-arm-none-eabi gdb
随后使用Git拉取项目源码
```bash
```shell
git clone https://github.com/RT-Thread-Studio/sdk-bsp-stm32f407-spark.git
```
@@ -66,7 +66,7 @@ git clone https://github.com/RT-Thread-Studio/sdk-bsp-stm32f407-spark.git
使用Git拉取RT-Thread配套的linux开发环境并添加Shell变量。
```bash
```shell
# 克隆仓库
git clone https://github.com/RT-Thread/env.git ~/env
# 将 ~/env 添加到 PATH
@@ -79,7 +79,7 @@ type pkgs
随后可以使用PKG初始化并安装两个必要的包
```bash
```shell
pkgs --update
pip install kconfiglib
pip install scons
@@ -88,14 +88,14 @@ pip install scons
## 连接
使用USB线连接开发板和开发PC并使用lsusb命令查看是否出现
```bash
```shell
lsusb
Bus 001 Device 004: ID 0483:374b STMicroelectronics ST-LINK/V2.1
```
添加成功后可以使用这个命令来检测是否连接成功:
```bash
```shell
st-info --probe
Found 1 stlink programmers
version: V2J35S26
@@ -149,11 +149,11 @@ elif CROSS_TOOL == 'llvm-arm':
## 编译
在完成以上设置之后我们可以开始编译。STM32使用scons编译系统同样是menuconfig命令
```bash
```shell
scons --menuconfig
```
修改配置并保存退出后即可开始编译,$(nproc)代表使用全部CPU线程来编译
```bash
```shell
scons -j$(nproc)
```
@@ -163,18 +163,18 @@ scons -j$(nproc)
在烧入之前,我们可以备份一下原来的系统:
```bash
```shell
st-flash read firmware_backup.bin 0x08000000 0x100001
```
随后使用如下命令烧入系统:
```bash
```shell
st-flash write rtthread.bin 0x08000000
```
## 串口
除了USB之外我们还可以使用串口连接
```bash
```shell
sudo apt install picocom
picocom -b 115200 /dev/ttyACM0
```

View File

@@ -98,7 +98,7 @@ Java : JRE 17.0.16+8
## Key方案
构建Release包需要密钥签名验证可以使用传统的环境变量配置或者使用密钥管理器.
构建Release包需要密钥签名验证可以使用传统的明文配置或者使用密钥管理器.
### 相同部分
@@ -113,7 +113,7 @@ keytool -genkey -v \
```
- 修改app/build.gradle.kts
```java
```bash
signingConfigs {
create("release") {
storeFile = System.getenv("KEYSTORE_FILE")?.let { file(it) }

View File

@@ -13,11 +13,11 @@ tags = ["Windows"]
开机之前先断网然后输入Shift+F10会弹出命令行界面并输入
``bash
``
oobe\BypassNRO.cmd
``
回车之后会重启,之后就可以跳过联网了,选择
``bash
``
I don't have internet
``
即可。
@@ -36,7 +36,7 @@ I don't have internet
## 激活windows
这里使用MAS的脚本:
```bash
```
irm https://get.activated.win | iex
```
@@ -48,7 +48,7 @@ irm https://get.activated.win | iex
3.然后就可以使用脚本彻底关闭更新:将以下命令保存为.bat文件运行即可。
```bat
```
::Windows auomatic updates
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v AutoInstallMinorUpdates /t REG_DWORD /d 1 /f
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v NoAutoUpdate /t REG_DWORD /d 1 /f
@@ -71,7 +71,7 @@ reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings /v Pause
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings /v PauseQualityUpdatesEndTime /t REG_SZ /d "2100-01-01T00:00:00Z" /f
```
如果要恢复更新,使用以下命令,同样保存为.bat运行
```bat
```
::Windows auomatic updates
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v AutoInstallMinorUpdates /t REG_DWORD /d 0 /f
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v NoAutoUpdate /t REG_DWORD /d 0 /f
@@ -103,17 +103,17 @@ Win11的`显示更多选项`的二级菜单过于繁琐,怎么设置才能将
**步骤2.** 输入以下命令并按**Enter**键执行。
```bash
```
reg add HKCU\Software\Classes\CLSID{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32 /ve /d “” /f
```
或者
```bash
```
reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve
taskkill /f /im explorer.exe
start explorer.exe
```
如果想要重新打开Win11新样式的右键菜单的话以同样的方式在命令提示符中执行此命令
```bash
```
reg delete "HKCU\Software\Classes\CLSID{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" /f
```
## Win11关闭 Windows Defender
@@ -151,7 +151,7 @@ pool.ntp.org一个公共的 NTP 时间服务器池)
应用更改:点击 "更新现在",然后 "确定" 保存设置。
- 如果有linux/win双系统可以让 Windows 使用 UTC 作为硬件时钟时间:
```bash
```
# 在 Windows 中以管理员权限运行命令提示符,执行:
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation" /v RealTimeIsUniversal /t REG_DWORD /d 1 /f
```
@@ -159,11 +159,11 @@ reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation
## 调整网络优先级
- 查看当前优先级PowerShell/管理员)
```bash
```
Get-NetIPInterface
```
你会看到类似:
```bash
```
IfIndex InterfaceMetric InterfaceAlias
------- -------------- --------------
15 25 Wi-Fi
@@ -174,15 +174,15 @@ IfIndex InterfaceMetric InterfaceAlias
- 修改网络优先级
将有线网络(以太网) 设为更高优先级(值更小):
```bash
```
Set-NetIPInterface -InterfaceIndex 3 -InterfaceMetric 10
```
- 将 WiFi 设为更低优先级:
```bash
```
Set-NetIPInterface -InterfaceIndex 15 -InterfaceMetric 25
```
- 重启网络
```bash
```
Restart-NetAdapter -Name "以太网"
```
这样当网线插入时Windows 会优先使用有线网络;断开网线后,自动切换到 WiFi。
@@ -191,7 +191,7 @@ Restart-NetAdapter -Name "以太网"
- 如需永久设置,可修改注册表:
Win + R 输入 regedit 打开注册表编辑器,进入路径:
```bash
```
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces
```
在 Interfaces 里找到你的有线网卡和无线网卡(可以根据 IP 或 MAC 地址确认)。
@@ -207,7 +207,7 @@ HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces
> 保存为.bat格式
```bat
```
@echo off
REM 清理代理设置
REG DELETE "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /f
@@ -219,7 +219,7 @@ echo 代理设置已清除
> 保存为.reg格式
开启3D加速
```bat
```
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectDraw]
"EmulationOnly"=dword:00000000
@@ -232,7 +232,7 @@ Windows Registry Editor Version 5.00
```
关闭3D加速
```bat
```
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectDraw]
"EmulationOnly"=dword:00000001

View File

@@ -28,7 +28,7 @@ Python是一种跨平台的编程语言,社区生态丰富,有许多现成的
安装好了Anaconda就相当于同时有了Python、环境管理器、包管理器以及一大堆开箱即用的科学计算工具包。
> linux中安装Miniconda
```bash
```
# Miniconda安装脚本
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
# 执行以下命令启动安装程序:
@@ -40,39 +40,39 @@ conda --version
## 使用
- 创建环境后面的python=3.6是指定python的版本
```bash
```
conda create --name env_name python=3.6
```
- 创建包含某些包的环境(也可以加上版本信息)
```bash
```
conda create --name env_name python=3.7 numpy scrapy
```
- 激活某个环境
```bash
```
conda activate env_name
```
- 关闭某个环境
```bash
```
conda deactivate env_name
```
- 复制某个环境
```bash
```
conda create --name new_env_name --clone old_env_name
```
- 删除某个环境
```bash
```
conda remove --name env_name --all
```
- 生成需要分享环境的yml文件需要在虚拟环境中执行
```bash
```
conda env export > environment.yml
```
- 在本地使用yml文件创建虚拟环境
```bash
```
conda env create -f environment.yml
```
- 列出本机的所有环境如下可见当前有2个环境当前激活的是test环境
```bash
```
(test) ➜ ~ conda info -e
- conda environments:
#
@@ -83,47 +83,47 @@ test * /Volumes/300g/opt/anaconda3/envs/test
### 包管理
- 列出当前环境下所有安装的包
```bash
```
conda list
```
- 列举一个指定环境下的所有包
```bash
```
conda list -n env_name
```
- 查询库
```bash
```
conda search scrapys
```
- 安装库安装时可以指定版本例如scrapy=1.5.0
```bash
```
conda install scrapy
```
- 为指定环境安装某个包
```bash
```
conda install --name target_env_name package_name
```
- 更新安装的库
```bash
```
conda update scrapy
```
- 更新指定环境某个包
```bash
```
conda update -n target_env_name package_name
```
- 更新所有包
```bash
```
conda update --all
```
- 删除已经安装的库
```bash
```
conda remove scrapy
```
- 删除指定环境某个包
```bash
```
conda remove -n target_env_name package_name
```
- 更多命令请查看官方文档或者查询帮助命令:
```bash
```
conda --help
conda install --help
@@ -134,11 +134,11 @@ conda install --help
安装Anaconda并启动一个环境之后如何让Jupyter Notebook在我们要的环境中启动呢
- 安装jupyter
```bash
```
conda install jupyter notebook
```
- 配置虚拟机中允许宿主机访问
```bash
```
# 生成配置
jupyter notebook --generate-config
# 编辑配置
@@ -155,20 +155,20 @@ jupyter notebook
为了让 Jupyter Notebook 能识别该环境中的 Python 解释器,你需要在该环境中安装 ipykernel
```bash
```
conda install ipykernel
```
- 注册环境内核
将该环境注册为 Jupyter 的一个内核kernel这样启动 Jupyter Notebook 后就能选择这个内核:
```bash
```
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
```
这里 --name 指定内核的名称,--display-name 是在 Jupyter Notebook 界面中显示的名称,你可以根据需要自定义。
- 启动 Jupyter Notebook依然在激活后的环境中启动 Jupyter Notebook启动后你在新建 notebook 时可以选择刚刚注册的内核 “Python (myenv)” 来确保使用该环境的 Python 解释器。
```bash
```
jupyter notebook
```
@@ -176,7 +176,7 @@ jupyter notebook
Jupyter Notebook 本身没有官方语言包,但可以用第三方扩展 ``jupyter_contrib_nbextensions``和``notebook-translation``来实现部分汉化
```bash
```
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
pip install jupyter-notebook-translation
@@ -265,12 +265,6 @@ uv pip list # 列出已安装包
uv pip uninstall numpy
```
- 更新UV自身
```bash
uv self update
```
---
### 替代常见 Conda 工作流
@@ -288,12 +282,12 @@ uv self update
## ipynb转markdown
首先安装 nbformat 和 nbconvert包
```bash
```
conda install nbformat nbconvert -y
touch ipynb2md.py && nano ipynb2md.py
```
写入以下脚本:
```python
```
import nbformat
from nbconvert import MarkdownExporter
from pathlib import Path
@@ -325,7 +319,7 @@ if __name__ == "__main__":
batch_convert(input_dir=".")
```
运行脚本:
```bash
```
python ipynb2md.py
```
脚本会自动扫描当前目录下的所有 .ipynb 文件,并把 .md 文件输出到 markdown_output/ 文件夹。

View File

@@ -44,7 +44,7 @@ tags = ["Windows"]
## 配置JSON
- 回到 Visual Studio Code 继续配置。点击左侧的资源管理器,点击打开文件夹,创建一个``.cpp``文件,里面代码可以是
```bash
```
#include <iostream>
int main() {

133
public/404.html Normal file
View File

@@ -0,0 +1,133 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>
404 | Dich&#x27;s Blog
</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="Page not found">
<meta property="og:description" content="Page not found">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="website">
<meta property="og:url" content="https://blog.dich.bid">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="Page not found">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post">
<h1 class="post-title">Lost?</h1>
<p>This page does not exist.</p>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,224 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-2024/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-2024/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-2024/">乱七八糟:2024年度总结</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2025-01-04
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 又是新的一年,时间流速感觉越来越快了。</p>
<span id="continue-reading"></span><h2 id="da-shi-ji">大事记</h2>
<ul>
<li>六月份暑假将家里大翻新,包括水晶头,吊灯,门锁,水龙头等等;</li>
<li>买了新柜子,房间更有序了;</li>
<li>和朋友们聚餐;</li>
<li>采用Mesh进行家庭组网</li>
<li>安装了一盏太阳能路灯,院子里更明亮了;</li>
<li>和父母看电影;</li>
<li>将博客迁移到新平台用上亚马逊CDN</li>
<li>更换域名,不再续费 .ink;</li>
<li>使用国家补贴更换电脑,换掉了故障百出的机械革命;</li>
<li>办理校园网套餐并注销掉旧的电话卡;</li>
<li>买了一台AX3000路由器并刷成openwrt绕过校园网检测</li>
<li>开了azure虚拟机并研究</li>
<li>卖掉了chromebook</li>
<li>配置了Qemu虚拟机</li>
<li>给父母加装了流量包;</li>
<li>更换了鼠标,并买了显示器和沙发椅;</li>
<li>家里更换新热水器;</li>
<li>修理亲戚家的网络问题;</li>
<li>在学校和家里两处配备常用药箱;</li>
<li>将所有设备更换为typec接口</li>
<li>整理并精简了RSS订阅源</li>
<li>重构了书签结构,增加用途分类;</li>
<li>用上了Android 15并使用多种开源软件</li>
<li>研究不同的root方案并完美隐藏环境</li>
<li>自制养生茶,咖啡和燕麦粥;</li>
<li>养成跑步习惯;</li>
<li>使用Deepl api进行翻译学习</li>
<li>看Netflix并研究浏览器环境检测</li>
<li>搭建Syncthing同步服务器实现三端同步</li>
<li>定时备份重要数据;</li>
<li>学习英语纪录片,每天背单词;</li>
</ul>
<h2 id="cheng-chang-yu-fan-si">成长与反思</h2>
<ul>
<li>谋定而后动,不要冲动消费;</li>
<li>实践出真知,不要轻易下定论;</li>
<li>适合自己的才是最好的;</li>
<li>锻炼自身,早点睡觉,饮食规律是最好的养生;</li>
</ul>
<h2 id="xin-de-yi-nian-de-mu-biao">新的一年的目标</h2>
<ul>
<li>在各大SRC平台挖点漏洞</li>
<li>封装一个完美的windows系统用于对外使用</li>
<li>研究并总结各大代理技术;</li>
<li>重构家庭数据中心;</li>
<li>学习一门新的语言并熟悉一种业务;</li>
<li>控制体重并研究低成本健身;</li>
</ul>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/about-virtual/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">乱七八糟:虚拟化常用设置与操作</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/network-homenet-1/">
<span class="button__text">家庭组网系列(1):方案与设备选购</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,273 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-accurate-pronunciation/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-accurate-pronunciation/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-accurate-pronunciation/">乱七八糟:常见发音错误术语集合</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2023-08-25
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 中文和英语发音习惯不同,容易引起误解。本文旨在帮助您准确发音常见的科技术语,欢迎随时补充。</p>
<span id="continue-reading"></span>
<p><strong>常见发音错误指南:公司/产品名</strong></p>
<ul>
<li>
<p>Youtube: 正确念法是 "You-tube" [tju:b],而不是 "优吐毙",应该是 "优tiu啵"。</p>
</li>
<li>
<p>Skype: 应该念为 [ˈskaɪp],而不是 "死盖屁",应该是 "死盖破"。</p>
</li>
<li>
<p>Adobe: 正确的发音是 [əˈdəʊbi],不是 "阿斗伯",而是 "阿兜笔"。</p>
</li>
<li>
<p>C#: 应该念为 "C Sharp",即"C煞破"。</p>
</li>
<li>
<p>GNU: 正确的发音是 [(g)nuː] 即"哥怒"。</p>
</li>
<li>
<p>GUI: 应该念为 [ˈɡui],即"故意"。</p>
</li>
<li>
<p>JAVA: 正确的发音是 [ˈɑːvə],而不是 "夹蛙",应该是 "扎蛙"。</p>
</li>
<li>
<p>AJAX: 应该念为 [ˈeɪdʒæks],而不是 "阿贾克斯",应该是 "诶(ei) 贾克斯"。</p>
</li>
<li>
<p>Ubuntu: 正确的发音是 [uˈbuntuː],而不是 "友邦兔",应该是 "巫不恩兔"。</p>
</li>
<li>
<p>Debian: 应该念为 [ˈdɛbiən],即"得(dei)变"。</p>
</li>
<li>
<p>Linux: 正确的发音有两种,[ˈlɪnəks] 或 [ˈlɪnʊks]"丽娜克斯" 或 "李扭克斯"都可以。</p>
</li>
<li>
<p>LaTeX: 正确的发音是 [ˈleɪtɛk] 或 [ˈleɪtɛx] 或 [ˈlɑːtɛx] 或 [ˈlɑːtɛk],即"雷泰克" 或 "拉泰克"。</p>
</li>
<li>
<p>GNOME: 念法可以是 [ɡˈnoʊm] 或 [noʊm],即"格弄姆" 或 "弄姆"。</p>
</li>
<li>
<p>App: 应该念为 [ˈæp],即 "阿破"。</p>
</li>
<li>
<p>null: 正确的发音是 [nʌl],即"闹"。</p>
</li>
<li>
<p>jpg: 应该念为 [ˈdʒeɪɡ],而不是 "勾屁记",应该是 "zhei派个"。</p>
</li>
<li>
<p>WiFi: 正确的发音是 [ˈwaɪfaɪ],即"歪fai"。</p>
</li>
<li>
<p>mobile: 念法可以是 [moˈbil] 或 [ˈmoˌbil] 或 [ˈməubail],即"膜拜哦" 或 "牟bou"。</p>
</li>
<li>
<p>integer: 正确的发音是 [ˈɪntɪdʒə],而不是 "阴太阁儿",应该是 "音剃摺儿"。</p>
</li>
<li>
<p>cache: 应该念为 [kæʃ],而不是 "卡尺",即"喀什"。</p>
</li>
<li>
<p>@: 应该念为 "at"。</p>
</li>
<li>
<p>Tumblr: 应该念为 "Tumbler",而不是 "贪不勒"。</p>
</li>
<li>
<p>nginx: 正确的发音是 "Engine X",应该是 "恩静 爱克斯"。</p>
</li>
<li>
<p>Apache: 应该念为 [əˈpætʃiː],即"阿趴气"。</p>
</li>
<li>
<p>Lucene: 正确的发音是 [ˈluːsin],即"鲁信"。</p>
</li>
<li>
<p>MySQL: 应该念为 [maɪ ˌɛskjuːˈɛl] 或 [maɪ ˈsiːkwəl],可以是 "买S奎儿" 或 "买 吸扣"。</p>
</li>
<li>
<p>Exposé: 念法可以是 [ɛksˈpəʊzeɪ]重音在Z上。</p>
</li>
<li>
<p>RFID: 官方念法是四个字母分开读 "R F I D"。</p>
</li>
<li>
<p>JSON: 应该念为 "jason",即"zhei森"。</p>
</li>
<li>
<p>Processing: 重音在 "Pro" 上。</p>
</li>
<li>
<p>avatar: 正确的发音是 [ˌævə'tɑr],即"艾瓦塌儿"。</p>
</li>
</ul>
<h2 id="hou-ji">后记</h2>
<p>虽然许多的词汇常常被错误发音但在中国遵守拼音原则是入乡随俗的一种表现且往往并没有所谓的官方读法不必太过于纠结100%纯正的读法。</p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/about-calling-cards/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">乱七八糟:流量卡购买与套路</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-mechrev-keyboard/">
<span class="button__text">乱七八糟:机械革命键盘失灵拯救记</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,658 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-baci/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-baci/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-baci/">乱七八糟:Baci实验笔记</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2025-04-23
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 BACI是一个简化的并发程序模拟器这里对其语法与运行环境进行说明。</p>
<span id="continue-reading"></span>
<p>BACI<code>Ben-Ari Concurrent Interpreter</code>)由计算机科学家 M. Ben-Ari 开发,是一个用于教学目的的并发程序模拟器,提供了一个简化的编程环境,使学习者能够编写、编译和执行并发程序,从而深入<code>理解进程同步、互斥、信号量</code>等核心概念。</p>
<h1 id="guan-fang-zhi-nan">官方指南</h1>
<p><code>BACI C Users Guide</code>:详细介绍了 C 编译器bacc与 PCODE 解释器bainterp的使用方法、语法说明及示例程序。该指南<code>包含编译命令、信号量、监视器等并发原语</code>介绍。 这里对官方文档进行了汉化:</p>
<blockquote>
<p>作者Bill Bynum/Tracy Camp 威廉玛丽学院/科罗拉多矿业学院 2002年11月5日</p>
</blockquote>
<h2 id="mu-lu">目录</h2>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>1. 引言
</span><span>2. C-- 编译器语法
</span><span>3. 并发结构
</span><span> 3.1 cobegin 块
</span><span> 3.2 信号量
</span><span> 3.2.1 初始化信号量
</span><span> 3.2.2 p (或 wait) 和 v (或 signal) 函数
</span><span> 3.2.3 信号量使用示例
</span><span> 3.3 管程
</span><span> 3.3.1 条件变量
</span><span> 3.3.2 waitc 和 signalc 函数
</span><span> 3.3.3 立即恢复要求
</span><span> 3.3.4 管程示例
</span><span> 3.4 其他并发结构
</span><span> 3.4.1 atomic 关键字
</span><span> 3.4.2 void suspend( void );
</span><span> 3.4.3 void revive( int process_number );
</span><span> 3.4.4 int which_proc( void );
</span><span> 3.4.5 int random( int range );
</span><span>4. 内置字符串处理函数
</span><span> 4.1 void stringCopy(string dest, string src);
</span><span> 4.2 void stringConcat(string dest, string src);
</span><span> 4.3 int stringCompare(string x, string y);
</span><span> 4.4 int stringLength(string x);
</span><span> 4.5 int sscanf(string x, rawstring fmt,...);
</span><span> 4.6 void sprintf(string x, rawstring fmt,...);
</span><span>5. 使用 BACI C-- 编译器和 PCODE 解释器
</span><span>6. 示例程序和输出
</span></code></pre>
<h2 id="1-yin-yan">1. 引言</h2>
<p>本文档旨在简要描述 C-- BACI 编译器和并发 PCODE 解释器程序并说明如何使用它们。C-- 编译器首先将用户程序编译成一种称为 PCODE 的中间目标代码然后由解释器执行。C-- 编译器支持二进制和计数信号量以及 Hoare 管程。解释器模拟并发进程执行。</p>
<p>BACI 系统程序:</p>
<table><thead><tr><th>程序</th><th>功能</th><th>相关文档</th></tr></thead><tbody>
<tr><td>bacc</td><td>BACI C-- 到 PCODE 编译器</td><td>本指南 (cmimi.ps)</td></tr>
<tr><td>bapas</td><td>BACI Pascal 到 PCODE 编译器</td><td>guidepas.ps</td></tr>
<tr><td>bainterp</td><td>命令行 PCODE 解释器</td><td>cmimi.ps, guidepas.ps, disasm.ps</td></tr>
<tr><td>bagui</td><td>PCODE 解释器的图形用户界面(仅限 UNIX 系统)</td><td>guiguide.ps</td></tr>
<tr><td>badis</td><td>PCODE 反编译器</td><td>disasm.ps</td></tr>
<tr><td>baar</td><td>PCODE 归档程序</td><td>sepcomp.ps</td></tr>
<tr><td>bald</td><td>PCODE 链接器</td><td>sepcomp.ps</td></tr>
</tbody></table>
<p>Pascal 版本的编译器和解释器最初是 M. Ben-Ari 编写的程序中的过程,基于 Niklaus Wirth 的原始 Pascal 编译器。程序源代码作为附录包含在 Ben-Ari 的著作《并发编程原理》中。BACI 编译器和解释器的原始版本就是从该源代码创建的。最终Pascal 编译器和解释器被分成两个独立的程序,并开发了 C-- 编译器,用于将用 C++ 的受限子集编写的源程序编译成可由解释器执行的 PCODE。</p>
<p>下面将解释 C-- 编译器的语法。本指南仅适用于 C-- 编译器,不适用于 BACI 并发 Pascal 编译器。对 Pascal 编译器感兴趣的用户应参考其用户指南(见文件 guidepas.ps</p>
<h2 id="2-c-bian-yi-qi-yu-fa">2. C-- 编译器语法</h2>
<ol>
<li>
<p>如同 C++,注释可以用 '/<em>' 和 '</em>/' 或 '//' 来界定。</p>
</li>
<li>
<p>除了标准输入和输出外没有其他文件cout、cin 和 endl 在 C-- BACI 中的行为与标准 C++ 一致。主程序必须具有以下形式之一:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">int </span><span style="color:#fad07a;">main</span><span>()
</span><span style="color:#8fbfdc;">void </span><span style="color:#fad07a;">main</span><span>()
</span><span style="color:#ffb964;">main</span><span>()
</span></code></pre>
</li>
<li>
<p>C-- BACI 中唯一可用的简单 C/C++ 类型是 int 和 char。还有其他与并发控制相关的类型将在下面讨论。</p>
<p>所有变量必须在它们出现的代码块开头声明。特别是for 循环的索引变量不能在循环头中声明,而必须在包含该 for 循环的块的开头声明。</p>
</li>
<li>
<p>支持 string 类型。声明字符串时,必须指定字符串的长度。以下声明定义了一个长度为 20 的字符串:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span>string[</span><span style="color:#cf6a4c;">20</span><span>] string_name;
</span></code></pre>
<p>长度说明符应该是字符串应具有的字符数,不应包括终止字节的空间。编译器负责为终止字节保留空间。长度说明符必须是字面常量或程序常量。</p>
<p>在函数声明中string 关键字用于声明 string 类型的参数:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">void </span><span style="color:#fad07a;">proc</span><span>(string </span><span style="color:#ffb964;">formal_parm</span><span>)
</span></code></pre>
<p>此声明断言 formal_parm 的类型为 string[n],其中 n 为某个正值。string 类型的参数是通过引用传递的。不执行字符串溢出检查。</p>
</li>
<li>
<p>支持任何有效类型的数组。数组声明遵循通常的 C 语法:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span>element_type arrayname[index1][index2][index3]...[indexN];
</span></code></pre>
</li>
<li>
<p>C-- BACI 支持关键字 typedef。例如要使变量名 length 成为 int 的同义词:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">typedef int </span><span style="color:#ffb964;">length</span><span>;
</span></code></pre>
</li>
<li>
<p>支持简单类型的常量 (const)</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">const int</span><span> m = </span><span style="color:#cf6a4c;">5</span><span>;
</span></code></pre>
</li>
<li>
<p>在声明 int 和 char 类型的变量时,支持初始化器。初始化器的值必须是字面量或程序常量:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">const int</span><span> m = </span><span style="color:#cf6a4c;">5</span><span>;
</span><span style="color:#8fbfdc;">int</span><span> j = m;
</span><span style="color:#8fbfdc;">int</span><span> k = </span><span style="color:#cf6a4c;">3</span><span>;
</span><span style="color:#8fbfdc;">char</span><span> c = </span><span style="color:#556633;">&#39;</span><span style="color:#99ad6a;">a</span><span style="color:#556633;">&#39;</span><span>;
</span></code></pre>
</li>
<li>
<p>支持过程和函数。适用标准作用域规则。支持递归。参数声明为传值或传引用:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">int </span><span style="color:#fad07a;">afunc</span><span>(</span><span style="color:#8fbfdc;">int </span><span style="color:#ffb964;">a</span><span>, </span><span style="color:#888888;">/* 传值 */
</span><span> </span><span style="color:#8fbfdc;">int</span><span>&amp; </span><span style="color:#ffb964;">b</span><span>) </span><span style="color:#888888;">/* 传引用 */
</span></code></pre>
<p>每个程序必须有一个 int 或 void 类型的 main() 函数,并且该函数必须是源文件中的最后一个函数。执行从 main() 的调用开始。</p>
</li>
<li>
<p>可执行语句包括 if-else、switch/case、for、while、do-while、break 和 continue。这些语句的语法与标准 C/C++ 相同。代码的括号也是标准的,即 { ... }。</p>
</li>
<li>
<p>支持标准 C/C++ 文件包含:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">#include </span><span style="color:#556633;">&lt;</span><span style="color:#99ad6a;"> ... </span><span style="color:#556633;">&gt;
</span><span style="color:#8fbfdc;">#include </span><span style="color:#556633;">&quot;</span><span style="color:#99ad6a;"> ... </span><span style="color:#556633;">&quot;
</span></code></pre>
<p>两种包含语句风格具有相同的语义,因为没有"系统"包含目录。</p>
</li>
<li>
<p>支持用于定义外部变量的 extern 关键字。外部变量可以是任何有效的 C-- 类型。外部变量不能使用初始化器。extern 关键字只能出现在全局("外部")级别。典型示例:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">extern int</span><span> i;
</span><span style="color:#8fbfdc;">extern char</span><span> a[</span><span style="color:#cf6a4c;">20</span><span>];
</span><span style="color:#8fbfdc;">extern</span><span> string[</span><span style="color:#cf6a4c;">30</span><span>] b;
</span><span style="color:#888888;">// 不允许初始化器 ----&gt; extern int i = 30;
</span><span style="color:#888888;">// (如果有初始化,必须在 i 定义的地方进行)
</span><span style="color:#8fbfdc;">extern int </span><span style="color:#fad07a;">func</span><span>(</span><span style="color:#8fbfdc;">int </span><span style="color:#ffb964;">k</span><span>);
</span><span style="color:#8fbfdc;">extern</span><span> monitor monSemaphore { </span><span style="color:#888888;">// 见第 3 节。这里只需给出
</span><span> </span><span style="color:#8fbfdc;">void </span><span style="color:#ffb964;">monP</span><span>(); </span><span style="color:#888888;">// 管程的外部可见细节
</span><span> </span><span style="color:#8fbfdc;">void </span><span style="color:#ffb964;">monV</span><span>();
</span><span>}
</span></code></pre>
<p>使用 bacc 编译包含外部引用的源文件时,必须使用 -c 选项。有关使用外部变量的更多信息,请参阅 BACI 系统分离编译指南。</p>
</li>
</ol>
<h2 id="3-bing-fa-jie-gou">3. 并发结构</h2>
<h3 id="3-1-cobegin-kuai">3.1 cobegin 块</h3>
<p>C-- 进程是一个 void 函数。在 BACI 系统中,"并发进程"一词与"并发线程"一词同义。要并发运行的进程列表封装在一个 cobegin 块中。这种块不能嵌套,必须出现在主程序中。</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span>cobegin {
</span><span> </span><span style="color:#ffb964;">proc1</span><span>(...); </span><span style="color:#ffb964;">proc2</span><span>(...); ... ; </span><span style="color:#ffb964;">procN</span><span>(...);
</span><span>}
</span></code></pre>
<p>列出的过程中的 PCODE 语句由解释器以任意的"随机"顺序交错执行,因此,包含 cobegin 块的同一程序的多次执行将表现为非确定性的。主程序被挂起,直到 cobegin 块中的所有进程终止,此时主程序在块结尾后的语句处恢复执行。</p>
<h3 id="3-2-xin-hao-liang">3.2 信号量</h3>
<p>解释器有一个预先声明的 semaphore 类型。也就是说C-- 中的信号量是一个非负整数变量(见下面的定义),只能以受限方式访问。二进制信号量,即只取值 0 和 1 的信号量,由 semaphore 类型的 binarysem 子类型支持。在编译和执行过程中,编译器和解释器强制限制 binarysem 变量只能取值 0 或 1而 semaphore 类型只能是非负的。</p>
<h4 id="3-2-1-chu-shi-hua-xin-hao-liang">3.2.1 初始化信号量</h4>
<p>只有在定义信号量变量时才允许对其赋值。例如,以下任一声明都是有效的:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span>semaphore s = </span><span style="color:#cf6a4c;">17</span><span>;
</span><span>binarysem b = </span><span style="color:#cf6a4c;">0</span><span>;
</span></code></pre>
<p>内置过程:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#ffb964;">initialsem</span><span>(semaphore, integer_expression);
</span></code></pre>
<p>是在运行时初始化任一类型信号量的唯一可用方法。在调用中integer_expression 可以是计算结果为整数且对信号量类型有效的任何表达式semaphore 类型为非负binarysem 类型为 0 或 1。例如以下两个 initialsem 调用显示了初始化上述两个信号量的另一种方式:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#ffb964;">initialsem</span><span>(s, </span><span style="color:#cf6a4c;">17</span><span>);
</span><span style="color:#ffb964;">initialsem</span><span>(b, </span><span style="color:#cf6a4c;">0</span><span>);
</span></code></pre>
<h4 id="3-2-2-p-huo-wait-he-v-huo-signal-han-shu">3.2.2 p (或 wait) 和 v (或 signal) 函数</h4>
<p>p 函数(或同义的 wait和 v 函数(或同义的 signal由并发执行的进程用于同步它们的操作。这些函数为用户提供了更改信号量值的唯一方式。</p>
<p>这两个函数的原型如下:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">void </span><span style="color:#fad07a;">p</span><span>(semaphore&amp; </span><span style="color:#ffb964;">s</span><span>);
</span></code></pre>
<p>或等效地:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">void </span><span style="color:#fad07a;">wait</span><span>(semaphore&amp; </span><span style="color:#ffb964;">s</span><span>);
</span></code></pre>
<p>以及:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">void </span><span style="color:#fad07a;">v</span><span>(semaphore&amp; </span><span style="color:#ffb964;">s</span><span>);
</span></code></pre>
<p>或等效地:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">void </span><span style="color:#fad07a;">signal</span><span>(semaphore&amp; </span><span style="color:#ffb964;">s</span><span>);
</span></code></pre>
<p>每个函数的信号量参数显示为引用参数,因为函数会修改信号量的值。</p>
<p>p 和 v 函数调用的语义如下:</p>
<p>p(sem);</p>
<ul>
<li>如果 sem &gt; 0则将 sem 减 1 并返回,允许 p 的调用者继续。</li>
<li>如果 sem = 0则使 p 的调用者休眠。这些操作是原子的,即它们是不可中断的,从开始到结束执行。</li>
</ul>
<p>v(sem);</p>
<ul>
<li>如果 sem = 0 且一个或多个进程正在 sem 上休眠,则唤醒其中一个进程。如果没有进程在 sem 上等待,则将 sem 加一。在任何情况下v 的调用者都被允许继续。这些操作是原子的,即它们是不可中断的,从开始到结束执行。</li>
<li>v 的某些实现要求按 FIFO 顺序唤醒等待信号量的进程(队列信号量),但 BACI 符合 Dijkstra 的原始提议,在信号到达时随机选择要重新唤醒的进程。</li>
</ul>
<h4 id="3-2-3-xin-hao-liang-shi-yong-shi-li">3.2.3 信号量使用示例</h4>
<p>为帮助解释信号量的使用,我们提供以下简短示例:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>BACI System: C-- to PCODE Compiler, 09:24 2 May 2002
</span><span>Source file: semexample.cm Sun Apr 28 20:40:12 2002
</span><span>line pc
</span><span>1 0 // C-- 信号量使用示例
</span><span>2 0
</span><span>3 0 semaphore count; // 一个&quot;通用&quot;信号量
</span><span>4 0 binarysem output; // 一个二进制0 或 1信号量用于解除输出混乱
</span><span>5 0
</span><span>6 0 void increment()
</span><span>7 0 {
</span><span>8 0 p(output); // 获取对标准输出的独占访问权
</span><span>9 2 cout &lt;&lt; &quot;before v(count) value of count is &quot; &lt;&lt; count &lt;&lt; endl;
</span><span>10 6 v(output);
</span><span>11 8 v(count); // 增加信号量
</span><span>12 10 } // increment
</span><span>13 11
</span><span>14 11 void decrement()
</span><span>15 11 {
</span><span>16 11 p(output); // 获取对标准输出的独占访问权
</span><span>17 13 cout &lt;&lt; &quot;before p(count) value of count is &quot; &lt;&lt; count &lt;&lt; endl;
</span><span>18 17 v(output);
</span><span>19 19 p(count); // 减少信号量(或停止 -- 见手册文本)
</span><span>20 21 } // decrement
</span><span>21 22
</span><span>22 22 main()
</span><span>23 23 {
</span><span>24 23 initialsem(count,0);
</span><span>25 26 initialsem(output,1);
</span><span>26 29 cobegin {
</span><span>27 30 decrement(); increment();
</span><span>28 36 }
</span><span>29 37 } // main
</span></code></pre>
<p>该程序使用两个信号量。一个信号量 count 属于 semaphore 类型,这向 BACI 系统表明该信号量将被允许具有任何非负值。两个并发过程 increment 和 decrement 通过 count 信号量相互"发送信号"。另一个信号量 output 属于 binarysem 类型,这向 BACI 系统表明该信号量应始终具有值 0 或 1任何其他值都会导致运行时异常。该信号量用于防止两个并发执行的过程 increment 和 decrement 的输出混合在一起。</p>
<p>我们使用以下命令生成上述编译器列表:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>prompt% bacc semexample
</span><span>Pcode and tables are stored in semexample.pco
</span><span>Compilation listing is stored in semexample.lst
</span></code></pre>
<p>然后可以使用 BACI PCODE 解释器执行 semexample.pco 文件:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>prompt% bainterp semexample
</span><span>Source file: semexample.cm Sun Apr 28 20:40:12 2002
</span><span>Executing PCODE ...
</span><span>before v(count) value of count is 0
</span><span>before p(count) value of count is 1
</span></code></pre>
<p>这是程序可能产生的三种可能输出之一。另外两种可能的程序输出是:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>prompt% bainterp semexample
</span><span>Source file: semexample.cm Sun Apr 28 20:40:12 2002
</span><span>Executing PCODE ...
</span><span>before p(count) value of count is 0
</span><span>before v(count) value of count is 0
</span></code></pre>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>prompt% bainterp semexample
</span><span>Source file: semexample.cm Sun Apr 28 20:40:12 2002
</span><span>Executing PCODE ...
</span><span>before v(count) value of count is 0
</span><span>before p(count) value of count is 0
</span></code></pre>
<p>有兴趣的读者可能会发现,提供这三种程序输出生成方式的解释,并证明这三种输出是唯一可能的输出,是很有指导意义的。</p>
<h3 id="3-3-guan-cheng">3.3 管程</h3>
<p>支持 Hoare 提出的管程概念,但有一些限制。管程是一个 C-- 块,类似于由过程或函数定义的块,但具有一些额外的属性。管程块中的所有函数都是可见的(即可从块外部调用的入口过程),但管程变量在块外部不可访问,并且只能由管程函数访问。</p>
<p>在 C-- 中,管程只能在最外层、全局级别声明。管程不能嵌套。管程可以选择在最后一个块中有一个 init{} 块,用于初始化管程变量的值。这段代码在主程序启动时运行。</p>
<p>管程块的只有一个过程或函数可以在任何时候执行。这一特性使得可以使用管程来实现互斥。使用管程控制并发是有优势的,因为所有控制并发的代码都位于管程中,而不是像使用信号量那样广泛分布在调用者中。</p>
<p>管程的过程和函数使用三种结构来控制并发条件变量、waitc等待条件和 signalc表示条件</p>
<h4 id="3-3-1-tiao-jian-bian-liang">3.3.1 条件变量</h4>
<p>条件变量只能在管程中定义,因此只能由管程的进程访问。条件变量实际上从不"有"值;它是等待的地方或信号的东西。管程进程可以通过 waitc 和 signalc 调用等待条件成立或表示给定条件现在成立。</p>
<h4 id="3-3-2-waitc-he-signalc-han-shu">3.3.2 waitc 和 signalc 函数</h4>
<p>waitc 和 signalc 调用具有以下语法和语义:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">void </span><span style="color:#fad07a;">waitc</span><span>(condition </span><span style="color:#ffb964;">cond</span><span>, </span><span style="color:#8fbfdc;">int </span><span style="color:#ffb964;">prio</span><span>);
</span></code></pre>
<p>管程进程(因此,也是调用管程进程的外部进程)被阻塞并被分配优先级 prio 以便被重新唤醒(见下面的 signalc。请注意这种阻塞操作允许另一个管程进程执行如果有的话。</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">void </span><span style="color:#fad07a;">waitc</span><span>(condition </span><span style="color:#ffb964;">cond</span><span>);
</span></code></pre>
<p>此调用具有与上面的 waitc 调用相同的语义,但等待被分配默认优先级 10。</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span style="color:#8fbfdc;">void </span><span style="color:#fad07a;">signalc</span><span>(condition </span><span style="color:#ffb964;">cond</span><span>);
</span></code></pre>
<p>唤醒在 cond 上等待的、具有最小(最高)优先级的某个进程;否则,不执行任何操作。请注意,这与信号量 v 或 signal 完全不同因为如果没有人等待signalc 是一个空操作,而 v(sem) 在没有人等待时会增加 sem从而在将来的 p(sem) 发生时"记住"该操作。</p>
<p>优先级方案可用于实现重新唤醒等待者的 FIFO 规则。如果每个管程进程都增加与当前分配给条件的优先级相关联的管程变量,那么对该条件的连续 signalc 将按照 FIFO 顺序唤醒休眠进程。</p>
<p>C-- 编译器提供了一个 int 函数 empty(cond),如果条件 cond 的队列中没有进程等待,则返回 1否则返回 0。</p>
<h4 id="3-3-3-li-ji-hui-fu-yao-qiu">3.3.3 立即恢复要求</h4>
<p>这是指刚刚被发送信号的条件上等待的进程应该优先于新调用管程进程(那些想要"从顶部"进入的进程)重新进入管程的要求。该要求基于这样的假设:刚刚被发送信号的条件比新进入管程的情况具有更"紧急"的业务要执行。立即恢复要求在 BACI 中通过挂起条件的发送者并随机选择一个具有适当优先级的条件等待者来运行来实现。因此signalc 条件的管程过程通常将其作为最后一条指令。</p>
<p>当被 signalc 重新唤醒的进程离开管程时,在发出 signalc 调用后被挂起的在管程中执行的进程被允许优先于尝试"从顶部"进入管程的进程恢复在管程中的执行。</p>
<h4 id="3-3-4-guan-cheng-shi-li">3.3.4 管程示例</h4>
<p>以下通过管程实现通用信号量的示例说明了管程语法:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span>monitor monSemaphore {
</span><span> </span><span style="color:#8fbfdc;">int</span><span> semvalue;
</span><span> condition notbusy;
</span><span> </span><span style="color:#8fbfdc;">void </span><span style="color:#ffb964;">monP</span><span>()
</span><span> {
</span><span> </span><span style="color:#8fbfdc;">if </span><span>(!semvalue)
</span><span> </span><span style="color:#ffb964;">waitc</span><span>(notbusy);
</span><span> </span><span style="color:#8fbfdc;">else
</span><span> semvalue--;
</span><span> }
</span><span> </span><span style="color:#8fbfdc;">void </span><span style="color:#ffb964;">monV</span><span>()
</span><span> {
</span><span> </span><span style="color:#8fbfdc;">if </span><span>(</span><span style="color:#ffb964;">empty</span><span>(notbusy))
</span><span> semvalue++;
</span><span> </span><span style="color:#8fbfdc;">else
</span><span> </span><span style="color:#ffb964;">signalc</span><span>(notbusy);
</span><span> }
</span><span> init{ semvalue = </span><span style="color:#cf6a4c;">1</span><span>; }
</span><span>} </span><span style="color:#888888;">// monSemaphore 管程结束
</span></code></pre>
<h3 id="3-4-qi-ta-bing-fa-jie-gou">3.4 其他并发结构</h3>
<p>BACI C-- 提供了几个低级并发结构,可用于创建新的并发控制原语:这些函数可用于创建"公平"FIFO队列信号量。实现这一点的代码超出了本用户指南的范围。</p>
<h4 id="3-4-1-atomic-guan-jian-zi">3.4.1 atomic 关键字</h4>
<p>如果一个函数被定义为 atomic那么该函数是不可抢占的。解释器不会用上下文切换中断一个原子函数。这为用户提供了定义新原语的方法。以下程序说明了如何定义 test_and_set 原语并使用它来强制互斥:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span>atomic </span><span style="color:#8fbfdc;">int </span><span style="color:#fad07a;">test_and_set</span><span>(</span><span style="color:#8fbfdc;">int</span><span>&amp; </span><span style="color:#ffb964;">target</span><span>) {
</span><span> </span><span style="color:#8fbfdc;">int</span><span> u;
</span><span> u = target;
</span><span> target = </span><span style="color:#cf6a4c;">1</span><span>;
</span><span> </span><span style="color:#8fbfdc;">return</span><span> u;
</span><span>}
</span><span>
</span><span style="color:#8fbfdc;">int</span><span> lock = </span><span style="color:#cf6a4c;">0</span><span>;
</span><span>
</span><span style="color:#8fbfdc;">void </span><span style="color:#fad07a;">proc</span><span>(</span><span style="color:#8fbfdc;">int </span><span style="color:#ffb964;">id</span><span>) {
</span><span> </span><span style="color:#8fbfdc;">int</span><span> i = </span><span style="color:#cf6a4c;">0</span><span>;
</span><span> </span><span style="color:#8fbfdc;">while</span><span>(i &lt; </span><span style="color:#cf6a4c;">10</span><span>) {
</span><span> </span><span style="color:#8fbfdc;">while </span><span>(</span><span style="color:#ffb964;">test_and_set</span><span>(lock)) </span><span style="color:#888888;">/* wait */ </span><span>;
</span><span> cout &lt;&lt; id;
</span><span> lock = </span><span style="color:#cf6a4c;">0</span><span>;
</span><span> i++;
</span><span> }
</span><span>}
</span><span>
</span><span style="color:#ffb964;">main</span><span>() {
</span><span> cobegin { </span><span style="color:#ffb964;">proc</span><span>(</span><span style="color:#cf6a4c;">1</span><span>); </span><span style="color:#ffb964;">proc</span><span>(</span><span style="color:#cf6a4c;">2</span><span>); </span><span style="color:#ffb964;">proc</span><span>(</span><span style="color:#cf6a4c;">3</span><span>); }
</span><span>}
</span></code></pre>
<h4 id="3-4-2-void-suspend-void">3.4.2 void suspend(void);</h4>
<p>suspend 函数使调用线程休眠。</p>
<h4 id="3-4-3-void-revive-int-process-number">3.4.3 void revive(int process_number);</h4>
<p>revive 函数重新激活给定编号的进程。</p>
<h4 id="3-4-4-int-which-proc-void">3.4.4 int which_proc(void);</h4>
<p>which_proc 函数返回当前线程的进程编号。</p>
<h4 id="3-4-5-int-random-int-range">3.4.5 int random(int range);</h4>
<p>random 函数返回一个在 0 到 range - 1包含之间"随机选择"的整数。它使用与解释器使用的不同的随机数生成器流也就是说random() 调用不会影响解释器执行。</p>
<h2 id="4-nei-zhi-zi-fu-chuan-chu-li-han-shu">4. 内置字符串处理函数</h2>
<h3 id="4-1-void-stringcopy-string-dest-string-src">4.1 void stringCopy(string dest, string src);</h3>
<p>stringCopy 函数将 src 字符串复制到 dest 字符串中。不执行字符串溢出检查。例如:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span>string[</span><span style="color:#cf6a4c;">20</span><span>] x;
</span><span>...
</span><span style="color:#ffb964;">stringCopy</span><span>(x,</span><span style="color:#556633;">&quot;</span><span style="color:#99ad6a;">Hello, world!</span><span style="color:#556633;">&quot;</span><span>);
</span><span style="color:#ffb964;">stringCopy</span><span>(x,</span><span style="color:#556633;">&quot;&quot;</span><span>);
</span></code></pre>
<p>将把字符串 x 初始化为一个众所周知的值。第二个 stringCopy 将字符串 x 重置为零长度字符串。</p>
<h3 id="4-2-void-stringconcat-string-dest-string-src">4.2 void stringConcat(string dest, string src);</h3>
<p>stringConcat 函数将 src 字符串连接到 dest 的末尾。不执行字符串溢出检查。</p>
<h3 id="4-3-int-stringcompare-string-x-string-y">4.3 int stringCompare(string x, string y);</h3>
<p>stringCompare 函数与 C 字符串库中的 strcmp 函数具有相同的语义:如果字符串 x 按字典顺序在字符串 y 之后,则返回正数;如果字符串相等,则返回零;如果字符串 x 按字典顺序在字符串 y 之前,则返回负数。</p>
<h3 id="4-4-int-stringlength-string-x">4.4 int stringLength(string x);</h3>
<p>stringLength 函数返回字符串 x 的长度,不包括终止字节。</p>
<h3 id="4-5-int-sscanf-string-x-rawstring-fmt">4.5 int sscanf(string x, rawstring fmt,...);</h3>
<p>与"真正的" sscanf 一样sscanf 函数根据格式字符串 fmt 扫描字符串 x将扫描到的值存储到参数列表中提供的变量中并返回扫描到的项目数。仅支持真正的 sscanf 的 %d、%x 和 %s 格式说明符。还支持 BACI 独有的附加格式说明符 %q带引号的字符串。对于此说明符所有由一对双引号")分隔的字符都将被扫描到相应的字符串变量中。当在格式字符串中遇到 %q 说明符时,如果要扫描的字符串中的下一个非空白字符不是双引号,则 %q 扫描失败,并且字符串的扫描终止。</p>
<p>格式字符串后面出现的变量是引用变量(即,不需要 &amp; 符号)。</p>
<p>在以下示例中sscanf 调用返回的 i 值将为 4存储在变量 j 中的值将为 202存储在字符串 x 中的字符串值将为 alongstring存储在变量 k 中的值将为 0x3c03存储在字符串 y 中的字符串将为 a long string。</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span>string[</span><span style="color:#cf6a4c;">50</span><span>] x,y;
</span><span style="color:#8fbfdc;">int</span><span> i,j,k;
</span><span style="color:#ffb964;">stringCopy</span><span>(x,</span><span style="color:#556633;">&quot;</span><span style="color:#99ad6a;">202 alongstring 3c03 \&quot;a long string\&quot;</span><span style="color:#556633;">&quot;</span><span>);
</span><span>i = sscanf(x,</span><span style="color:#556633;">&quot;</span><span style="color:#7697d6;">%d %s %x</span><span style="color:#99ad6a;"> %q</span><span style="color:#556633;">&quot;</span><span>,j,x,k,y);
</span></code></pre>
<h3 id="4-6-void-sprintf-string-x-rawstring-fmt">4.6 void sprintf(string x, rawstring fmt,...);</h3>
<p>与 C 库中的"真正的" sprintf 函数一样sprintf 函数使用格式字符串 fmt 和格式字符串后面的变量创建存储在变量 x 中的字符串。</p>
<p>支持 %d、%o、%x、%X、%c 和 %s 格式说明符,其全部功能与真正的 sprintf 相同。此外,%q 格式说明符将在输出字符串中插入带双引号的字符串。%q 格式说明符等同于 "%s" 说明符。</p>
<p>例如,在以下代码片段中:</p>
<pre data-lang="c" style="background-color:#151515;color:#e8e8d3;" class="language-c "><code class="language-c" data-lang="c"><span>string[</span><span style="color:#cf6a4c;">80</span><span>] x;
</span><span>string[</span><span style="color:#cf6a4c;">15</span><span>] y,z;
</span><span style="color:#ffb964;">stringCopy</span><span>(y,</span><span style="color:#556633;">&quot;</span><span style="color:#99ad6a;">alongstring</span><span style="color:#556633;">&quot;</span><span>);
</span><span style="color:#ffb964;">stringCopy</span><span>(z,</span><span style="color:#556633;">&quot;</span><span style="color:#99ad6a;">a long string</span><span style="color:#556633;">&quot;</span><span>);
</span><span style="color:#ffb964;">sprintf</span><span>(x,</span><span style="color:#556633;">&quot;</span><span style="color:#99ad6a;">.</span><span style="color:#7697d6;">%12d</span><span style="color:#99ad6a;">. .</span><span style="color:#7697d6;">%-20s</span><span style="color:#99ad6a;">. .%q. .</span><span style="color:#7697d6;">%08X</span><span style="color:#99ad6a;">.</span><span style="color:#556633;">&quot;</span><span>,</span><span style="color:#cf6a4c;">202</span><span>,y,z,</span><span style="color:#cf6a4c;">0x3c03</span><span>);
</span></code></pre>
<p>字符串 x 变为:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>. 202. .alongstring . .&quot;a long string&quot;. .00003C03.
</span></code></pre>
<h2 id="5-shi-yong-baci-c-bian-yi-qi-he-pcode-jie-shi-qi">5. 使用 BACI C-- 编译器和 PCODE 解释器</h2>
<p>使用 BACI 系统执行程序有两个步骤。</p>
<ol>
<li>
<p>编译 ".cm" 文件以获取 ".pco" 文件。</p>
<p>用法bacc [可选标志] 源文件名</p>
<p>可选标志:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>-h 显示此帮助
</span><span>-c 创建一个 .pob 目标文件以便后续链接
</span></code></pre>
<p>源文件名是必需的。如果缺少,您将被提示输入。如果您不提供,将附加文件后缀 ".cm"。</p>
</li>
<li>
<p>解释 ".pco" 文件以执行程序</p>
<p>用法baininterp [可选标志] pcode文件名</p>
<p>可选标志:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>-d 进入调试器,单步执行,设置断点
</span><span>-e 在进入每个进程时显示活动记录 (AR)
</span><span>-x 在退出每个进程时显示 AR
</span><span>-t 宣布进程终止
</span><span>-h 显示此帮助
</span><span>-p 显示正在执行的 PCODE 指令
</span></code></pre>
<p>PCODE 文件名是必需的。如果缺少,您将被提示输入。文件后缀 ".pco" 将附加到您给出的文件名。</p>
</li>
</ol>
<p>每次用 bainterp 执行 .pco 文件时,不必重新编译源文件。有一个 shell 脚本 baccint它将为您调用编译器然后调用解释器。它会将您给它的选项见上文传递给解释器。</p>
<h2 id="6-shi-li-cheng-xu-he-shu-chu">6. 示例程序和输出</h2>
<p>以下列表由 C-- BACI 编译器生成。行号右侧的数字是开始该行的指令的 PCODE 偏移量。BACI 编译器从文件 "incremen.cm" 创建此列表。该列表被放置在文件 "incremen.lst" 中。还创建了一个 "incremen.pco" 文件;此文件由解释器使用。</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>BACI System: C-- to PCODE Compiler, 09:24 2 May 2002
</span><span>Source file: incremen.cm Wed Oct 22 21:18:02 1997
</span><span>line pc
</span><span>1 0 const int m = 5;
</span><span>2 0 int n;
</span><span>3 0
</span><span>4 0 void incr(char id)
</span><span>5 0 {
</span><span>6 0 int i;
</span><span>7 0
</span><span>8 0 for(i = 1; i &lt;= m; i = i + 1)
</span><span>9 14 {
</span><span>10 14 n = n + 1;
</span><span>11 19 cout &lt;&lt; id &lt;&lt; &quot; n =&quot; &lt;&lt; n &lt;&lt; &quot; i =&quot;;
</span><span>12 25 cout &lt;&lt; i &lt;&lt; &quot; &quot; &lt;&lt; id &lt;&lt; endl;
</span><span>13 31 }
</span><span>14 32 }
</span><span>15 33
</span><span>16 33 main()
</span><span>17 34 {
</span><span>18 34 n = 0;
</span><span>19 37 cobegin
</span><span>20 38 {
</span><span>21 38 incr( &#39;A&#39;); incr( &#39;B&#39; ); incr(&#39;C&#39;);
</span><span>22 50 }
</span><span>23 51 cout &lt;&lt; &quot;The sum is &quot; &lt;&lt; n &lt;&lt; endl;
</span><span>24 55 }
</span></code></pre>
<p>以下列表由 BACI 解释器生成。解释器执行编译到文件 "incremen.pco" 中的程序。</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>Source file: incremen.cm Wed Oct 22 21:18:02 1997
</span><span>Executing PCODE ...
</span><span>C n =1 i =A n =1 C2 i =
</span><span>1 A
</span><span>C n =4 i =2 C
</span><span>B n =A n =5 i =24 A
</span><span>i =1 B
</span><span>AC n = n =6 i =3 C6 i =3
</span><span>A
</span><span>C n =7 i =4 C
</span><span>B n =9 i =2 BA n =8
</span><span>i =4 A
</span><span>C n =8 i =5 A n =9C
</span><span>i =5 A
</span><span>B n =10 i =3 B
</span><span>B n =11 i =4 B
</span><span>B n =12 i =5 B
</span><span>The sum is 12
</span></code></pre>
<h1 id="linuxhuan-jing-yun-xing-baci">linux环境运行baci</h1>
<ul>
<li>首先安装jdk和dos2unix</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>apt install jdk-openjdk dos2unix
</span></code></pre>
<ul>
<li>使用dos2unix转换格式</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>dos2unix ~/Git/java/baci/scripts/baci
</span></code></pre>
<ul>
<li>编写baci脚本</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>#!/usr/bin/env bash
</span><span># 定位到项目根目录(包含 javabaci 子目录的目录)
</span><span>BASEDIR=&quot;$(cd &quot;$(dirname &quot;${BASH_SOURCE[0]}&quot;)/..&quot; &amp;&amp; pwd)&quot;
</span><span>
</span><span># 将 javabaci/bin默认包类和项目根目录javabaci 包根)加入 classpath
</span><span>CLASSPATH=&quot;$BASEDIR/javabaci/bin:$BASEDIR&quot;
</span><span>
</span><span># 将所有参数原样传递给 java 运行
</span><span>exec java -cp &quot;$CLASSPATH&quot; &quot;$@&quot;
</span></code></pre>
<ul>
<li>给baci授予可执行权限</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>chmod +x ~/Git/java/baci/scripts/baci
</span></code></pre>
<ul>
<li>添加系统环境变量</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>fish_add_path ~/Git/java/baci/scripts
</span></code></pre>
<ul>
<li>查看baci是否存在</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>which baci
</span></code></pre>
<ul>
<li>现在即可编译运行</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>baci bacc ex3_1.cm
</span><span>baci bainterp ex3_1
</span></code></pre>
<hr />
<p><strong>Done.</strong></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/about-lazyvim/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">乱七八糟:lazyvim快速上手</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/network-ssh/">
<span class="button__text">网络艺术:SSH使用指南</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,333 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-blog/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-blog/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-blog/">乱七八糟:个人博客搭建</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2023-10-12
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 个人博客的搭建具有许多的方案可以选择,本文介绍如何快速部署一个博客,并将其发布到公网。</p>
<span id="continue-reading"></span><h2 id="qian-qing-hui-gu">前情回顾</h2>
<p>在互联网冲浪的过程中我们常常看到许多独立站点他们往往是个人博客有各种各样的主题样式这些站点见证了互联网的发展历史。从最初的手工编写HTML页面到后来的内容管理系统CMS如WordPress的兴起再到如今流行的静态网站生成器SSG如HugoHexoZola等等。</p>
<p>个人博客的定义是什么?私以为是<code>域名+站点+原创内容</code>三要素组成。当然,最重要的原创内容往往被忽视...</p>
<ul>
<li>域名可以在<a href="https://www.dynadot.com/">Dynadot</a>等平台购买,也可以申请如<code>eu.org</code><code>us.kg</code>等免费域名,目的是为了好记;</li>
<li>站点可以在自己的服务器上使用动态的<code>WordPress</code>或者<code>Halo</code>来一键创建,也可以使用<code>静态框架</code>部署在PAAS平台上</li>
</ul>
<p>因此,整体成本应该是非常低的。</p>
<h2 id="shi-yong-halokuai-su-da-jian-bo-ke">使用Halo快速搭建博客</h2>
<ul>
<li>首先你需要有一台自己的云服务器建议在1核1G以上配置并安装Debian系统</li>
<li>随后我们安装1panel执行以下命令一键安装</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh &amp;&amp; sudo bash quick_start.sh
</span></code></pre>
<blockquote>
<p>1panel依赖于docker如果实现没有安装docker脚本会帮你安装。</p>
</blockquote>
<ul>
<li>
<p>安装过程中选择好端口,随后即可使用<code>http:&lt;ip&gt;:&lt;port&gt;:&lt;安全入口&gt;</code>进入登录界面,并使用默认随机生成的密码进入面板。</p>
</li>
<li>
<p>进入之后我们可以看到里面有应用商店,在其中安装<code>OpenResty</code><code>Halo</code><code>mysql</code>,安装完毕后打开外部访问地址<code>http://ip:8090</code>即可进入halo的后台在其中写入文章并发布。</p>
</li>
</ul>
<p>但我们不能使用不安全的HTTP以及IP来访问博客因此我们需要一个域名指向我们的博客例如本文的<code>blog.dich.bid</code>;可以在在<a href="https://www.dynadot.com/">Dynadot</a>等平台购买域名,并托管到<a href="https://askai.glarity.app/zh-CN/search/%E5%A6%82%E4%BD%95%E5%B0%86Dynadot%E6%B3%A8%E5%86%8C%E7%9A%84%E5%9F%9F%E5%90%8D%E8%BD%AC%E7%A7%BB%E5%88%B0Cloudflare">Cloudflare</a></p>
<ul>
<li>
<p>随后可以在1panel的<code>网站</code>中创建一个反向代理代理地址即为http://ip:8090主域名为刚刚注册的域名前加blog或其他<code>blog.xxx.com</code></p>
</li>
<li>
<p>创建完成后我们还需要配置TLS证书在网站-HTTPS中添加证书可以选择<a href="https://bkssl.com/ssl/selfsign">自签名证书</a>正式或者通过Acme申请免费的<code>Let's Encrypt</code>证书。</p>
</li>
<li>
<p>配置完成后在Cloudflare的DNS解析界面创建一个A记录将你的<code>blog.xxx.com解析到你的服务器的IP</code></p>
</li>
<li>
<p>大功告成现在你应该可以通过HTTPS域名访问自己的博客</p>
</li>
</ul>
<h2 id="shi-yong-hugokuang-jia-gou-jian-bo-ke">使用Hugo框架构建博客</h2>
<p>首先明确你需要的架构,一般有两种选择:</p>
<ul>
<li>使用现有的架构,包括Hugo,HexoZola,Astro等等</li>
<li>或者从头写一个框架需要HTML/CSS/JS等知识</li>
</ul>
<blockquote>
<p>可以在<a href="https://jamstackthemes.dev/">这个网站</a>上面查看常见的框架与主题的显示效果</p>
</blockquote>
<ol>
<li><strong>安装Hugo</strong>:选择好你的框架与主题后这里以hugo为例子随后安装hugo以及对应的依赖</li>
</ol>
<ul>
<li><strong>Windows</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span># 打开以管理员模式运行的PowerShell,输入命令安装 Hugo Extended
</span><span>winget install Hugo.Hugo.Extended
</span></code></pre>
<ul>
<li><strong>Arch linux</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>paru -S hugo
</span></code></pre>
<ul>
<li><strong>检查版本</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>hugo version
</span></code></pre>
<ol start="2">
<li><strong>创建新的 Hugo 站点</strong>:选择一个文件夹打开命令行,执行:</li>
</ol>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>hugo new site myblog
</span></code></pre>
<p>该命令会在<code>myblog</code>文件夹下生成hugo的基础目录。</p>
<ol start="3">
<li><strong>安装主题</strong>,这里以<a href="https://jamstackthemes.dev/theme/hugo-blog-awesome/">hugo-blog-awesome</a>主题为例:</li>
</ol>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>cd myblog
</span><span>git clone https://github.com/hugo-sid/hugo-blog-awesome.git themes/hugo-blog-awesome
</span></code></pre>
<p>并在<code>hugo.toml</code>顶层添加:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>theme = &quot;hugo-blog-awesome&quot;
</span></code></pre>
<p>这样 Hugo 在构建时会从 themes/ 目录加载主题文件。后续可使用<code>git pull</code>获取主题更新。</p>
<blockquote>
<p>你也可以直接用theme中的文件夹替换掉项目根目录下的同名文件夹并再次修改。</p>
</blockquote>
<ol start="4">
<li><strong>写入文章</strong>:使用 Hugo 提供的命令创建新文章:</li>
</ol>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>hugo new posts/hello-world.md
</span></code></pre>
<p>该命令会在<code>content/posts/</code>下生成 Markdown 文件,打开后修改<code>title、date、tags</code>等前缀然后撰写 Markdown 正文, Markdown 编辑器参考<a href="https://blog.dich.bid/about-markdown/">前文</a></p>
<blockquote>
<p>注意md文章头部和正文之间得使用<code>&lt;!-- more --&gt;</code>隔断</p>
</blockquote>
<ol start="5">
<li><strong>本地测试</strong>:在项目根目录运行:</li>
</ol>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>hugo server -D
</span></code></pre>
<p>然后在浏览器访问<code>http://localhost:1313</code>即可实时预览并查看更新效果。</p>
<ol start="6">
<li>
<p><strong>上传到GitHub</strong>新建一个Github仓库用Git连接并将Hugo项目的文件夹push上去</p>
</li>
<li>
<p><strong>使用PAAS平台部署</strong>:随后使用<a href="https://vercel.com">Vercel</a>/<a href="https://www.netlify.com/">Netlify</a>等平台读取GitHub仓库并部署Hugo博客项目并设置指向自己的域名<code>设置一条CNAME记录</code>。部署的时候可以让<code>平台command运行部署</code>也可以<code>本地build之后直接上传public文件夹</code>并在平台中指定。</p>
</li>
</ol>
<blockquote>
<p>当然也可以使用GitHub Pages部署详见<a href="https://docs.github.com/zh/pages/quickstart?library=true">官方文档</a></p>
</blockquote>
<h3 id="ke-xuan-ding-zhi-xiang">可选定制项</h3>
<p><strong>你想要的显示效果?</strong></p>
<ul>
<li>风格包括命令行风格极简风格MD3风格等等;</li>
<li>布局,是响应式还是传统布局?</li>
</ul>
<p><strong>你需要那些功能?</strong></p>
<ul>
<li>黑暗/白天模式切换;</li>
<li>高斯模糊?动态取色?</li>
<li>PPT般的动效</li>
<li>访问人数和运行天数统计?</li>
<li>Tag分类和时间排序</li>
<li>搜索功能和RSS</li>
</ul>
<p><strong>需要处理哪些外部依赖?</strong></p>
<ul>
<li>域名和paas平台</li>
<li>图床还是直接嵌入图片?</li>
<li>是否需要自动编译?</li>
<li>是否需要多平台发布?</li>
<li>是否需要加密特定文章?</li>
</ul>
<p><strong>以上的功能和需求是否对SEO和界面相应时间造成影响</strong></p>
<h2 id="xiao-ji">小记</h2>
<p>由于我所使用的平台不支持zola因此我直接在本地编译public并推送这样时间久了.git文件夹大小会非常大记录public的变化我又不想将zola的二进制包放入目录下因此有了这个办法</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span># 安装git-filter-repo工具
</span><span>paru git-filter-repo
</span><span># 清理public相关的历史
</span><span>git clone git@github.com:Dichgrem/Blog.git blog1 &amp;&amp; cd blog1
</span><span>git filter-repo --path public --invert-paths
</span><span>git gc --aggressive --prune=now
</span><span># 重新推送到github
</span><span>git push --force --mirror
</span></code></pre>
<h2 id="link">🔗</h2>
<ul>
<li><a href="https://gohugo.io/documentation/">Hugo官方文档</a></li>
<li><a href="https://www.getzola.org/documentation/getting-started/overview/">zola官方文档</a></li>
<li><a href="https://github.com/pawroman/zola-theme-terminimal">zoal-terminimal主题</a></li>
<li><a href="https://github.com/aaranxu/chinese-copywriting-guidelines">中文排版指南</a></li>
<li><a href="https://atpx.com/blog/improving-online-reading-experience/">如何提高用户网页阅读体验</a></li>
</ul>
<hr />
<p><strong>Done.</strong></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/about-mechrev-keyboard/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">乱七八糟:机械革命键盘失灵拯救记</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-junk-cleanup/">
<span class="button__text">乱七八糟:垃圾清理的艺术</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,227 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-calling-cards/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-calling-cards/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-calling-cards/">乱七八糟:流量卡购买与套路</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2023-08-24
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 由于临近升学,校园网不尽人意,因此许多小伙伴有了买一张流量卡的计划。本文以三大运营商为例,说明常见流量卡的套路与选择。</p>
<span id="continue-reading"></span>
<p>2019 年 6 月 6 日,工信部发布 4 张 5G 牌照,标志 5G 商用的开始,中国进入 5G 时代。回想过去数年4G 降速、5G 提费的新闻屡见不鲜,而 5G 网络的落地应用似乎离普通人依然遥远。对于普通人而言昂贵的5G套餐资费依然没有流量卡香那什么是流量卡呢</p>
<h2 id="yi-shen-me-shi-liu-liang-qia">一.什么是流量卡</h2>
<p>流量卡<code>本质上还是一张 SIM 卡,往往具有大流量、低月租的特征</code>。互联网上有非常多不同运营商的「优惠套餐」,实则是不同卡商取名包装后的产物,卡商往往可以通过激活后赚取高额佣金获利,比如每年大学新生开学,校园里总有「运营商营业厅」摆摊甚至上门推销所谓「校园卡」,不少声称「超大流量」「长期套餐」,更有甚者,会搬出「校园网」来给涉世未深的大一小白们制造焦虑。</p>
<p>事实上,不管是「校园卡」还是网上卡商们大力吆喝的优惠流量卡,本质上<code>都属于个人使用的电话卡</code>。例如电信的优惠套餐,大都通过「电信星卡」套餐,再由当地运营商叠加优惠包(赠费或叠加流量包)包装而成。</p>
<h2 id="er-wei-shen-me-xu-yao-liu-liang-qia">二.为什么需要流量卡</h2>
<p>普通卡大多有着长合约和固定归属地,不能轻易更换套餐,且套餐月租费用较高,<code>特别是在5G推行时期4G的资费不减反升且速度有所下降</code>。而流量卡动则100G往上月租在50左右且可以随时退卡。</p>
<h2 id="san-liu-liang-qia-ji-ben-yuan-li">三.流量卡基本原理</h2>
<p>由于三大运营商处于<code>半国企状态(自负盈亏)</code>,因此在长期亏损下不得不整一些牛马活采用一些策略,比如冗长的条款和隐藏极深的优惠套餐等等。而由于不同地区的经济发展状况不同,<code>部分中西部地区的地区分公司业绩不佳</code>,为了在短期内达到要求往往会和一些地区分销商进行合作,将本地区的电话卡改为优惠的套餐,从而吸引客户。注意:<code>99%所谓的月租19、29等流量卡都是要先缴一笔较多的钱进而每月返还一点点实现长期上的低月租</code>,运营商是要短期变现的!</p>
<p>那么是不是我们就没有优惠了呢其实相对于5元1G、40元10G的资费而言还是非常划算的。</p>
<h2 id="si-fen-qing-liu-liang-qia-he-wu-lian-qia">四.分清流量卡和物联卡</h2>
<p>部分小伙伴反映被物联卡坑了这里我们一定要注意诸如某宝某猫上面的9999G超级流量卡usb接口的随身WiFi等等不出意外都是物联卡。</p>
<p>什么是物联卡?<code>物联网设备往往只需要网络接入而不需要电话短信功能,也就不需要电话号码</code>。为了防止滥用,同时降低成本,运营商往往会给这些设备制作「物联网卡」,也就是只具备上网功能的电话卡。为了便于物联网设备公司管理,运营商还会授权这些代理公司组建「流量池」,对池中每一张卡进行限速、流控等管理。</p>
<p>市面上绝大多数「随身 WiFi」自带的流量卡套餐正是来自运营商授权公司的「自组流量池」。绝大多数物联卡商家为了控制成本会采取各种措施进行限制而由于这一行业往往处于缺乏有效监管的灰色地带这些限制大都不会被商家明确写出。</p>
<p>最常见的套路是<strong>虚标流量</strong>。由于这类物联网卡并没有手机号码,也就无法使用运营商官方渠道查询流量使用情况。商家自建流量管理后台,也就有了对数据做手脚的可乘之机。有些商家会将使用的流量按 1.5 倍甚至更高倍率计费,因此,你也许会发现自己的流量不那么「经用」。</p>
<p>另一个套路是<strong>流控</strong>,包括流量封顶和限速。网上销量相当高的某随身 WiFi 商家,电商平台可以看到不少次月开始卡慢、每日设置流量封顶的差评。比如,广告上打着「月享 1500G」实际上也许每天限制使用 50G达量往往会限速甚至封卡。</p>
<p>在市面上,流量池批发流量的价格大约是 0.1 元 / G如果你看到了显著低于这个价格的流量可能需要多斟酌一下是否可靠。</p>
<p>当然,也有正规厂商提供可信的流量池或与运营商直接合作的物联网卡,限制会少不少,不过难以买到。</p>
<h2 id="wu-gou-mai-liu-liang-qia-xu-yao-zhu-yi-de-shi-xiang">五.购买流量卡需要注意的事项</h2>
<ul>
<li><strong>靓号</strong></li>
</ul>
<p><code>大部分流量卡是不能选号的</code>,因为这类具有优惠套餐的卡大多来自不同地区的前任买家,因此靓号数有限,总不能既有好的号码又有优惠套餐;而这就带来第二个问题:</p>
<ul>
<li><strong>号码绑定</strong></li>
</ul>
<p>作为信息时代的重要识别符,电话卡和身份证几乎同样重要,在前任主人信息意识不强的情况下,其<code>大部分社交媒体、生活服务和各种网站的帐号都会遗留下来,这就需要我们去一一解绑</code>;作者曾经买了一张宁夏的流量卡,结果通过验证和社工成功进入了前主人的微信和淘宝帐号,当然现在已经注销了;部分平台不支持注销的,只能继续使用前号;<code>甚至有概率被前号主的债务人打电话催债</code>;因此我们一定要小心谨慎;</p>
<ul>
<li><strong>归属地</strong></li>
</ul>
<p>由于前面所讲的原因,<code>流量卡的归属地大部分是随机的</code>,比如青海,宁夏等等;这样一来当别人打电话时会看到地址为中国宁夏之类,可能会误以为是诈骗电话;当然这样也有不被看到地址的好处,所谓各有优点。</p>
<ul>
<li><strong>信号</strong></li>
</ul>
<p><code>SIM卡本身对信号没有影响除非氧化严重难以识别</code>;真正影响体验的不只是手机基带,还有你所在地区中三大<code>运营商的基站分布</code>;因此,购买之前可以先查看一下你所在地区哪个运营商信号最好,从而对症下药。</p>
<ul>
<li><strong>副卡</strong></li>
</ul>
<p>有些小伙伴在买完流量卡后打算作为主力卡使用那这样原先的卡套餐就没必要了可以办理8元保号套餐让号码可以继续使用。</p>
<ul>
<li><strong>流量</strong></li>
</ul>
<p>不少校园套餐,使用了<code>定向流量</code>或区域流量即仅可在指定APP使用或指定省内使用而非全国流量/通用流量。而宣传的额外流量往往以流量包形式给出此流量包不同活动获得方式也不同办完卡后进入营业厅的APP流量可能不会马上出现这是因为系统的延迟以及运营商的计时方式<code>有些卡需要在月初才能有全部的流量</code>,后几天按百分比计算,下个月就正常了。</p>
<ul>
<li><strong>激活</strong></li>
</ul>
<p>注意要<code>实名购卡</code>,且收获地址要足够详细,会有专门的快递小哥和你线下激活,预充值,注意接收电话!</p>
<ul>
<li><strong>注销</strong></li>
</ul>
<p><code>每个运营商最多办5张电话卡</code>因此一个人一辈子最多只能从三大运营商办理一共15张卡因此注销需谨慎流量卡大部分可以线上异地注销但也要仔细看清楚条款。</p>
<hr />
<p><strong>Done.</strong></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/awesome-arch-linux/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">综合工程:Arch-linux 安装与配置</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-accurate-pronunciation/">
<span class="button__text">乱七八糟:常见发音错误术语集合</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,370 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-cslearning/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-cslearning/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-cslearning/">乱七八糟:计算机科学优质视频</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2024-05-31
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 CSdiy珠玉在前,为CS教育做出了极大贡献.这里分享一些优质的CS学习相关视频.</p>
<span id="continue-reading"></span><h2 id="ji-suan-ji-zu-jian-fa-zhan-li-shi">计算机组件发展历史</h2>
<ul>
<li><a href="https://www.bilibili.com/video/BV1ME421A78n/">CPU发展史</a></li>
<li><a href="https://www.bilibili.com/video/BV1gb421h7C4/">BIOS发展史</a></li>
<li><a href="https://www.bilibili.com/video/BV1H5m6YkE9c/">存储器发展史</a></li>
<li><a href="https://www.bilibili.com/video/BV1h2w5eREfD/">显示器发展史</a></li>
<li><a href="https://www.bilibili.com/video/BV1ru411M7Hc/">计算机发展史</a></li>
<li><a href="https://www.bilibili.com/video/BV1Zc411D7sG/">操作系统发展史</a></li>
</ul>
<h2 id="ji-suan-ji-zu-jian-yuan-li">计算机组件原理</h2>
<ul>
<li><a href="https://www.bilibili.com/video/BV1BG4y137mG/">【装机教程】全网最好的装机教程,没有之一</a></li>
<li><a href="https://www.bilibili.com/video/BV1xQ4y1b7JS/">从零开始认识主板</a></li>
<li><a href="https://www.bilibili.com/video/BV1xE421j7Uv/">从零开始认识显卡</a></li>
<li><a href="https://www.bilibili.com/video/BV1Ab411d7zn/">如何合理科学的选择电源功率的大小?</a></li>
<li><a href="https://www.bilibili.com/video/BV1Wz411B7Tf/">OLED与LCD屏幕工作原理与优劣科普</a></li>
<li><a href="https://www.bilibili.com/video/BV1Me4y1k72b/">LCD OLED QLED mini-LED等显示技术的区别</a></li>
<li><a href="https://www.bilibili.com/video/BV1kk4y167rk/">显示器的色域和色准是什么东西?</a></li>
<li><a href="https://www.bilibili.com/video/BV1FK4y1x7bk/">Gsync Freesync 垂直同步工作原理科普</a></li>
<li><a href="https://www.bilibili.com/video/BV1Ca4y1W73e/">电脑散热器工作原理科普</a></li>
<li><a href="https://www.bilibili.com/video/BV1Qv411t7ZL/">硬盘的SATA M.2 NGFF NVME是什么意思详解硬盘的总线协议与接口</a></li>
<li><a href="https://www.bilibili.com/video/BV19T4y1R71r/">键鼠是怎么工作的8K回报率有意义吗</a></li>
<li><a href="https://www.bilibili.com/video/BV1ca411t7qf/">音响耳机麦克风这些设备是怎么工作的?</a></li>
<li><a href="https://www.bilibili.com/video/BV1G94y1g7Up">如何选择存储卡SD、TF和CFe卡有哪些区别</a></li>
</ul>
<h2 id="ji-suan-ji-bo-wu-zhi">计算机博物志</h2>
<ul>
<li><a href="https://www.bilibili.com/video/BV1qW4y1L7tN/">DES的生与死</a></li>
<li><a href="https://www.bilibili.com/video/BV1S541127qR/">MD5为何不再安全</a></li>
<li><a href="https://www.bilibili.com/video/BV1DS4y1R7hM/">战争密码(上集)如何复刻一台恩格玛机</a></li>
<li><a href="https://www.bilibili.com/video/BV1M34y1o7ca/">战争密码(中集)蝴蝶的翅膀</a></li>
<li><a href="https://www.bilibili.com/video/BV1PL4y1H77Z/">战争密码(下集)炸弹机</a></li>
<li><a href="https://www.bilibili.com/video/BV1y5411D7a6/">被遗忘的科学天才:沃尔特·皮茨</a></li>
<li><a href="https://www.bilibili.com/video/BV11R4y1b7zc/">最后的黑客:理查德·马修·斯托曼</a></li>
</ul>
<h2 id="ji-suan-ji-ti-xi-jie-gou">计算机体系结构</h2>
<ul>
<li><a href="https://www.bilibili.com/video/BV1Ct42177Y6/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">普林斯顿大学-计算机科学:算法、理论和机器(GPT 翻译)</a></li>
<li><a href="https://www.bilibili.com/video/BV1bx421D7Xd/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">计算机体系结构( 2024 年春)</a></li>
<li><a href="https://www.bilibili.com/video/BV1VF4m1u7xi/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">台湾科技大学:计算机组成 2023-刘一宇</a></li>
<li><a href="https://www.bilibili.com/video/BV1ZW4y1w7M6/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">国科大:计算机体系结构胡伟武、汪文祥</a></li>
<li><a href="https://www.bilibili.com/video/BV1aC4y1X7VF/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">CMU15213/15513-2023Spring:深入理解计算机系统(英)</a></li>
<li><a href="https://www.bilibili.com/video/BV1964y1j7gk/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">UCBerkeley-CS61C:计算机体系结构(GPT 翻译)</a></li>
<li><a href="https://www.bilibili.com/video/BV1ua4y1a72K/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">Stanford-CS107:计算机组织与系统</a></li>
<li><a href="https://www.bilibili.com/video/BV1Zp421y7Ex/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">耶路撒冷希伯来大学:从零开始构建现代计算机(GPT 翻译)</a></li>
<li><a href="https://space.bilibili.com/91181150/channel/seriesdetail?sid=3700435&amp;ctype=0">威廉玛丽学院:计算机体系结构建模与仿真(英)</a></li>
</ul>
<h2 id="cao-zuo-xi-tong-ji-suan-ji-zu-cheng">操作系统 /计算机组成</h2>
<ul>
<li><a href="https://space.bilibili.com/491131440/channel/collectiondetail?sid=146887">操作系统实现</a></li>
<li><a href="https://space.bilibili.com/18777618/channel/collectiondetail?sid=801384">操作系统速成-2022 秋冬朋辈辅学录播</a></li>
<li><a href="https://space.bilibili.com/354767108/channel/collectiondetail?sid=373847">CSAPP-深入理解计算机系统-讲解</a></li>
<li><a href="https://space.bilibili.com/2107852263/channel/collectiondetail?sid=690279">“一生一芯”</a></li>
<li><a href="https://space.bilibili.com/28086502/channel/collectiondetail?sid=674585">MIT6.828/6.S081 操作系统课程教程</a></li>
<li><a href="https://space.bilibili.com/12995787/channel/collectiondetail?sid=196337">从零开始自制操作系统</a></li>
<li><a href="https://space.bilibili.com/202224425/channel/collectiondetail?sid=1116786">2023 南京大学 “操作系统:设计与实现” (蒋炎岩)</a></li>
<li><a href="https://space.bilibili.com/40333442/channel/collectiondetail?sid=444904&amp;ctype=0">厦门大学-操作系统原理( 2022 春)</a></li>
<li><a href="https://www.bilibili.com/video/BV1B341117Ez?p=6">现代操作系统:原理与实现(上海交通大学)</a></li>
<li><a href="https://www.bilibili.com/video/BV1wv4y1S7xm/">操作系统原理:清华大学陈渝教授</a></li>
<li><a href="https://space.bilibili.com/4564101/channel/series">深入理解计算机系统---个人讲解</a></li>
<li><a href="https://www.bilibili.com/video/BV1RK4y1R7Kf/">深入理解计算机系统-CSAPP 重点导读</a></li>
<li><a href="https://www.bilibili.com/video/BV1hf4y1P7qW/">Dr.Dng 陪跑 CSAPP: bigONE 《深入理解计算机系统》</a></li>
<li><a href="https://space.bilibili.com/31359187/channel/seriesdetail?sid=2310084">CS162 操作系统-精译(更新中)</a></li>
<li><a href="https://www.bilibili.com/video/BV1nb411K7DT/">台湾清华大学 - 操作系统 Operating Systems - 黄能富教授</a></li>
<li><a href="https://www.bilibili.com/video/BV1i2421K7P1?p=2&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">CS537:操作系统导论 Spring2018(英)</a></li>
<li><a href="https://www.bilibili.com/video/BV1iy421q74x/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">中山大学:操作系统原理-2024</a></li>
<li><a href="https://www.bilibili.com/video/BV1a7411w7tC/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">2020 年春季:南京大学计算机系统基础 PA 在线课-汪亮</a></li>
<li><a href="https://www.bilibili.com/video/BV1pK4y1C7es/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">教你写一个简单的 CPU</a></li>
<li><a href="https://www.bilibili.com/video/BV1194y157ku/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">台湾大学:信号与系统-李琳山</a></li>
<li><a href="https://www.bilibili.com/video/BV1mW421A7Wi/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">信号与系统漫谈</a></li>
<li><a href="https://www.bilibili.com/video/BV1iA4m137ML/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">嵌入式系统-南开大学李庆诚教授-2024 春</a></li>
</ul>
<h2 id="bian-yi-xiang-guan-ruan-jian-fen-xi">编译相关 /软件分析</h2>
<ul>
<li><a href="https://space.bilibili.com/2919428/channel/collectiondetail?sid=342930&amp;ctype=0">南京大学《软件分析》课程 2020</a></li>
<li><a href="https://space.bilibili.com/296494084/channel/collectiondetail?sid=571708">手写一个 RISC-V 编译器!初学者友好的实战课程</a></li>
<li><a href="https://space.bilibili.com/479141149/channel/collectiondetail?sid=837891">南京大学软件学院编译原理课程</a></li>
<li><a href="https://www.bilibili.com/video/BV1FA4m1P7kn/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">湖南大学:2024 计科拔尖班《编译原理》</a></li>
<li><a href="https://www.bilibili.com/video/BV1WC4y1k768/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">KAISTCS420:编译器设计 2020Spring(机翻)</a></li>
</ul>
<h2 id="shu-ju-jie-gou-suan-fa-xiang-guan">数据结构 /算法相关</h2>
<ul>
<li><a href="https://space.bilibili.com/33807373/channel/collectiondetail?sid=442054&amp;ctype=0">东北大学2021 2022 春季学期算法设计与分析</a></li>
<li><a href="https://space.bilibili.com/474662253/channel/collectiondetail?sid=1114093">南京大学《 2023 算法设计与分析》- 黄宇</a></li>
<li><a href="https://space.bilibili.com/390606417/channel/collectiondetail?sid=1120423">南京大学《 2023 算法设计与分析》- 徐经纬</a></li>
<li><a href="https://www.bilibili.com/video/BV1nJ411V7bd/">数据结构与算法基础(青岛大学-王卓)</a></li>
<li><a href="https://space.bilibili.com/26340287/channel/collectiondetail?sid=5221">跟懒猫老师快乐学数据结构</a></li>
<li><a href="https://www.bilibili.com/video/BV12V4y1Z78b/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">香港科技大学:高级算法 &amp; Advanced Algorithms</a></li>
</ul>
<h2 id="ji-suan-ji-wang-luo">计算机网络</h2>
<ul>
<li><a href="https://space.bilibili.com/327247876/channel/collectiondetail?sid=60187">计算机网络-通熟易懂讲解每个知识要点</a></li>
<li><a href="https://www.bilibili.com/video/BV1JV411t7ow/">中科大郑烇、杨坚全套-计算机网络(自顶向下方法)</a></li>
<li><a href="https://www.bilibili.com/video/BV1c4411d7jb/">计算机网络微课堂</a></li>
</ul>
<h2 id="cheng-xu-yu-yan-bian-cheng-yu-yan">程序语言 /编程语言</h2>
<ul>
<li><a href="https://space.bilibili.com/283614758/channel/collectiondetail?sid=514109">计算机程序的构造与解释( SICP, Python 版)</a></li>
<li><a href="https://www.bilibili.com/video/BV1xE411N74T/">计算机语言 x86 汇编语言:从实模式到保护模式(操作系统引导课)</a></li>
<li><a href="https://space.bilibili.com/1453436642/video">程序语言理论与实现</a></li>
<li><a href="https://www.bilibili.com/video/BV1Xx41117tr/">CS 公开课:计算机程序的构造和解释( SICP </a></li>
<li><a href="https://www.bilibili.com/video/BV1v64y1Q78o?p=34">精译</a><a href="https://www.bilibili.com/video/BV1v64y1Q78o?p=34">-UC Berkeley 公开课-CS61A [计算机程序的构造和解释] (Spring 2021)</a></li>
<li><a href="https://www.bilibili.com/video/BV1hb4y1A71J?p=4&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">计算机程序的构造和解释 (SICP) Python 版 教程(录制持续更新中)</a></li>
</ul>
<h2 id="ruan-jian-gong-cheng">软件工程</h2>
<ul>
<li><a href="https://space.bilibili.com/507030405/channel/seriesdetail?sid=1878983&amp;ctype=0">南京大学-2023 软件工程与计算 I</a></li>
<li><a href="https://www.bilibili.com/video/BV15y421h7j7/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">2024 Rust 现代实用教程</a></li>
</ul>
<h2 id="shu-ju-ku">数据库</h2>
<ul>
<li><a href="https://space.bilibili.com/87476569/channel/collectiondetail?sid=695667">数据库系统( DBMS </a></li>
<li><a href="https://space.bilibili.com/31359187/channel/seriesdetail?sid=2310086">CMU15-445-精译(更新中)</a></li>
<li><a href="https://www.bilibili.com/video/BV15u4y1Q71R/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">清华大学计算机系:数据库管理系统-李国良</a></li>
<li><a href="https://space.bilibili.com/23722270/channel/collectiondetail?sid=89600&amp;spm_id_from=333.788.0.0">中文讲解版-CMU15-445:数据库内核</a></li>
</ul>
<h2 id="bing-xing-cheng-xu-she-ji">并行程序设计</h2>
<ul>
<li><a href="https://www.bilibili.com/video/BV1XM4y1S7wy?p=5">并行程序设计 谭光明</a></li>
<li><a href="https://space.bilibili.com/263032155/channel/collectiondetail?sid=53025">高性能并行编程与优化</a></li>
<li><a href="https://www.bilibili.com/video/BV1Yt411W7td/">新竹清华大学:并行计算与并行编程课程</a></li>
</ul>
<h2 id="mi-ma-xue">密码学</h2>
<ul>
<li><a href="https://space.bilibili.com/445312136/channel/collectiondetail?sid=988395&amp;spm_id_from=333.788.0.0">分布式密码学:Dora Dōjō x THUBA</a></li>
<li><a href="https://www.bilibili.com/video/BV1WL411d7Zi/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">新火公开课-密码学基础系列课程</a></li>
<li><a href="https://www.bilibili.com/video/BV1Ht411w7Re/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">Stanford:密码学(有翻译)</a></li>
</ul>
<h2 id="gong-ju">工具</h2>
<ul>
<li><a href="https://space.bilibili.com/171431343/channel/collectiondetail?sid=1213483">浙江大学:「实用技能拾遗」 2023 春夏朋辈辅学</a></li>
<li><a href="https://space.bilibili.com/443605967/channel/collectiondetail?sid=266172">Obsidian 公开课</a></li>
</ul>
<h2 id="qi-ta">其他</h2>
<ul>
<li>
<p><a href="https://www.bilibili.com/video/BV1xa4y1g7sZ/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">自制双语字幕-计算机教育缺失的一课(2020)</a></p>
</li>
<li>
<p><a href="https://www.bilibili.com/video/BV1SF4m1u7SU?p=27&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">CMU15-440:分布式系统(英)</a></p>
</li>
<li>
<p><a href="https://www.bilibili.com/video/BV1Hz4y1c7EZ/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">数字电路(对应的 MIT 数电)-UP 主讲解</a></p>
</li>
<li>
<p><a href="https://www.bilibili.com/video/BV1Vt411X7JF/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">北京大学肖臻老师《区块链技术与应用》公开课</a></p>
</li>
<li>
<p><a href="https://space.bilibili.com/494117284/channel/series">《智能计算系统-从深度学习到大模型》</a></p>
</li>
</ul>
<h2 id="shu-xue-xiang-guan">数学相关</h2>
<ul>
<li><a href="https://www.bilibili.com/video/BV1jR4y1M78W/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">北大丘维声教授清华高等代数课程 1080P 高清修复版</a></li>
<li><a href="https://www.bilibili.com/video/BV1Nr4y1U7qC/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">中国科学技术大学-数学分析(B1)-程艺老师</a></li>
<li><a href="https://www.bilibili.com/video/BV1T5411P7wi/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">北京大学公开课:数学分析(上下全 112 讲无级数部分)</a></li>
<li><a href="https://www.bilibili.com/video/BV1bi4y1K7vn/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">复变函数(复分析) [中英双字] 已完结</a></li>
<li><a href="https://www.bilibili.com/video/BV1sX4y1Y7jH/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">数学分析陈纪修无障碍重制版</a></li>
<li><a href="https://www.bilibili.com/video/BV1fK411K7MA/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">2020 齐震宇老师微積分 02 班</a></li>
<li><a href="https://www.bilibili.com/video/BV1mJ411r7ZB/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">高等代数学-复旦大学-谢启鸿-高清</a></li>
<li><a href="https://www.bilibili.com/video/BV1d7411v7zu/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">离散数学-东北大学</a></li>
<li><a href="https://space.bilibili.com/610062295/channel/seriesdetail?sid=2558242&amp;ctype=0">统计学-个人 UP 主</a></li>
</ul>
<h2 id="zhe-xue-xiang-guan">哲学相关</h2>
<ul>
<li><a href="https://www.bilibili.com/video/BV1y64y1r7Mt/?spm_id_from=333.337.search-card.all.click&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">中国人民大学:西方哲学史-张志伟</a></li>
<li><a href="https://www.bilibili.com/video/BV1hp4y1p7ye/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">赵林、邓晓芒-西方哲学史(旧版)</a></li>
<li><a href="https://www.bilibili.com/video/BV19u4y1s7ug/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">台湾大学:逻辑学-傅皓政</a></li>
<li><a href="https://www.bilibili.com/video/BV1tt411h7TT/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">康德专题研究-邓晓芒</a></li>
<li><a href="https://www.bilibili.com/video/BV1P54y1G7EW/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">劳动关系学院:美学原理-2021 年春-杨宁</a></li>
<li><a href="https://www.bilibili.com/video/BV1aZ4y167bp/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">符号学入门</a></li>
</ul>
<h2 id="ren-wen-yi-shu-jian-zhu-dian-ying-she-hui-xue">人文/艺术/建筑/电影/社会学</h2>
<ul>
<li><a href="https://www.bilibili.com/video/BV1D7411D7h4/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91"> MIT全球建筑史 4.605 A Global History of Architecture )(英文)</a></li>
<li><a href="https://www.bilibili.com/video/BV1FL4y1e7nt/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">现代社会理论基础-中英字幕</a></li>
<li><a href="https://www.bilibili.com/video/BV1Ti42117sw/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">中英双字-艺术史速成课</a></li>
<li><a href="https://space.bilibili.com/477533700/channel/collectiondetail?sid=1737877&amp;spm_id_from=333.788.0.0">贡布里希《艺术的故事》视频解说版</a></li>
<li><a href="https://space.bilibili.com/386246830/channel/collectiondetail?sid=1837138&amp;spm_id_from=333.788.0.0">摄影指导公开课-VFS/北电毕业生</a></li>
<li><a href="https://space.bilibili.com/386246830/channel/collectiondetail?sid=1871554">导演公开课-北电/VFS 毕业生</a></li>
<li><a href="https://www.bilibili.com/video/BV1EG4y187wq/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">劳动关系学院:文学理论-2021 年秋-杨宁</a></li>
<li><a href="https://www.bilibili.com/video/BV1sR4y1W77y/?spm_id_from=333.999.0.0&amp;vd_source=cc4bfbaa0f8c6c363ff9afecce036d91">劳动关系学院:西方文论-2021 年秋-杨宁</a></li>
<li><a href="https://www.bilibili.com/video/BV1as411M7DG/?spm_id_from=333.999.0.0">周传基讲电影</a></li>
</ul>
<h2 id="zong-he">综合</h2>
<ul>
<li><a href="https://space.bilibili.com/479038960/channel/collectiondetail?sid=997541">精读 c++primer</a></li>
<li><a href="https://space.bilibili.com/1268065381/channel/collectiondetail?sid=1163347">计算机图形学游戏方向-2023 年春季第 2 次迭代-谭剑</a></li>
<li><a href="https://space.bilibili.com/1356949475/channel/collectiondetail?sid=1211802">Linux 文件系统九讲-陈硕</a></li>
<li><a href="https://space.bilibili.com/30933812/channel/collectiondetail?sid=240551">DDIA 读书逐章分享</a></li>
<li><a href="https://www.bilibili.com/video/BV1aE411o7qd/">机器学习-白板推导系列</a></li>
<li><a href="https://space.bilibili.com/395471891/channel/collectiondetail?sid=1213523">陈明-南京大学 23 春-面向对象编程基础</a></li>
<li><a href="https://www.bilibili.com/video/BV1Xy4y1b7SK/">每个程序员都应该知道的内存知识 (带你走读 Ulrich Drepper 的经典论文)</a></li>
</ul>
<h2 id="hou-ji">后记</h2>
<p>待续...</p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/windows-5-py/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">Windows系列(5):Python开发配置</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-server-set/">
<span class="button__text">乱七八糟:服务器初始化与安全设置</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

231
public/about-gfs/index.html Normal file
View File

@@ -0,0 +1,231 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-gfs/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-gfs/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-gfs/">乱七八糟:GFS项目考量笔记</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2025-03-18
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 最近nekoray项目归档,考量新的singbox前端时发现这个项目不错,不过在Arch linux中运行有一些小问题,这里做个总结。</p>
<span id="continue-reading"></span><h2 id="an-zhuang-zui-xin-ban">安装最新版:</h2>
<p>安装gui-for-singbox的时候发现仓库的1.9.2版本release被作者删除,无法安装,于是:</p>
<ul>
<li>在AUR仓库中下载<strong>aur-gui-for-singbox.tar.gz</strong>,解压进入aur-gui-for-singbox目录;</li>
<li><strong>更改.SRCINFO文件</strong>,使其版本号为最新;</li>
<li><strong>使用makepkg -si构建并安装</strong>这个包,缺少的png图片可以直接下载并放进目录;</li>
<li>如果有错误<strong>刷新密钥环</strong>sudo pacman-key --refresh-keys;</li>
</ul>
<h2 id="wu-fa-da-kai-wu-fa-shi-yong-tunmo-shi">无法打开/无法使用TUN模式:</h2>
<ul>
<li>安装成功,进入<code>/opt/gui-for-singbox</code>,运行<code>sudo chown -R your_username:your_group /opt/gui-for-singbox</code>,使其可以被非root用户启动;</li>
<li>执行<code>sudo setcap cap_net_bind_service,cap_net_admin,cap_dac_override=+ep /opt/gui-for-singbox/your_executable</code>命令,并在设置-内核中点击盾牌-钥匙图标,使Tun模式可以有特权运行。</li>
</ul>
<h2 id="mian-mi-ma-yun-xing-tunmo-shi">免密码运行TUN模式:</h2>
<ul>
<li>检查 polkit 服务是否正在运行</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>systemctl status polkit
</span></code></pre>
<ul>
<li>若返回状态为除 active (running) 之外的结果,运行</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl enable --now polkit
</span></code></pre>
<ul>
<li>创建 polkit 策略</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo vi /etc/polkit-1/rules.d/99-nopassword.rules
</span></code></pre>
<ul>
<li>添加以下内容并保存退出</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>polkit.addRule(function (action, subject) {
</span><span> if (
</span><span> (action.id == &quot;org.freedesktop.resolve1.set-domains&quot; ||
</span><span> action.id == &quot;org.freedesktop.resolve1.set-default-route&quot; ||
</span><span> action.id == &quot;org.freedesktop.resolve1.set-dns-servers&quot;) &amp;&amp;
</span><span> subject.local &amp;&amp;
</span><span> subject.active &amp;&amp;
</span><span> subject.isInGroup(&quot;wheel&quot;)
</span><span> ) {
</span><span> return polkit.Result.YES;
</span><span> }
</span><span>});
</span></code></pre>
<ul>
<li>将当前用户添加至 wheel 组中,注意Debian 与衍生系统需要先创建 wheel 组,然后运行:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo usermod -G wheel 当前用户
</span></code></pre>
<ul>
<li>重新加载 polkit 使更改生效</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl restart polkit
</span></code></pre>
<hr />
<p><strong>Done.</strong></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/network-frp/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">网络艺术:FRP使用指南</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-markdown/">
<span class="button__text">乱七八糟:Markdown使用快速教程</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

714
public/about-git/index.html Normal file
View File

@@ -0,0 +1,714 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-git/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-git/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-git/">乱七八糟:Git使用简明手册</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2023-12-15
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 Git作为现代软件开发中不可或缺的版本控制工具常常让初学者感到困惑。本文旨在介绍 Git 的全流程安装和基本使用,希望能够帮助新手更轻松地理解和掌握 Git 的基本概念和操作。</p>
<span id="continue-reading"></span><h2 id="an-zhuang-git">安装git</h2>
<ul>
<li>
<p>Windows<a href="https://git-scm.com/download/">Git-download</a></p>
</li>
<li>
<p>Archlinux<code>sudo pacman -S git</code></p>
</li>
</ul>
<h2 id="yuan-li">原理</h2>
<p>一个Git仓库的目录里面包括<code>工作目录</code>(即我们要追踪的代码)以及<code>.git</code>目录Git 在这里存储自己的数据。Git 维护了三棵“树”:第一个是你的 <code>工作目录</code>,它持有实际文件;第二个是 <code>暂存区Index</code>,它像个缓存区域,临时保存你的改动;最后是 <code>HEAD</code>,它指向你最后一次提交的结果。</p>
<p><img src="http://marklodato.github.io/visual-git-guide/basic-usage.svg.png" alt="git-tree" /></p>
<h2 id="chuang-jian-xin-cang-ku">创建新仓库</h2>
<p>首先我们需要得到一个Git仓库一般有两种方法</p>
<ul>
<li>在本地初始化之后连接到远程;</li>
<li>在远程创建后”下载“到本地。</li>
</ul>
<p><strong>方法一</strong>
创建新文件夹,在你的项目目录中运行以下命令:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git init --initial-branch=main
</span></code></pre>
<p>这里设置默认仓库主分支名称为 main,避免因为 main/master 名称不同导致的推送问题。</p>
<blockquote>
<p>Git目前默认的主分支为 master和 github 默认分支 main 不同,这使得默认配置下 git 往往连接失败。除了创建的时候设定外还可以通过以下方法改变默认分支。</p>
</blockquote>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git config --global init.defaultBranch main //将默认分支修改成main
</span></code></pre>
<p><strong>方法二</strong></p>
<p>克隆远端服务器上的仓库:</p>
<ul>
<li>HTTPS方法<code>git clone https://github.com/Dichgrem/script.git</code></li>
<li>或者使用SSH方法<code>git clone git@github.com:Dichgrem/script.git</code></li>
</ul>
<blockquote>
<p>建议使用SSH方法如果你使用HTTPS方法则提交代码时需要手动输入用户名/密码使用SSH方法则只需要在<code>~/.ssh/config</code>中配置即可。</p>
</blockquote>
<h2 id="pei-zhi">配置</h2>
<p>Git的设置文件为.gitconfig它可以在用户主目录下全局配置也可以在项目目录下项目配置</p>
<ul>
<li>显示当前的Git配置</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git config --list
</span></code></pre>
<ul>
<li>编辑Git配置文件</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git config -e [--global]
</span></code></pre>
<ul>
<li>设置提交代码时的用户信息</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git config [--global] user.name &quot;[name]&quot;
</span><span>git config [--global] user.email &quot;[email address]&quot;
</span></code></pre>
<ul>
<li>设置大小写敏感windows不区分大小写的解决办法</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git config core.ignorecase false
</span></code></pre>
<ul>
<li>配置git默认使用的编辑器</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git config --global core.editor &quot;nvim&quot;
</span></code></pre>
<h2 id="lian-jie-yuan-cheng-cang-ku">连接远程仓库</h2>
<p>连接到远程仓库并推送需要证明你有权写入仓库。早期Github可以使用密码认证现在则使用密钥认证。</p>
<ul>
<li>生成密钥:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>ssh-keygen -t rsa -b 4096 -C &quot;your_email@example.com&quot;
</span></code></pre>
<ul>
<li>
<p>生成的文件位于<code>~/.ssh/config</code>路径下,带.pub后缀的文件为公钥不带.pub后缀的为私钥使用<code>cat ~/.ssh/id_rsa.pub</code>将公钥添加到github/gitee的设置-SSH中。</p>
</li>
<li>
<p>随后使用 <code>ssh-add</code> 命令将生成的密钥添加到 SSH 代理中。</p>
</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>ssh-add ~/.ssh/github_key
</span><span>ssh-add ~/.ssh/gitee_key
</span></code></pre>
<ul>
<li><code>~/.ssh/config</code> 文件中配置不同的主机别名以及相应的密钥文件。编辑该文件并添加内容,例如:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span># GitHub repository 1
</span><span>
</span><span>Host github1
</span><span>
</span><span> HostName github.com
</span><span>
</span><span> User git
</span><span>
</span><span> IdentityFile ~/.ssh/github_key
</span><span>
</span><span># GitHub repository 2
</span><span>
</span><span>Host github2
</span><span>
</span><span> HostName gitee.com
</span><span>
</span><span> User git
</span><span>
</span><span> IdentityFile ~/.ssh/gitee_key
</span></code></pre>
<ul>
<li>连接到github</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>ssh -T git@github.com
</span></code></pre>
<ul>
<li>添加远程仓库:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git remote add origin &lt;remote_repository_url&gt;
</span><span>
</span><span># 例如git remote add origin git@github.com:Dichgrem/dichos.git
</span></code></pre>
<blockquote>
<p>如果你运行<code>git remote -v</code>发现URL为HTTP格式则可以用下面的命令改为Git格式</p>
</blockquote>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span># 例如git remote set-url origin git@github.com:Dichgrem/dichos.git
</span></code></pre>
<h2 id="chuang-jian-fen-zhi">创建分支</h2>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git branch main
</span></code></pre>
<p>这将创建一个名为 main 的分支。</p>
<ul>
<li>删除分支</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git branch -d master
</span></code></pre>
<ul>
<li>使用大写强制删除</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git branch -D master
</span></code></pre>
<h2 id="tian-jia-he-ti-jiao">添加和提交</h2>
<p>你可以提出更改(把它们添加到暂存区),使用如下命令:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git add &lt;filename&gt;
</span><span>git add *
</span></code></pre>
<p>这是 git 基本工作流程的第一步;使用如下命令以实际提交改动:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git commit -m &quot;代码提交信息&quot;
</span><span># 例如git commit -m &quot;Initial commit&quot;
</span></code></pre>
<p>现在,你的改动已经提交到了 <strong>HEAD</strong>,但是还没到你的远端仓库。</p>
<ul>
<li>添加指定文件到暂存区</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git add [file1] [file2] ...
</span></code></pre>
<ul>
<li>添加指定目录到暂存区,包括子目录</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git add [dir]
</span></code></pre>
<ul>
<li>添加当前目录的所有文件到暂存区</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git add .
</span></code></pre>
<p>添加每个变化前,都会要求确认</p>
<ul>
<li>对于同一个文件的多处变化,可以实现分次提交</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git add -p
</span></code></pre>
<ul>
<li>删除工作区文件,并且将这次删除放入暂存区</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git rm [file1] [file2] ...
</span></code></pre>
<ul>
<li>停止追踪指定文件,但该文件会保留在工作区</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git rm --cached [file]
</span></code></pre>
<ul>
<li>改名文件,并且将这个改名放入暂存区</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git mv [file-original] [file-renamed]
</span></code></pre>
<h2 id="tui-song-gai-dong">推送改动</h2>
<p>你的改动现在已经在本地仓库的 <strong>HEAD</strong> 中了。执行如下命令以将这些改动提交到远端仓库:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git push origin main
</span></code></pre>
<p>可以把 <strong>main</strong> 换成你想要推送的任何分支,如<strong>master</strong>或者<strong>test</strong></p>
<p>如果你的远程仓库是最新的,可以使用以下命令更新本地仓库:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git pull
</span></code></pre>
<blockquote>
<p>Verified</p>
</blockquote>
<p>在 GitHub 的 commit 历史中看到的 “Verified” 标记,表示该提交是经过 签名验证signed commit 的,也就是 GitHub 能确认这个 commit 的确是由声明的提交者签名并发布的。可以通过GPG或者SSH配置</p>
<ul>
<li>GPG方式</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo pacman -S gnupg //安装 GPG
</span><span>gpg --full-generate-key //生成 GPG 密钥
</span><span>gpg --list-secret-keys --keyid-format=long //查看你生成的密钥 ID
</span><span>git config --global user.signingkey ABCDEF1234567890 //让 Git 使用该密钥签名
</span><span>git config --global commit.gpgsign true //启用自动签名所有提交
</span><span>gpg --armor --export ABCDEF1234567890 //导出公钥并添加到 GitHub
</span></code></pre>
<p>然后前往<code>GitHub → Settings → SSH and GPG keys → New GPG key</code>粘贴并保存。</p>
<ul>
<li>SSH方式</li>
</ul>
<p>可以用你平时登录 GitHub 的同一个 SSH 密钥:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git config --global gpg.format ssh //让 Git 使用 SSH 格式签名
</span><span>git config --global user.signingkey ~/.ssh/Github.pub //指定使用的 SSH 公钥
</span><span>git config --global commit.gpgsign true //表示自动签名所有提交
</span></code></pre>
<p>然后前往<code>Settings → SSH and GPG keys → New SSH key → Signing key</code>粘贴并保存。</p>
<ul>
<li>本地查看</li>
</ul>
<p>首先创建这个文件:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>mkdir -p ~/.ssh
</span><span>nano ~/.ssh/allowed_signers
</span></code></pre>
<p>写入你的 <code>test@mail.com ssh-ed25519 AAAABBBBBBBBBBBBBBBBxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</code>并保存。
随后配置Git信任该文件</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git config --global gpg.ssh.allowedSignersFile ~/.ssh/allowed_signers
</span></code></pre>
<p>随后使用<code>git log --show-signature</code>即可查看本地log中的</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>Good &quot;git&quot; signature for test@mail.com with ED25519 key SHA256:ssh-ed25519 AAAABBBBBBBBBBBBBBBBBBBBB
</span></code></pre>
<h2 id="he-bing-fen-zhi">合并分支</h2>
<p>分支是用来将特性开发绝缘开来的。比如你在本地的test分支新增了一个功能想要合并到主分支中。</p>
<p>创建一个叫做“test”的分支并切换过去</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git checkout -b test
</span></code></pre>
<p>新增某些功能后切换回主分支:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git checkout master
</span></code></pre>
<p>在主分支上执行合并操作,将 test 分支的改动合并到主分支:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git merge test
</span></code></pre>
<p>推送完成后可以把新建的分支删掉:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git branch -d test
</span></code></pre>
<h3 id="fen-zhi-chang-yong-cao-zuo">分支常用操作</h3>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>- 列出所有本地分支
</span><span>git branch
</span><span>
</span><span>- 列出所有远程分支
</span><span>git branch -r
</span><span>
</span><span>- 列出所有本地分支和远程分支
</span><span>git branch -a
</span><span>
</span><span>- 列出所有本地分支,并展示没有分支最后一次提交的信息
</span><span>git branch -v
</span><span>
</span><span>- 列出所有本地分支,并展示没有分支最后一次提交的信息和远程分支的追踪情况
</span><span>git branch -vv
</span><span>
</span><span>- 列出所有已经合并到当前分支的分支
</span><span>git branch --merged
</span><span>
</span><span>- 列出所有还没有合并到当前分支的分支
</span><span>git branch --no-merged
</span><span>
</span><span>- 新建一个分支,但依然停留在当前分支
</span><span>git branch [branch-name]
</span><span>
</span><span>- 新建一个分支,并切换到该分支
</span><span>git checkout -b [branch]
</span><span>
</span><span>- 新建一个与远程分支同名的分支,并切换到该分支
</span><span>git checkout --track [branch-name]
</span><span>
</span><span>- 新建一个分支指向指定commit
</span><span>git branch [branch] [commit]
</span><span>
</span><span>- 新建一个分支,与指定的远程分支建立追踪关系
</span><span>git branch --track [branch] [remote-branch]
</span><span>
</span><span>- 切换到指定分支,并更新工作区
</span><span>git checkout [branch-name]
</span><span>
</span><span>- 切换到上一个分支
</span><span>git checkout -
</span><span>
</span><span>- 建立追踪关系,在现有分支与指定的远程分支之间
</span><span>git branch --set-upstream-to=[remote-branch]
</span><span>git branch --set-upstream [branch] [remote-branch] - 已被弃用
</span><span>
</span><span>- 合并指定分支到当前分支
</span><span>git merge [branch]
</span><span>
</span><span>- 中断此次合并(你可能不想处理冲突)
</span><span>git merge --abort
</span><span>
</span><span>- 选择一个commit合并进当前分支
</span><span>git cherry-pick [commit]
</span><span>
</span><span>- 删除分支
</span><span>git branch -d [branch-name]
</span><span>
</span><span>#新增远程分支 远程分支需先在本地创建,再进行推送
</span><span>git push origin [branch-name]
</span><span>
</span><span>- 删除远程分支
</span><span>git push origin --delete [branch-name]
</span><span>git branch -dr [remote/branch]
</span></code></pre>
<h2 id="biao-qian">标签</h2>
<p>Git 的 tag 功能主要用于<code>给仓库历史中的某个特定提交打上“标签”</code>,通常用于标记版本发布点(例如 v1.0、v2.0 等),以<code>便于后续的版本定位、回溯和发布管理</code></p>
<h3 id="biao-qian-lei-xing">标签类型</h3>
<p>Git 提供两种类型的标签:</p>
<ul>
<li>
<p>附注标签Annotated Tag会创建成一个完整的 Git 对象,存储打标签者的名字、邮箱、日期和标签说明,还可采用 GPG 进行签名。推荐用于正式发布,因为包含更多元数据和安全信息。</p>
</li>
<li>
<p>轻量标签Lightweight Tag实际上只是对某个提交的引用不保存额外信息类似一个固定的分支。适用于临时标记或非正式用途。</p>
</li>
</ul>
<h3 id="chuang-jian-biao-qian">创建标签</h3>
<ul>
<li>创建附注标签</li>
</ul>
<p>使用 -a 参数表示“annotated”并用 -m 提供标签说明。例如,给当前提交创建一个名为 v1.0 的附注标签:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git tag -a v1.0 -m &quot;发布版本 v1.0&quot;
</span></code></pre>
<p>这会在 Git 数据库中生成一个完整的标签对象,可通过 git show v1.0 查看标签信息和对应的提交详情。</p>
<p>如果需要给旧提交贴标签,可以在命令末尾指定提交的 SHA 值(部分 SHA 也可):</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git tag -a v1.0 &lt;commit-sha&gt; -m &quot;发布版本 v1.0&quot;
</span></code></pre>
<ul>
<li>创建轻量标签</li>
</ul>
<p>直接指定标签名即可,不加任何参数:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git tag v1.0-light
</span></code></pre>
<p>轻量标签仅仅是一个提交引用,因此查看时不会显示附加信息。</p>
<h3 id="lie-chu-biao-qian">列出标签</h3>
<ul>
<li>列出所有标签</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git tag
</span></code></pre>
<ul>
<li>还可以使用通配符过滤:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git tag -l &quot;v1.*&quot;
</span></code></pre>
<p>这样便于管理和筛选大量标签。</p>
<ul>
<li>查看标签详细信息</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git show v1.0
</span></code></pre>
<p>这会显示标签对象的元数据以及对应的提交记录。</p>
<h3 id="tui-song-biao-qian">推送标签</h3>
<p><code>默认情况下git push 不会将本地标签推送到远程仓库。推送标签有两种方式:</code></p>
<ul>
<li>推送单个标签</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git push origin v1.0
</span></code></pre>
<ul>
<li>一次性推送所有标签</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git push origin --tags
</span></code></pre>
<h3 id="shan-chu-biao-qian">删除标签</h3>
<ul>
<li>删除本地标签</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git tag -d v1.0
</span></code></pre>
<ul>
<li>删除远程标签</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git push origin --delete v1.0
</span></code></pre>
<h2 id="ri-zhi">日志</h2>
<p>如果你想了解本地仓库的历史记录,最简单的命令就是使用:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git log
</span></code></pre>
<ul>
<li>只看某一个人的提交记录:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git log --author=bob
</span></code></pre>
<ul>
<li>一个压缩后的每一条提交记录只占一行的输出:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git log --pretty=oneline
</span></code></pre>
<ul>
<li>看看哪些文件改变了:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git log --name-status
</span></code></pre>
<h2 id="sheng-cheng-bu-ding">生成补丁</h2>
<p>比如你修改了项目中的<code>fs/proc/base.c</code>,然后</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git add fs/proc/base.c
</span><span>git commit -m &quot;fix:base&quot;
</span><span>git format-patch origin/16.0
</span></code></pre>
<p>即可在目录下生成补丁<code>0001-fix-base.patch</code>.</p>
<h2 id="shan-chu-qian-yi-ge-ti-jiao-ji-lu">删除前一个提交记录</h2>
<p>有时候手滑或者不想使用一个commit说明可以用以下命令撤销上一个 commit</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git reset --soft HEAD~1
</span></code></pre>
<p>这个命令会撤销上一个 commit但保留文件修改代码仍然在工作区。适用于 想要重新提交amend或调整 commit 的情况。</p>
<p>如果你想彻底删除更改(不保留代码修改),可以使用:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git reset --hard HEAD~1
</span></code></pre>
<blockquote>
<p>注意:--hard 会清除未提交的更改,无法恢复。</p>
</blockquote>
<h2 id="git-mu-lu-zhong-zhu-yao-wen-jian-he-zi-mu-lu-de-jie-gou-ji-qi-zuo-yong"><code>.git</code> 目录中主要文件和子目录的结构及其作用</h2>
<h3 id="file-folder-git-mu-lu-jie-gou-gai-lan">📁 <code>.git</code> 目录结构概览</h3>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>.git/
</span><span>├── HEAD
</span><span>├── config
</span><span>├── description
</span><span>├── hooks/
</span><span>├── index
</span><span>├── info/
</span><span>│ └── exclude
</span><span>├── logs/
</span><span>│ ├── HEAD
</span><span>│ └── refs/
</span><span>├── objects/
</span><span>│ ├── info/
</span><span>│ └── pack/
</span><span>├── refs/
</span><span>│ ├── heads/
</span><span>│ ├── remotes/
</span><span>│ └── tags/
</span></code></pre>
<h3 id="dividers-he-xin-wen-jian-he-mu-lu-shuo-ming">🗂️ 核心文件和目录说明</h3>
<ul>
<li>
<p><strong>HEAD</strong>:指向当前检出的分支或提交。例如,<code>ref: refs/heads/main</code> 表示当前位于 <code>main</code> 分支。</p>
</li>
<li>
<p><strong>config</strong>:仓库级别的配置文件,包含用户名、邮箱、远程仓库等信息.</p>
</li>
<li>
<p><strong>description</strong>:用于描述仓库,仅供 GitWeb 等工具使用。</p>
</li>
<li>
<p><strong>hooks/</strong>:存放 Git 钩子脚本的目录,可用于在特定操作前后执行自定义脚本,如 <code>pre-commit</code><code>post-merge</code> 等.</p>
</li>
<li>
<p><strong>index</strong>暂存区staging area的索引文件记录了即将提交的文件信息。</p>
</li>
<li>
<p><strong>info/</strong>:包含辅助信息,如 <code>exclude</code> 文件用于定义仓库级别的忽略规则。</p>
</li>
<li>
<p><strong>logs/</strong>:记录了引用(如分支、标签)的更新历史,有助于追踪操作记录。</p>
</li>
<li>
<p><strong>objects/</strong>:存储 Git 的所有对象,包括:</p>
<ul>
<li><strong>blob</strong>:文件内容。</li>
<li><strong>tree</strong>:目录结构。</li>
<li><strong>commit</strong>:提交对象,记录提交信息和指向的树对象。</li>
<li><strong>tag</strong>:标签对象。
这些对象以 SHA-1 哈希命名,前两位作为子目录,其余作为文件名。</li>
</ul>
</li>
<li>
<p><strong>refs/</strong>:存储所有引用,包括:</p>
<ul>
<li><strong>heads/</strong>:本地分支。</li>
<li><strong>remotes/</strong>:远程分支。</li>
<li><strong>tags/</strong>:标签。</li>
</ul>
</li>
</ul>
<h2 id="commitgui-fan">Commit规范</h2>
<h3 id="ti-jiao-xin-xi-de-ji-ben-ge-shi">提交信息的基本格式</h3>
<ul>
<li>Header头部
格式:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>&lt;type&gt;[可选的 scope]: &lt;简短描述&gt;
</span></code></pre>
<p>type 表示提交类型feat新功能、fix修复bug等。
scope 是可选的,用于指出变更影响的模块或范围。
简短描述 用于概述本次提交的核心内容,通常使用祈使语气。</p>
<ul>
<li>
<p>Body正文
用于详细说明变更的动机、方法以及可能的影响,建议每行不超过 72 个字符。</p>
</li>
<li>
<p>Footer脚注
可选部分,用来引用相关 issue、任务或说明破坏性变更例如BREAKING CHANGE: ...)。例如:</p>
</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>Fixes #123
</span></code></pre>
<p>这可以在提交后自动关闭相关问题。</p>
<h3 id="chang-jian-de-commit-lei-xing">常见的 Commit 类型</h3>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>- feat新功能的添加
</span><span> 示例feat(user): 添加用户注册功能
</span><span>
</span><span>- fix修复 Bug
</span><span> 示例fix(parser): 修复解析错误导致程序崩溃
</span><span>
</span><span>- docs文档相关的修改
</span><span> 示例docs(readme): 更新使用说明
</span><span>
</span><span>- style代码格式、排版等不影响代码逻辑的调整
</span><span> 示例style: 优化代码缩进和空格
</span><span>
</span><span>- refactor代码重构不涉及新功能或 Bug 修复
</span><span> 示例refactor: 优化数据处理逻辑
</span><span>
</span><span>- perf性能优化
</span><span> 示例perf: 提升数据查询速度
</span><span>
</span><span>- test添加或修改测试代码
</span><span> 示例test: 补充用户登录单元测试
</span><span>
</span><span>- build构建相关的变更如依赖管理、构建脚本等
</span><span> 示例build: 更新 webpack 配置
</span><span>
</span><span>- ci持续集成相关的修改
</span><span> 示例ci: 调整 GitHub Actions 配置
</span><span>
</span><span>- chore其他杂项维护不涉及源代码或测试文件的修改
</span><span> 示例chore: 更新项目依赖
</span><span>
</span><span>- revert回滚到上一个版本的提交
</span><span> 示例revert: 撤销上次提交
</span></code></pre>
<hr />
<p><strong>Done.</strong></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/about-junk-cleanup/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">乱七八糟:垃圾清理的艺术</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/network-isps/">
<span class="button__text">网络艺术:国内&#x2F;国际骨干ISP线路整理</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

291
public/about-gpg/index.html Normal file
View File

@@ -0,0 +1,291 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-gpg/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-gpg/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-gpg/">乱七八糟:GPG使用小记</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2025-06-17
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 PGP/GPG 的核心功能——公钥加密、数字签名、信任管理广泛用于各个行业,本文简单说明了其使用方法。</p>
<span id="continue-reading"></span><h2 id="shen-me-shi-pgp-yu-gpg">什么是 PGP 与 GPG</h2>
<ul>
<li>
<p><strong>PGPPretty Good Privacy</strong></p>
<ul>
<li>由 Phil Zimmermann 于 1991 年发布,是第一个面向个人用户的大众化加密软件。</li>
<li>采用公钥加密体系,用于对邮件和文件进行加密、签名与验证。</li>
</ul>
</li>
<li>
<p><strong>GPGGNU Privacy Guard又称 GnuPG</strong></p>
<ul>
<li>项目发起于 1997 年,由 Free Software Foundation 推动,是 GPL 许可的自由软件实现。</li>
<li>完全兼容 OpenPGP 标准RFC 4880可无缝替代 PGP 软件。</li>
</ul>
</li>
</ul>
<h2 id="li-shi-yan-ge">历史沿革</h2>
<table><thead><tr><th>时间</th><th>事件</th></tr></thead><tbody>
<tr><td>1991 年</td><td>Phil Zimmermann 发布 PGP 1.0,标志个人加密进入大众市场</td></tr>
<tr><td>1994 年</td><td>PGP 因出口管制遭到美国政府调查,后续改版加密算法合规化</td></tr>
<tr><td>1997 年</td><td>GNU 推出 GnuPG目标创建一个开源、自由的 OpenPGP 实现</td></tr>
<tr><td>2001 年</td><td>OpenPGP 正式成为 IETF 标准RFC 2440</td></tr>
<tr><td>2006 年</td><td>GnuPG 2.0 发布引入多子系统gpg-agent、dirmngr 等)</td></tr>
<tr><td>2014 年</td><td>OpenPGP 更新为 RFC 4880bisGnuPG 不断改进对新算法的支持</td></tr>
</tbody></table>
<h2 id="he-xin-zuo-yong">核心作用</h2>
<table><thead><tr><th>应用领域</th><th>描述</th></tr></thead><tbody>
<tr><td><strong>1. 电子邮件加密与签名</strong></td><td>- <strong>PGP/MIME</strong>:通过邮件客户端(如 Thunderbird + Enigmail对正文和附件加密并用私钥签名。<br>- <strong>PGP inline</strong>:将加密/签名内容以纯文本形式嵌入邮件,兼容性更强。</td></tr>
<tr><td><strong>2. 文件与目录的加密签名</strong></td><td>- <strong>单文件加密/解密</strong><br><code>gpg --encrypt --recipient Alice file.txt</code><br><code>gpg --decrypt file.txt.gpg</code><br>- <strong>归档目录加密</strong>:使用 <code>tar</code> 打包后再加密。<br>- <strong>签名校验</strong><br><code>gpg --detach-sign --armor release.tar.gz</code><br><code>gpg --verify release.tar.gz.asc release.tar.gz</code></td></tr>
<tr><td><strong>3. 软件包与系统镜像签名</strong></td><td>- Linux 包管理签名APT、pacman-key 等验证来源可信性。<br>- 容器镜像签名:结合 TUF/Notary 使用 GPG 保护 Docker 镜像完整性。</td></tr>
<tr><td><strong>4. SSH 公钥管理与登录</strong></td><td>- 将 GPG 子密钥作为 SSH 密钥使用:<br><code>echo "enable-ssh-support" &gt;&gt; ~/.gnupg/gpg-agent.conf</code><br><code>gpgconf --reload gpg-agent</code><br><code>ssh-add -L</code><br>- 好处私钥集中管理、PIN保护、跨平台一致。</td></tr>
<tr><td><strong>5. 自动化脚本与 CI/CD 环境</strong></td><td>- 用 GPG 自动签名构建产物,供用户验证。<br>- 将签名集成进发布脚本(如 <code>release.sh</code>),自动生成 <code>.sig</code> 并上传。</td></tr>
<tr><td><strong>6. 文档与 PDF 数字签名</strong></td><td>- 利用 <code>gpgsm</code><code>OpenPGP.js</code> 对 PDF、Office 文档签名,保障法律或审计合规性。</td></tr>
<tr><td><strong>7. 密码管理与“密码库”</strong></td><td>- <strong>pass</strong>:每个密码为一个 GPG 加密文件,支持 Git 同步和版本控制。<br>- <strong>git-crypt</strong>:自动加密 Git 仓库中的敏感文件,仅授权者可解密。</td></tr>
<tr><td><strong>8. 安全聊天与即时通讯</strong></td><td>- 将 OTR 会话密钥托管在 GPG 中(如 <code>mcabber</code> + OTR实现端到端加密。</td></tr>
<tr><td><strong>9. 时间戳与不可篡改日志</strong></td><td>- 结合 GPG 签名与时间戳协议(如 RFC 3161验证文件/日志未被篡改。</td></tr>
<tr><td><strong>10. 去中心化信任与身份管理</strong></td><td>- 使用 Web of Trust 模型构建可信身份网络用于开源社区签名、Key Signing Party、LDAP 交换等。</td></tr>
</tbody></table>
<h2 id="an-zhuang-gnupg">安装 GnuPG</h2>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>paru -S gnupg
</span></code></pre>
<h2 id="sheng-cheng-gong-yao-yu-si-yao">生成公钥与私钥</h2>
<p>使用如下命令:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>gpg --full-generate-key
</span></code></pre>
<p>生成流程:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>gpg (GnuPG) 2.4.7; Copyright (C) 2024 g10 Code GmbH
</span><span>This is free software: you are free to change and redistribute it.
</span><span>There is NO WARRANTY, to the extent permitted by law.
</span><span>
</span><span>Please select what kind of key you want:
</span><span> (1) RSA and RSA
</span><span> (2) DSA and Elgamal
</span><span> (3) DSA (sign only)
</span><span> (4) RSA (sign only)
</span><span> (9) ECC (sign and encrypt) *default*
</span><span> (10) ECC (sign only)
</span><span> (14) Existing key from card
</span><span>Your selection? 9 ## 默认选择ECC算法
</span><span>Please select which elliptic curve you want:
</span><span> (1) Curve 25519 *default*
</span><span> (4) NIST P-384
</span><span> (6) Brainpool P-256
</span><span>Your selection? 1 ## 默认选择标准椭圆曲线
</span><span>Please specify how long the key should be valid.
</span><span> 0 = key does not expire
</span><span> &lt;n&gt; = key expires in n days
</span><span> &lt;n&gt;w = key expires in n weeks
</span><span> &lt;n&gt;m = key expires in n months
</span><span> &lt;n&gt;y = key expires in n years
</span><span>Key is valid for? (0) 1y ## 默认有效期为一年
</span><span>Key expires at 2026年06月17日 星期三 13时06分27秒 CST
</span><span>Is this correct? (y/N) y
</span><span>
</span><span>GnuPG needs to construct a user ID to identify your key.
</span><span>
</span><span>## 输入名字与邮箱,comment可省略
</span><span>
</span><span>Real name: xxx
</span><span>Email address: xxx@gmail.com
</span><span>Comment:
</span><span>You selected this USER-ID:
</span><span> &quot;xxx &lt;xxx@gmail.com&gt;&quot;
</span><span>
</span><span>Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit?
</span><span>Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
</span><span>We need to generate a lot of random bytes. It is a good idea to perform
</span><span>some other action (type on the keyboard, move the mouse, utilize the
</span><span>disks) during the prime generation; this gives the random number
</span><span>generator a better chance to gain enough entropy.
</span><span>We need to generate a lot of random bytes. It is a good idea to perform
</span><span>some other action (type on the keyboard, move the mouse, utilize the
</span><span>disks) during the prime generation; this gives the random number
</span><span>generator a better chance to gain enough entropy.
</span></code></pre>
<h2 id="lie-chu-mi-yao">列出密钥</h2>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>gpg --list-secret-keys --keyid-format long
</span></code></pre>
<p>其中<code>sec ed25519/xxxxxxxxx 2025-06-17 [SC] [expires: 2026-06-17]</code>的xxxxxxxxx即为公钥ID。</p>
<h2 id="fa-bu-gong-yao">发布公钥</h2>
<p>例如上传你的 key</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>gpg --send-keys &lt;你的LongKeyID&gt;
</span></code></pre>
<p>默认为你的 gpg.conf 中配置的 keyserver也可以显式指定</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>gpg --keyserver hkps://keys.openpgp.org --send-keys &lt;KeyID&gt;
</span></code></pre>
<p>也可以使用如下命令导出公钥为可读 ASCII 格式类似ssh-keys随后即可发布在个人博客上等等。</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>gpg --armor --export &lt;KeyID&gt; &gt; mypubkey.asc
</span></code></pre>
<h2 id="che-xiao-gong-yao">撤销公钥</h2>
<p>如果怀疑密钥被泄露或被中间人替换立即发布“撤销证书”revocation certificate并上传到 keyserver。</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>gpg --gen-revoke &lt;KeyID&gt; &gt; revoke.asc
</span></code></pre>
<p>上传撤销证书后,所有人都能知道该公钥已不再可信。</p>
<hr />
<p><strong>Done.</strong></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/network-ssh/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">网络艺术:SSH使用指南</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-sports/">
<span class="button__text">乱七八糟:运动健身基本理论</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,314 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-junk-cleanup/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-junk-cleanup/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-junk-cleanup/">乱七八糟:垃圾清理的艺术</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2023-11-19
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 在从前的机械硬盘时代,由于硬盘空间小,且没有时常清理垃圾文件,常常导致硬盘空间严重不足;特别是在以 Windows 平台为代表的 C/D盘 体系下。那么,我们常说的垃圾清理,释放硬盘空间,到底是在清理什么?哪些文件可以被清理?</p>
<span id="continue-reading"></span><h2 id="la-ji-qing-li">垃圾清理</h2>
<p>通常指的是清理计算机硬盘上的<code>不必要或临时</code>文件,以释放硬盘空间。这些文件包括:</p>
<ol>
<li><strong>临时文件:</strong> 程序在运行时会生成临时文件,以帮助它们完成任务。这些文件在任务完成后不再需要,占据了硬盘空间,却没有被回收。</li>
<li><strong>缓存文件:</strong> 许多程序比如浏览器会在本地存储缓存数据以加快后续访问速度。但是这些缓存文件可能会占据大量空间尤其是在长时间不清理的情况下这里点名国产的微信和QQ。</li>
</ol>
<blockquote>
<p>注意,清理缓存文件可能意味着加载速度变慢或需要重新下载,耗费流量,视情况而清理。</p>
</blockquote>
<ol start="3">
<li><strong>日志文件:</strong> 许多应用程序会生成日志文件来记录其活动和错误。这些日志文件可能会积累并占用大量空间,尤其是在长时间不清理的情况下。</li>
</ol>
<blockquote>
<p>特别是C盘上的log文件因为它们记录了系统和应用程序的运行情况可能会变得相当庞大。因此定期清理C盘中的log文件是维护系统性能和释放磁盘空间的重要步骤之一。</p>
</blockquote>
<ul>
<li><strong>备份文件:</strong> 如果您的系统或软件定期创建备份或快照,旧版本备份可能会占用大量空间。您可以定期清理旧版本备份以释放空间。</li>
<li><strong>大型文件:</strong> 有些应用程序可能会生成大型临时数据文件,如媒体编辑软件的临时视频或音频文件。这些文件在任务完成后可能会被遗留,占据大量空间。</li>
</ul>
<blockquote>
<p>例如PS加载的工作文件放C盘的话会占用大量空间。</p>
</blockquote>
<ol start="4">
<li><strong>卸载残余:</strong> 在卸载应用程序时,有时候可能会留下一些残余文件,如配置文件、注册表项等,这些文件可能会继续占用硬盘空间,并且在一定程度上影响系统的性能。定期清理这些卸载残余是维护系统健康的一部分。</li>
</ol>
<blockquote>
<p>还记得删除牛马软件时的挽留选项吗?里面往往藏着“保存个人配置”。</p>
</blockquote>
<ol start="5">
<li><strong>重复文件:</strong> 在计算机系统中,有时候可能会出现重复的文件,这些文件可能是因为用户错误地复制或下载了多个副本,也可能是由于应用程序或系统错误导致文件重复。这些重复文件不仅占用了宝贵的存储空间,而且也增加了文件管理的复杂性。</li>
</ol>
<blockquote>
<p>这里再次点名微信同样一个文件能保存好几次且不给出具体的存放路径怪不得动辄十几个G,尾大不掉,真的离谱!</p>
</blockquote>
<ol start="6">
<li><strong>回收站文件:</strong> 删除文件时,它们通常不会立即从硬盘上删除,而是移动到回收站。清空回收站可以释放这些被删除文件所占据的空间。</li>
</ol>
<blockquote>
<p>注意,尽管清空回收站会立即释放硬盘空间,但实际上删除的文件并不会立即被擦除,而是被标记为可以被覆写的空间。在某些情况下,专业的数据恢复软件可能仍然可以找回部分被删除的文件。因此,如果希望永久删除文件而不被恢复,需要使用专门的文件删除工具,来覆盖文件内容以确保无法恢复。</p>
</blockquote>
<ol start="7">
<li><strong>下载文件夹:</strong> 下载文件夹可能会积累大量临时文件、安装程序、文档和媒体文件。定期清理下载文件夹可以帮助释放硬盘空间。</li>
<li><strong>不再使用的程序:</strong> 有时候,安装的一些程序你已经不再使用或需要它们。卸载这些程序可以释放相关的硬盘空间。</li>
<li><strong>浏览器插件与扩展:</strong> 未使用的浏览器插件和扩展可能会占用不必要的资源和空间。删除不再需要的插件和扩展可以帮助优化浏览器性能并释放空间。</li>
<li><strong>安装程序和更新文件:</strong> 在安装程序或更新软件时,临时安装文件可能会留在系统中。这些文件通常可以安全删除,因为安装程序已经完成。</li>
</ol>
<blockquote>
<p>例如安卓上的安装包APK文件和下载安装后的EXE文件。</p>
</blockquote>
<p>需要注意的是,往往有许多牛马软件安装目录和文件目录不规范,或者是在安装时没有设定好,会产生大量垃圾文件;这时就需要垃圾清理工具或者手动遍历文件夹(注意隐藏文件夹)。</p>
<h2 id="la-ji-qing-li-ruan-jian">垃圾清理软件</h2>
<h3 id="windows-ping-tai">Windows 平台:</h3>
<ol>
<li><strong><a href="https://diskanalyzer.com/">WizTree</a></strong> WizTree是一款功能强大清理垃圾文件/在Windows上找到大文件以释放磁盘空间的首选程序...超级易于使用,快速闪电.</li>
<li><strong>Disk Cleanup磁盘清理</strong> Windows 自带的磁盘清理工具,可以帮助您清理不必要的系统文件,包括临时文件、回收站等。</li>
<li><strong><a href="https://github.com/bleachbit/bleachbit">BleachBit</a></strong> BleachBit 是一款开源的系统清理工具,可以帮助您清理系统中的临时文件、缓存、浏览器历史等。</li>
</ol>
<h3 id="macos-ping-tai">macOS 平台:</h3>
<ol>
<li><strong>CleanMyMac X</strong> CleanMyMac X 是一款功能强大的系统优化工具,可以帮助您清理系统中的垃圾文件、优化性能,并提供了其他的实用工具。</li>
<li><strong>Onyx</strong> Onyx 是一款免费的 macOS 系统维护和优化工具,可以帮助您清理系统缓存、日志文件、临时文件等。</li>
<li><strong>AppCleaner</strong> AppCleaner 是一款简单易用的应用程序卸载工具,可以帮助您彻底清理 macOS 系统中的应用程序及其相关文件。</li>
</ol>
<h3 id="linux-ping-tai">Linux 平台:</h3>
<ol>
<li><strong>BleachBit</strong> BleachBit 不仅适用于 Windows也提供了 Linux 版本,可以帮助您清理系统中的临时文件、缓存、浏览器历史等。</li>
<li><strong>Stacer</strong> Stacer 是一款开源的系统优化和监控工具,提供了垃圾清理、系统管理、系统监控等功能,适用于多种 Linux 发行版。</li>
<li><strong>SweeperKDE 扫除者):</strong> Sweeper 是 KDE 桌面环境的一部分,提供了简单易用的垃圾清理功能,可以帮助您清理系统中的临时文件、缓存等。</li>
</ol>
<h2 id="arch-linux-qing-li">Arch linux 清理</h2>
<ol>
<li>
<p><strong>缓存清理</strong>:</p>
<ul>
<li><code>sudo pacman -Sc</code>: 清理包缓存,删除已安装的但不再需要的软件包。</li>
<li><code>sudo pacman -Scc</code>: 进一步清理所有包文件,包括已下载的包。</li>
</ul>
</li>
<li>
<p><strong>系统日志</strong>:</p>
<ul>
<li><code>/var/log</code> 目录下包含系统日志文件。你可以删除较旧的日志文件,或者使用日志轮换工具,如 <code>logrotate</code></li>
</ul>
</li>
<li>
<p><strong>临时文件</strong>:</p>
<ul>
<li><code>/tmp</code> 目录下包含临时文件。你可以通过 <code>sudo rm -rf /tmp/*</code> 清理它们。</li>
</ul>
</li>
<li>
<p><strong>缓存文件</strong>:</p>
<ul>
<li>一些应用程序会在 <code>~/.cache</code> 目录下存储缓存文件。你可以检查该目录并删除不再需要的文件。</li>
</ul>
</li>
<li>
<p><strong>AUR 缓存</strong>:</p>
<ul>
<li>AUR 辅助工具(如 <code>yay</code>)会在 <code>~/.cache/yay</code> 目录下存储构建和下载的软件包。你可以清理这些文件。</li>
</ul>
</li>
<li>
<p><strong>旧内核</strong>:</p>
<ul>
<li>如果你安装了多个内核版本,你可以删除不再需要的旧内核。首先使用 <code>uname -r</code> 查看当前内核版本,然后使用 <code>sudo pacman -Rns linux-older-kernel</code> 删除不需要的版本。</li>
</ul>
</li>
<li>
<p><strong>不再使用的配置文件</strong>:</p>
<ul>
<li>检查家目录下的隐藏文件,如 <code>~/.config</code>,并删除不再需要的配置文件。</li>
</ul>
</li>
<li>
<p><strong>Docker日志文件</strong>:<br />
使用 <code>docker ps -a</code> 命令查找你感兴趣的容器的 ID。</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>docker ps -a
</span></code></pre>
<p>进入容器的日志目录,路径类似于 <code>/var/lib/docker/containers/&lt;container-id&gt;/</code></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>cd /var/lib/docker/containers/&lt;container-id&gt;/
</span></code></pre>
<p>使用命令清理或删除日志文件。你可以删除所有日志文件,或者只删除特定的日志文件。</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span># 删除所有日志文件
</span><span>rm *.log
</span><span>
</span><span># 删除特定日志文件(例如 stdout 和 stderr
</span><span>rm *-json.log
</span></code></pre>
</li>
</ol>
<h2 id="arch-linux-an-zhuang-bei-fen"><strong>Arch Linux 安装备份</strong></h2>
<p>你可以定期备份 Arch Linux 安装的软件列表,以便在需要时轻松还原。</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>pacman -Qqe &gt; package-list.txt
</span></code></pre>
<p>这将列出所有已安装的软件包,并将其保存到文件 <code>package-list.txt</code> 中。在还原系统时,你可以使用以下命令:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo pacman -S --needed - &lt; package-list.txt
</span></code></pre>
<h2 id="hou-ji">后记</h2>
<p>垃圾文件的产生总是无可避免,这是因为随着使用时间的流逝,系统的熵值也在增大;生命以负熵为食,同样的为系统清理垃圾也是逆熵的一部分。在你的生命中会有许多电子设备,但它们往往只有你一任主人,请善待它们!</p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/about-blog/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">乱七八糟:个人博客搭建</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-git/">
<span class="button__text">乱七八糟:Git使用简明手册</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,660 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-lazyvim/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-lazyvim/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-lazyvim/">乱七八糟:lazyvim快速上手</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2025-04-20
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 LazyVim 是一个基于 Neovim 的现代化配置框架,易于定制和扩展,这里对其介绍并说明使用方法。</p>
<span id="continue-reading"></span><h2 id="lazy">Lazy!</h2>
<blockquote>
<p>Vim 是从早期的 vi 编辑器发展而来的增强版其名称代表“Vi IMproved”。由荷兰程序员 Bram Moolenaar 于 1991 年首次发布。Vim 是开源软件,支持多种操作系统,包括 Unix、Linux、Windows 和 macOS 等。</p>
</blockquote>
<blockquote>
<p>LazyVim 是一个基于 Neovim 的现代化配置框架,旨在简化 Neovim 的配置过程。它通过集成的 lazy.nvim 插件管理器,提供了一种易于定制和扩展配置的方式,结合了从头开始配置的灵活性和预配置设置的便利性 。</p>
</blockquote>
<blockquote>
<p>LazyVim 是在Neovim的基础上进行配置Neovim又继承了vim的操作模式对vim不熟悉的同学可以看<a href="https://vimsheet.com/">这里</a>或者本文末尾的 Vim 速查表.</p>
</blockquote>
<h2 id="an-zhuang">安装</h2>
<p>首先安装neovim,在arch linux上是</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>paru -S neovim
</span></code></pre>
<p>在Ubuntu上是</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo add-apt-repository ppa:neovim-ppa/unstable
</span><span>sudo apt update
</span><span>sudo apt install -y \ neovim git curl unzip build-essential ripgrep fd-find
</span></code></pre>
<p>备份现有配置:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>mv ~/.config/nvim ~/.config/nvim.bak
</span><span>mv ~/.local/share/nvim ~/.local/share/nvim.bak
</span></code></pre>
<p>克隆 LazyVim Starter 模板:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git clone https://github.com/LazyVim/starter ~/.config/nvim
</span></code></pre>
<p>启动 Neovim</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>nvim
</span></code></pre>
<p>首次启动时LazyVim 会自动安装并配置所需的插件。</p>
<h2 id="jie-gou">结构</h2>
<p>LazyVim 的配置目录通常位于<code>~/.config/nvim/</code>中:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>~/.config/nvim
</span><span> tree
</span><span>.
</span><span>├── init.lua
</span><span>├── lazy-lock.json
</span><span>├── lazyvim.json
</span><span>├── LICENSE
</span><span>├── lua
</span><span>│   ├── config
</span><span>│   │   ├── autocmds.lua
</span><span>│   │   ├── keymaps.lua
</span><span>│   │   ├── lazy.lua
</span><span>│   │   └── options.lua
</span><span>│   └── plugins
</span><span>│   ├── example.lua
</span><span>│   └── mp.lua
</span><span>├── README.md
</span><span>└── stylua.toml
</span><span>
</span><span>4 directories, 12 files
</span></code></pre>
<p>另外在<code>~/.local/share/nvim/lazy/LazyVim/lua/lazyvim/plugins/</code>目录下看到的文件结构,是 LazyVim 为其核心插件和扩展插件提供的模块化配置体系。这些配置文件并不直接出现在<code>~/.config/nvim/lua/plugins/</code>目录中,是因为 LazyVim 采用了模块化和懒加载的设计理念,将核心插件和配置封装在其自身的代码库中。</p>
<h3 id="ge-wen-jian-he-mu-lu-de-zuo-yong">各文件和目录的作用</h3>
<ul>
<li>
<p><strong><code>init.lua</code></strong>:主配置文件,负责加载 <code>lua/config/lazy.lua</code>,从而引导整个 LazyVim 的初始化过程。</p>
</li>
<li>
<p><strong><code>lazy-lock.json</code></strong>:由 <code>lazy.nvim</code> 插件管理器生成的锁定文件,记录了已安装插件的精确版本,确保插件的一致性。</p>
</li>
<li>
<p><strong><code>lazyvim.json</code></strong>:用于记录通过 <code>:LazyExtras</code> 命令启用的额外功能Extras便于在不同设备间同步配置。</p>
</li>
<li>
<p><strong><code>LICENSE</code></strong><strong><code>README.md</code></strong>:分别为许可协议和项目说明文档。</p>
</li>
<li>
<p><strong><code>stylua.toml</code></strong><code>stylua</code> 的配置文件,用于格式化 Lua 代码。</p>
</li>
<li>
<p><strong><code>lua/config/</code></strong>:包含 Neovim 的基础配置文件,如自动命令(<code>autocmds.lua</code>)、快捷键(<code>keymaps.lua</code>)、插件管理(<code>lazy.lua</code>)和编辑器选项(<code>options.lua</code>)。这些文件会被 LazyVim 自动加载,无需手动引入。</p>
</li>
<li>
<p><strong><code>lua/plugins/</code></strong>:用于添加或修改插件配置的目录。您可以在此目录中添加新的 Lua 文件,以引入其他插件或更改现有插件的设置。
</p>
</li>
</ul>
<h2 id="lazyvimzi-dai-pei-zhi">Lazyvim自带配置</h2>
<p>在 LazyVim 中插件被分类为已加载Loaded和未加载Not Loaded</p>
<h3 id="white-check-mark-yi-jia-zai-de-cha-jian-loaded">✅ 已加载的插件Loaded</h3>
<ul>
<li>
<p><strong>blink.cmp</strong>:一个高性能、开箱即用的自动补全引擎,旨在替代 <code>nvim-cmp</code>,提供更快的性能和更少的配置需求。</p>
</li>
<li>
<p><strong>bufferline.nvim</strong>:用于在顶部显示缓冲区列表的插件,提供类似于浏览器标签页的界面。</p>
</li>
<li>
<p><strong>friendly-snippets</strong>:一个包含多种语言代码片段的集合,可与多个片段引擎(如 <code>luasnip</code>)配合使用。</p>
</li>
<li>
<p><strong>gitsigns.nvim</strong>:在编辑器中显示 Git 更改标记(如添加、修改、删除)的插件,增强版本控制的可视化。</p>
</li>
<li>
<p><strong>lazy.nvim</strong>LazyVim 的插件管理器,支持懒加载和依赖管理,提升启动速度和性能。</p>
</li>
<li>
<p><strong>lualine.nvim</strong>:一个高度可定制的状态栏插件,支持多种主题和组件。</p>
</li>
<li>
<p><strong>mason-lspconfig.nvim</strong> &amp; <strong>mason.nvim</strong>:用于自动安装和配置 LSP语言服务器协议服务器的插件组合简化开发环境的设置。</p>
</li>
<li>
<p><strong>mini.ai</strong><strong>mini.pairs</strong><code>mini.nvim</code> 插件集合的一部分,分别用于增强文本对象操作和自动括号配对功能。</p>
</li>
<li>
<p><strong>noice.nvim</strong>:改进 Neovim 消息和命令行界面的插件,提供更丰富的 UI 体验。</p>
</li>
<li>
<p><strong>nui.nvim</strong>:一个用于构建 Neovim 用户界面的 Lua 库,被多个插件作为依赖使用。</p>
</li>
<li>
<p><strong>nvim-lint</strong>:一个异步代码检查器,支持多种语言的语法和风格检查。</p>
</li>
<li>
<p><strong>nvim-lspconfig</strong>:提供预配置的 LSP 客户端设置,简化语言服务器的集成。</p>
</li>
<li>
<p><strong>nvim-treesitter</strong><strong>nvim-treesitter-textobjects</strong><strong>nvim-ts-autotag</strong>:基于 Tree-sitter 的语法高亮和代码结构分析插件,增强代码编辑体验。</p>
</li>
<li>
<p><strong>persistence.nvim</strong>:自动保存和恢复会话的插件,方便在不同项目之间切换。</p>
</li>
<li>
<p><strong>snacks.nvim</strong>:提供快速导航和编辑功能的插件,提升编辑效率。</p>
</li>
<li>
<p><strong>todo-comments.nvim</strong>:高亮和管理代码中的 TODO、FIXME 等注释的插件,方便任务跟踪。</p>
</li>
<li>
<p><strong>tokyonight.nvim</strong>:一个流行的 Neovim 主题,提供多种配色方案。</p>
</li>
<li>
<p><strong>trouble.nvim</strong>:一个用于显示诊断信息(如 LSP 错误、警告)的插件,提供统一的界面。</p>
</li>
<li>
<p><strong>ts-comments.nvim</strong>:基于 Tree-sitter 的注释插件,支持多语言的智能注释功能。</p>
</li>
<li>
<p><strong>which-key.nvim</strong>:在按下快捷键时弹出可用键位提示的插件,帮助记忆和发现快捷键。</p>
</li>
</ul>
<h3 id="x-wei-jia-zai-de-cha-jian-not-loaded">❌ 未加载的插件Not Loaded</h3>
<ul>
<li>
<p><strong>catppuccin</strong>:一个柔和的 Neovim 主题,提供多种风格的配色方案。</p>
</li>
<li>
<p><strong>conform.nvim</strong>:一个用于代码格式化的插件,支持多种语言的格式化工具。</p>
</li>
<li>
<p><strong>grug-far.nvim</strong>:一个快速的全局查找和替换插件,提供直观的界面和操作。</p>
</li>
<li>
<p><strong>lazydev.nvim</strong>:用于 LazyVim 插件开发的辅助工具,简化开发流程。</p>
</li>
<li>
<p><strong>markdown-preview.nvim</strong>:在浏览器中实时预览 Markdown 文件的插件,提升写作体验。</p>
</li>
<li>
<p><strong>plenary.nvim</strong>:一个 Lua 函数库,提供多种实用功能,被许多插件作为依赖使用。</p>
</li>
</ul>
<h2 id="zi-ding-yi-pei-zhi">自定义配置</h2>
<ul>
<li>
<p><strong>添加插件</strong>:​在 lua/plugins/ 目录下创建一个新的 Lua 文件,返回插件的配置表。</p>
</li>
<li>
<p><strong>修改快捷键</strong>:​编辑 lua/config/keymaps.lua 文件,添加或修改快捷键映射。</p>
</li>
<li>
<p><strong>调整选项</strong>:​编辑 lua/config/options.lua 文件,设置 Neovim 的行为选项。​</p>
</li>
</ul>
<h2 id="chang-yong-kuai-jie-jian">常用快捷键</h2>
<p>LazyVim 默认使用<code>&lt;space&gt; 作为 &lt;leader&gt;</code>\ 作为<code>&lt;localleader&gt;</code>,并通过 which-key.nvim 插件动态展示所有以<code>&lt;space&gt;</code>开头的可用映射,极大降低了记忆成本。​</p>
<ul>
<li><strong>导航与窗口管理</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>- 在窗口间切换Ctrl +h / Ctrl +j / Ctrl +k / Ctrl +l
</span><span>- 调整当前窗口尺寸Ctrl + ↑ / Ctrl + ↓ / Ctrl + ← / Ctrl + →
</span></code></pre>
<ul>
<li><strong>缓冲区切换与管理</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>- 切换到上一个/下一个缓冲区Shift +h / Shift +l
</span><span>- 切换“另一个”缓冲区Space + b + b
</span><span>- 关闭当前缓冲区Space + b + d
</span><span>- 只保留当前缓冲区Space + b + o
</span></code></pre>
<ul>
<li><strong>文件与搜索</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>- 新建文件Space + f + n
</span><span>- 打开文件(普通命令):输入 :e &lt;文件名&gt; 回车
</span><span>- 在项目根目录查找文件Space + Space
</span><span>- 在项目根目录查找文件另一路径Space + f + f
</span><span>- 在当前工作目录查找文件Space + f + F
</span><span>- 查找 Git 管理的文件Space + f + g
</span><span>- 列出最近打开的文件Space + f + r
</span><span>- 列出所有缓冲区Space + ,
</span><span>- 全局全文搜索Space + /
</span></code></pre>
<ul>
<li><strong>分割与终端</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>- 向下分割Space + -
</span><span>- 向右分割Space + |
</span><span>- 关闭当前窗口Space + w + d
</span><span>- 窗口最大化/恢复Space + w + m 或 Space + u + Z
</span><span>- 打开根目录终端Space + f + t
</span><span>- 打开当前目录终端Space + f + T
</span><span>- 切换(隐藏/显示终端Ctrl + /
</span></code></pre>
<ul>
<li><strong>LSP 相关</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>- 跳转到定义g + d
</span><span>- 查找引用g + r
</span><span>- 跳转到实现g + I
</span><span>- 跳转到声明g + D
</span><span>- 查看文档悬停K
</span><span>- 插入模式签名帮助Ctrl + k
</span><span>- 代码操作Space + c + a
</span><span>- 重命名Space + c + r
</span><span>- 运行 CodeLensSpace + c + c
</span><span>- 显示行诊断Space + c + d
</span></code></pre>
<ul>
<li><strong>Git 操作</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>- 查看状态Space + g + s
</span><span>- 查看差异Space + g + d
</span><span>- 查看行级 BlameSpace + g + b
</span><span>- 在浏览器打开当前文件Space + g + B
</span><span>- Git Stashsnacks.nvimSpace + g + S
</span></code></pre>
<ul>
<li><strong>诊断与快速修复</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>- 打开 Location ListSpace + x + l
</span><span>- 打开 Quickfix ListSpace + x + q
</span><span>- 在 Quickfix 跳转:[ q / ] q
</span></code></pre>
<h2 id="tian-jia-cha-jian">添加插件</h2>
<ul>
<li><strong>Markdown预览</strong></li>
</ul>
<p><code>~/config/nvim/lua/plugins/</code>下新建一个mp.lua写入如下配置</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>return {
</span><span> {
</span><span> &quot;iamcco/markdown-preview.nvim&quot;,
</span><span> cmd = { &quot;MarkdownPreviewToggle&quot;, &quot;MarkdownPreview&quot;, &quot;MarkdownPreviewStop&quot; },
</span><span> ft = { &quot;markdown&quot; },
</span><span> build = &#39;:call mkdp#util#install()&#39;
</span><span> }
</span><span>}
</span></code></pre>
<p>随后即可在 Neovim 中打开一个 Markdown 文件,执行以下命令启动预览:​</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>:MarkdownPreview
</span></code></pre>
<h2 id="tips">tips</h2>
<ul>
<li>gcc:注释当前行;</li>
<li>g+ctrl+g:显示信息;</li>
<li>alt+h显示隐藏文件</li>
<li>space+c+f:将当前代码格式化;</li>
<li>设置文件编码<code>:set fileencoding?</code></li>
<li>设置换行符<code>:set fileformat=unix</code></li>
<li>lazyvim的字体是和终端相同的不同单独设置</li>
<li>lazyvim中在侧边栏选择文件按d删除,按y复制,按p粘贴,按a创建,按r重命名</li>
<li>lazyvim中的行号是非自然序的这是为了方便光标移动而设置的你可以在正常模式中通过10k快速移动光标到10行前10j10h10l同理。</li>
<li>LSP快捷操作</li>
</ul>
<table><thead><tr><th>快捷键</th><th>功能</th></tr></thead><tbody>
<tr><td><code>gd</code></td><td>跳转到定义Go to Definition</td></tr>
<tr><td><code>gr</code></td><td>查找引用Go to References</td></tr>
<tr><td><code>K</code></td><td>显示悬浮文档Hover</td></tr>
<tr><td><code>&lt;leader&gt;rn</code></td><td>重命名Rename</td></tr>
<tr><td><code>&lt;leader&gt;ca</code></td><td>Code Action修复</td></tr>
<tr><td><code>gl</code></td><td>显示诊断信息Diagnostic</td></tr>
<tr><td><code>[d</code> / <code>]d</code></td><td>上/下一个诊断问题</td></tr>
</tbody></table>
<h2 id="edit">Edit!</h2>
<blockquote>
<p>编辑器的基本素养</p>
</blockquote>
<p><code>外观</code></p>
<ul>
<li>面板</li>
<li>侧边栏</li>
<li>Git符号</li>
<li>全局主题</li>
<li>文件类型主题</li>
</ul>
<p><code>编辑器</code></p>
<ul>
<li>显示行号</li>
<li>搜索替换</li>
</ul>
<p><code>Code</code></p>
<ul>
<li>高亮</li>
<li>格式化</li>
<li>自动补全</li>
<li>代码调试</li>
</ul>
<p><code>字符处理</code></p>
<ul>
<li>LF/CRLF处理</li>
<li>零宽字符处理</li>
<li>GBK/UTF-8处理</li>
</ul>
<p><code>终端</code></p>
<ul>
<li>打开终端/复用终端</li>
</ul>
<p><code>文件操作</code></p>
<ul>
<li>创建文件/文件夹</li>
<li>打开/关闭/切换文件</li>
<li>复制/粘贴</li>
<li>写入/保存/退出</li>
</ul>
<p><code>其他功能</code></p>
<ul>
<li>工作区切换</li>
<li>gitui</li>
<li>diff历史</li>
</ul>
<h2 id="yi-fen-you-xiu-de-vim-su-cha-biao">一份优秀的 Vim 速查表</h2>
<blockquote>
<p>翻译自<code>https://vimsheet.com/</code></p>
</blockquote>
<p>我整理了一份我每天使用的 Vim 基本命令列表,并提供了一些配置建议,使 Vim 更加实用。因为没有配置的 Vim 使用起来会比较痛苦。</p>
<h2 id="ji-chu-ming-ling">基础命令</h2>
<h3 id="guang-biao-yi-dong-pu-tong-mo-shi-ke-shi-mo-shi">光标移动(普通模式/可视模式)</h3>
<ul>
<li><code>h</code> <code>j</code> <code>k</code> <code>l</code>:左、下、上、右移动</li>
<li><code>w</code> / <code>b</code>:下一个/上一个单词</li>
<li><code>W</code> / <code>B</code>:下一个/上一个以空格分隔的单词</li>
<li><code>e</code> / <code>ge</code>:下一个/上一个单词的结尾</li>
<li><code>0</code> / <code>$</code>:行首/行尾</li>
<li><code>^</code>:行首第一个非空白字符(等同于 <code>0w</code></li>
</ul>
<h3 id="bian-ji-wen-ben">编辑文本</h3>
<ul>
<li><code>i</code> / <code>a</code>:在光标处/之后进入插入模式</li>
<li><code>I</code> / <code>A</code>:在行首/行尾进入插入模式</li>
<li><code>o</code> / <code>O</code>:在当前行下方/上方插入空行</li>
<li><code>Esc</code><code>Ctrl+[</code>:退出插入模式</li>
<li><code>d</code>:删除</li>
<li><code>dd</code>:删除整行</li>
<li><code>c</code>:删除并进入插入模式</li>
<li><code>cc</code>:删除整行并进入插入模式</li>
</ul>
<h3 id="cao-zuo-fu">操作符</h3>
<ul>
<li>操作符也适用于可视模式</li>
<li><code>d</code>:从光标处删除到移动目标</li>
<li><code>c</code>:从光标处删除到移动目标,并进入插入模式</li>
<li><code>y</code>:从光标处复制到移动目标</li>
<li><code>&gt;</code>:缩进一级</li>
<li><code>&lt;</code>:取消缩进一级</li>
<li>操作符可与移动命令组合使用,例如:<code>d$</code> 删除从光标到行尾的内容</li>
</ul>
<h3 id="biao-ji-wen-ben-ke-shi-mo-shi">标记文本(可视模式)</h3>
<ul>
<li><code>v</code>:进入可视模式</li>
<li><code>V</code>:进入行可视模式</li>
<li><code>Ctrl+v</code>:进入块可视模式</li>
<li><code>Esc</code><code>Ctrl+[</code>:退出可视模式</li>
</ul>
<h3 id="jian-tie-ban-cao-zuo">剪贴板操作</h3>
<ul>
<li><code>yy</code>:复制整行</li>
<li><code>p</code>:在光标后粘贴</li>
<li><code>P</code>:在光标前粘贴</li>
<li><code>dd</code>:剪切整行</li>
<li><code>x</code>:删除当前字符</li>
<li><code>X</code>:删除前一个字符</li>
<li>默认情况下,<code>d</code> / <code>c</code> 会将删除的内容复制到剪贴板</li>
</ul>
<h3 id="tui-chu">退出</h3>
<ul>
<li><code>:w</code>:保存文件但不退出</li>
<li><code>:wq</code>:保存并退出</li>
<li><code>:q</code>:退出(如果有修改会失败)</li>
<li><code>:q!</code>:强制退出并放弃修改</li>
</ul>
<h3 id="sou-suo-ti-huan">搜索/替换</h3>
<ul>
<li><code>/pattern</code>:搜索 pattern</li>
<li><code>?pattern</code>:向上搜索 pattern</li>
<li><code>n</code>:重复上一次搜索(同方向)</li>
<li><code>N</code>:重复上一次搜索(反方向)</li>
<li><code>:%s/old/new/g</code>:全文件替换 old 为 new</li>
<li><code>:%s/old/new/gc</code>:全文件替换 old 为 new并逐个确认</li>
</ul>
<h3 id="chang-gui-ming-ling">常规命令</h3>
<ul>
<li><code>u</code>:撤销</li>
<li><code>Ctrl+r</code>:重做</li>
</ul>
<h2 id="gao-ji-ming-ling">高级命令</h2>
<h3 id="guang-biao-yi-dong">光标移动</h3>
<ul>
<li><code>Ctrl+d</code>:向下移动半页</li>
<li><code>Ctrl+u</code>:向上移动半页</li>
<li><code>}</code>:跳转到下一个段落(空行)</li>
<li><code>{</code>:跳转到上一个段落(空行)</li>
<li><code>gg</code>:跳转到文件顶部</li>
<li><code>G</code>:跳转到文件底部</li>
<li><code>:[num]</code>:跳转到指定行号</li>
<li><code>Ctrl+e</code> / <code>Ctrl+y</code>:向下/向上滚动一行</li>
</ul>
<h3 id="zi-fu-sou-suo">字符搜索</h3>
<ul>
<li><code>f [char]</code>:向前移动到指定字符</li>
<li><code>F [char]</code>:向后移动到指定字符</li>
<li><code>t [char]</code>:向前移动到指定字符之前</li>
<li><code>T [char]</code>:向后移动到指定字符之前</li>
<li><code>;</code> / <code>,</code>:重复上一次字符搜索(正向/反向)</li>
</ul>
<h3 id="bian-ji-wen-ben-1">编辑文本</h3>
<ul>
<li><code>J</code>:将下一行合并到当前行</li>
<li><code>r [char]</code>:用指定字符替换当前字符(不进入插入模式)</li>
</ul>
<h3 id="ke-shi-mo-shi">可视模式</h3>
<ul>
<li><code>O</code>:移动到块的另一个角</li>
<li><code>o</code>:移动到标记区域的另一端</li>
</ul>
<h3 id="wen-jian-biao-qian">文件标签</h3>
<ul>
<li><code>:e filename</code>:编辑文件</li>
<li><code>:tabe</code>:打开新标签页</li>
<li><code>gt</code>:切换到下一个标签页</li>
<li><code>gT</code>:切换到上一个标签页</li>
<li><code>:vsp</code>:垂直分割窗口</li>
<li><code>Ctrl+ws</code>:水平分割窗口</li>
<li><code>Ctrl+wv</code>:垂直分割窗口</li>
<li><code>Ctrl+ww</code>:在窗口间切换</li>
<li><code>Ctrl+wq</code>:关闭当前窗口</li>
</ul>
<h3 id="biao-ji">标记</h3>
<ul>
<li>标记允许你跳转到代码中的指定位置</li>
<li><code>m{a-z}</code>:在光标位置设置标记 {a-z}</li>
<li>大写标记 {A-Z} 是全局标记,可跨文件使用</li>
<li><code>'{a-z}</code>:跳转到设置标记的行首</li>
<li><code>''</code>:返回上一个跳转位置</li>
</ul>
<h3 id="wen-ben-dui-xiang">文本对象</h3>
<ul>
<li>例如:<code>def (arg1, arg2, arg3)</code>,光标在括号内</li>
<li><code>di(</code>:删除括号内的内容,即“删除最近括号内的内容”</li>
<li>如果没有文本对象,你需要使用 <code>T(dt)</code> 来实现相同的功能</li>
</ul>
<h3 id="chang-gui-ming-ling-1">常规命令</h3>
<ul>
<li><code>.</code>:重复上一次命令</li>
<li>在插入模式下,<code>Ctrl+r 0</code>:插入最近复制的文本</li>
<li><code>gv</code>:重新选择上一次选中的文本块</li>
<li><code>%</code>:在匹配的 <code>()</code><code>{}</code> 之间跳转</li>
</ul>
<hr />
<p>如果你希望将此速查表保存为 PDF 或打印出来,可以使用 Markdown 编辑器(如 Typora或在线工具如 Dillinger进行导出。</p>
<p>此外Vim 的默认配置可能不够友好,建议你参考以下资源进行配置优化:</p>
<ul>
<li><a href="https://github.com/tpope/vim-sensible">vim-sensible</a>:提供一套合理的默认配置</li>
<li><a href="https://github.com/tpope/vim-pathogen">vim-pathogen</a>:插件管理工具</li>
<li><a href="https://github.com/rking/ag.vim">ag.vim</a>:快速全局搜索插件</li>
<li><a href="https://github.com/ctrlpvim/ctrlp.vim">ctrlp.vim</a>:文件和缓冲区快速切换插件</li>
<li><a href="https://github.com/preservim/nerdcommenter">nerdcommenter</a>:代码注释插件</li>
</ul>
<p>这些插件可以显著提升 Vim 的功能,使其更接近一个完整的 IDE。</p>
<hr />
<p>🔗</p>
<p><a href="https://yelog.org/2024/08/02/write-markdown-in-neovim-experience-and-tips/">用 neovim 写 markdown 是一种什么样的体验</a></p>
<hr />
<p><strong>Done.</strong></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/network-aria2/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">下载系列(3):Aria2使用指南</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-baci/">
<span class="button__text">乱七八糟:Baci实验笔记</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,405 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-markdown/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-markdown/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-markdown/">乱七八糟:Markdown使用快速教程</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2025-04-08
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 本文为 Markdown 教程,内容涵盖 Markdown 的历史、作用、基本语法和显示效果可以在github将本文的源码拷贝供大家参考和学习。</p>
<span id="continue-reading"></span><h1 id="markdown-jiao-cheng">Markdown 教程</h1>
<h2 id="ling-chang-yong-de-markdownbian-ji-qi">零.常用的markdown编辑器</h2>
<ul>
<li>VSCode的<code>Markdown Preview Enhanced</code>插件;</li>
<li>跨平台的<a href="https://obsidian.md/download">obsdian</a>或者<a href="https://github.com/1943time/inkdown">inkdown</a><a href="https://github.com/laurent22/joplin">joplin</a><a href="https://github.com/Zettlr/Zettlr">zettlr</a></li>
</ul>
<h2 id="yi-markdown-jian-jie">一、Markdown 简介</h2>
<h3 id="1-1-shen-me-shi-markdown">1.1 什么是 Markdown</h3>
<p>Markdown 是一种轻量级标记语言最初由约翰·格鲁伯John Gruber在 2004 年创建,其设计目标在于简洁易读,同时能够快速转换为 HTML。Markdown 被广泛用于撰写文档、博客、论坛帖子以及 README 文档,其直观的语法和高度可读性受到开发者和写作者的一致好评。</p>
<h3 id="1-2-markdown-de-li-shi-he-zuo-yong">1.2 Markdown 的历史和作用</h3>
<ul>
<li>
<p><strong>历史沿革:</strong><br />
2004 年左右,随着互联网内容量的增加以及对纯文本格式的需求不断上升,人们开始寻找一种既能保留纯文本的可读性,又能方便地生成格式化内容(如 HTML的解决方案。Markdown 应运而生。经过十多年的发展Markdown 已衍生出多个方言(例如 GitHub Flavored Markdown、CommonMark 等),并被各种编辑器、静态博客生成器(如 Zola、Jekyll、Hugo 等)以及内容管理系统所支持。</p>
</li>
<li>
<p><strong>主要作用:</strong></p>
<ul>
<li><strong>快速排版:</strong> Markdown 语法简单,使用自然语言符号来表示标题、列表、链接、图片等格式。</li>
<li><strong>跨平台兼容:</strong> 由于基于纯文本格式Markdown 文件可以在任何文本编辑器中打开和编辑,而且可以很容易地转换成 HTML、PDF 等格式。</li>
<li><strong>降低学习成本:</strong> 与复杂的 HTML 标记相比Markdown 的语法简单易懂,非常适合非程序员使用。</li>
<li><strong>促进内容创作:</strong> 许多博客平台和文档系统都采用 Markdown 作为主要写作格式,降低了内容创作和协作的门槛。</li>
</ul>
</li>
</ul>
<hr />
<h2 id="er-markdown-ji-ben-yu-fa">二、Markdown 基本语法</h2>
<p>下面详细介绍 Markdown 常用的语法,并演示其在渲染后显示的效果。</p>
<h3 id="2-1-biao-ti">2.1 标题</h3>
<p>使用井号 <code>#</code> 来表示标题井号的数量表示标题级别1~6级</p>
<pre data-lang="markdown" style="background-color:#151515;color:#e8e8d3;" class="language-markdown "><code class="language-markdown" data-lang="markdown"><span># </span><span style="color:#ffb964;">这是一级标题
</span><span>## </span><span style="color:#ffb964;">这是二级标题
</span><span>### </span><span style="color:#ffb964;">这是三级标题
</span><span>#### </span><span style="color:#ffb964;">这是四级标题
</span><span>##### </span><span style="color:#ffb964;">这是五级标题
</span><span>###### </span><span style="color:#ffb964;">这是六级标题
</span></code></pre>
<p><strong>渲染效果:</strong></p>
<h1 id="zhe-shi-yi-ji-biao-ti">这是一级标题</h1>
<h2 id="zhe-shi-er-ji-biao-ti">这是二级标题</h2>
<h3 id="zhe-shi-san-ji-biao-ti">这是三级标题</h3>
<h4 id="zhe-shi-si-ji-biao-ti">这是四级标题</h4>
<h5 id="zhe-shi-wu-ji-biao-ti">这是五级标题</h5>
<h6 id="zhe-shi-liu-ji-biao-ti">这是六级标题</h6>
<hr />
<h3 id="2-2-qiang-diao-wen-ben">2.2 强调文本</h3>
<ul>
<li><em>斜体</em>:在文字两侧加上一个星号 <code>*</code> 或下划线 <code>_</code></li>
<li><strong>加粗</strong>:在文字两侧加上两个星号 <code>**</code> 或下划线 <code>__</code></li>
<li><em><strong>斜体加粗</strong></em>:在文字两侧加上三个星号 <code>***</code></li>
</ul>
<pre data-lang="markdown" style="background-color:#151515;color:#e8e8d3;" class="language-markdown "><code class="language-markdown" data-lang="markdown"><span>*这是斜体*
</span><span>_这也是斜体_
</span><span>
</span><span>**这是加粗**
</span><span>__这也是加粗__
</span><span>
</span><span>***这是斜体加粗***
</span></code></pre>
<p><strong>渲染效果:</strong></p>
<p><em>这是斜体</em><br />
<em>这也是斜体</em></p>
<p><strong>这是加粗</strong><br />
<strong>这也是加粗</strong></p>
<p><em><strong>这是斜体加粗</strong></em></p>
<hr />
<h3 id="2-3-lie-biao">2.3 列表</h3>
<h4 id="wu-xu-lie-biao">无序列表</h4>
<p>使用 <code>-</code><code>*</code><code>+</code> 表示无序列表项。</p>
<pre data-lang="markdown" style="background-color:#151515;color:#e8e8d3;" class="language-markdown "><code class="language-markdown" data-lang="markdown"><span>- 项目 1
</span><span>- 项目 2
</span><span> - 子项目 2.1
</span><span> - 子项目 2.2
</span><span>- 项目 3
</span></code></pre>
<p><strong>渲染效果:</strong></p>
<ul>
<li>项目 1</li>
<li>项目 2
<ul>
<li>子项目 2.1</li>
<li>子项目 2.2</li>
</ul>
</li>
<li>项目 3</li>
</ul>
<h4 id="you-xu-lie-biao">有序列表</h4>
<p>使用数字后面跟点号来表示有序列表:</p>
<pre data-lang="markdown" style="background-color:#151515;color:#e8e8d3;" class="language-markdown "><code class="language-markdown" data-lang="markdown"><span>1. 第一项
</span><span>2. 第二项
</span><span>3. 第三项
</span></code></pre>
<p><strong>渲染效果:</strong></p>
<ol>
<li>第一项</li>
<li>第二项</li>
<li>第三项</li>
</ol>
<hr />
<h3 id="2-4-lian-jie-yu-tu-pian">2.4 链接与图片</h3>
<h4 id="lian-jie">链接</h4>
<p>格式:<a href="https://blog.dich.bid/about-markdown/URL" title="可选标题">链接文字</a></p>
<pre data-lang="markdown" style="background-color:#151515;color:#e8e8d3;" class="language-markdown "><code class="language-markdown" data-lang="markdown"><span>[GitHub](https://github.com </span><span style="color:#556633;">&quot;</span><span style="color:#99ad6a;">GitHub 官网</span><span style="color:#556633;">&quot;</span><span>)
</span></code></pre>
<p><strong>渲染效果:</strong><br />
<a href="https://github.com" title="GitHub 官网">GitHub</a></p>
<h4 id="tu-pian">图片</h4>
<p>格式:<code>![图片替代文本](图片 URL "可选标题")</code></p>
<pre data-lang="markdown" style="background-color:#151515;color:#e8e8d3;" class="language-markdown "><code class="language-markdown" data-lang="markdown"><span>![Markdown Logo](https://upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg </span><span style="color:#556633;">&quot;</span><span style="color:#99ad6a;">Markdown</span><span style="color:#556633;">&quot;</span><span>)
</span></code></pre>
<p><strong>渲染效果:</strong></p>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg" alt="Markdown Logo" /></p>
<hr />
<h3 id="2-5-dai-ma">2.5 代码</h3>
<h4 id="xing-nei-dai-ma">行内代码</h4>
<p>使用反引号 <code>`</code> 来表示行内代码。</p>
<pre data-lang="markdown" style="background-color:#151515;color:#e8e8d3;" class="language-markdown "><code class="language-markdown" data-lang="markdown"><span>使用 `printf()` 函数输出内容。
</span></code></pre>
<p><strong>渲染效果:</strong><br />
使用 <code>printf()</code> 函数输出内容。</p>
<h4 id="dai-ma-kuai">代码块</h4>
<p>代码块使用三个反引号(```)包裹,也可以指定语言以便进行语法高亮。</p>
<pre data-lang="markdown" style="background-color:#151515;color:#e8e8d3;" class="language-markdown "><code class="language-markdown" data-lang="markdown"><span>```</span><span style="color:#7697d6;">python
</span><span style="color:#8fbfdc;">def </span><span style="color:#fad07a;">hello</span><span>():
</span><span> </span><span style="color:#ffb964;">print</span><span>(</span><span style="color:#556633;">&quot;</span><span style="color:#99ad6a;">Hello, World!</span><span style="color:#556633;">&quot;</span><span>)
</span><span>```
</span></code></pre>
<blockquote>
<p>注意:上述代码块中第一行的三个反引号后面紧跟着语言名称(如 <code>python</code>),结束时用相同的三个反引号结束。</p>
</blockquote>
<p><strong>渲染效果(依赖编辑器或平台的语法高亮支持):</strong></p>
<pre data-lang="python" style="background-color:#151515;color:#e8e8d3;" class="language-python "><code class="language-python" data-lang="python"><span style="color:#8fbfdc;">def </span><span style="color:#fad07a;">hello</span><span>():
</span><span> </span><span style="color:#ffb964;">print</span><span>(</span><span style="color:#556633;">&quot;</span><span style="color:#99ad6a;">Hello, World!</span><span style="color:#556633;">&quot;</span><span>)
</span></code></pre>
<hr />
<h3 id="2-6-yin-yong-kuai">2.6 引用块</h3>
<p>使用 <code>&gt;</code> 来表示引用Blockquote</p>
<pre data-lang="markdown" style="background-color:#151515;color:#e8e8d3;" class="language-markdown "><code class="language-markdown" data-lang="markdown"><span>&gt; 这是引用的内容,可以用于引用名言或文章片段。
</span><span>&gt;
</span><span>&gt; 多行引用时,每行前面都加上 `&gt;`。
</span></code></pre>
<p><strong>渲染效果:</strong></p>
<blockquote>
<p>这是引用的内容,可以用于引用名言或文章片段。</p>
<p>多行引用时,每行前面都加上 <code>&gt;</code></p>
</blockquote>
<hr />
<h3 id="2-7-fen-ge-xian">2.7 分割线</h3>
<p>使用三个或更多的横线 <code>---</code>、星号 <code>***</code> 或下划线 <code>___</code> 来产生水平分割线。</p>
<pre data-lang="markdown" style="background-color:#151515;color:#e8e8d3;" class="language-markdown "><code class="language-markdown" data-lang="markdown"><span>---
</span><span>或者
</span><span>***
</span><span>或者
</span><span>___
</span></code></pre>
<p><strong>渲染效果:</strong></p>
<hr />
<p>或者</p>
<hr />
<p>或者</p>
<hr />
<hr />
<h3 id="2-8-biao-ge">2.8 表格</h3>
<p>Markdown 表格可以使用管道符 <code>|</code> 和短横线 <code>-</code> 来创建。</p>
<pre data-lang="markdown" style="background-color:#151515;color:#e8e8d3;" class="language-markdown "><code class="language-markdown" data-lang="markdown"><span>| 表头1 | 表头2 | 表头3 |
</span><span>| :--- | :---: | ---: |
</span><span>| 左对齐 | 居中对齐 | 右对齐 |
</span><span>| 单元格内容 | 更多内容 | 数据 |
</span></code></pre>
<p><strong>渲染效果:</strong></p>
<table><thead><tr><th style="text-align: left">表头1</th><th style="text-align: center">表头2</th><th style="text-align: right">表头3</th></tr></thead><tbody>
<tr><td style="text-align: left">左对齐</td><td style="text-align: center">居中对齐</td><td style="text-align: right">右对齐</td></tr>
<tr><td style="text-align: left">单元格内容</td><td style="text-align: center">更多内容</td><td style="text-align: right">数据</td></tr>
</tbody></table>
<blockquote>
<p><strong>注:</strong><br />
“:---” 表示左对齐;<br />
“:---:” 表示居中对齐;<br />
“---:” 表示右对齐。</p>
</blockquote>
<hr />
<h2 id="san-markdown-gao-ji-yu-fa-yu-kuo-zhan">三、Markdown 高级语法与扩展</h2>
<p>不同平台可能支持额外的 Markdown 扩展语法,下面列举一些常见的扩展功能:</p>
<h3 id="3-1-jiao-zhu">3.1 脚注</h3>
<p>某些 Markdown 方言支持脚注。脚注格式如下:</p>
<pre data-lang="markdown" style="background-color:#151515;color:#e8e8d3;" class="language-markdown "><code class="language-markdown" data-lang="markdown"><span>这是一个带脚注的句子.[^1]
</span><span>
</span><span>[</span><span style="color:#ffb964;">^1</span><span>]: 这是脚注的内容。
</span></code></pre>
<p><strong>渲染效果:</strong></p>
<p>这是一个带脚注的句子.<sup class="footnote-reference"><a href="#1">1</a></sup></p>
<div class="footnote-definition" id="1"><sup class="footnote-definition-label">1</sup>
<p>这是脚注的内容。</p>
</div>
<h3 id="3-2-ren-wu-lie-biao">3.2 任务列表</h3>
<p>GitHub Flavored MarkdownGFM支持任务列表可以用于表示待办事项。</p>
<pre data-lang="markdown" style="background-color:#151515;color:#e8e8d3;" class="language-markdown "><code class="language-markdown" data-lang="markdown"><span>- [x] 完成 Markdown 教程
</span><span>- [ ] 阅读更多文章
</span><span>- [ ] 分享教程
</span></code></pre>
<p><strong>渲染效果:</strong></p>
<ul>
<li><input disabled="" type="checkbox" checked=""/>
完成 Markdown 教程</li>
<li><input disabled="" type="checkbox"/>
阅读更多文章</li>
<li><input disabled="" type="checkbox"/>
分享教程</li>
</ul>
<hr />
<h2 id="si-markdown-shi-yong-zhu-yi-shi-xiang">四、Markdown 使用注意事项</h2>
<ol>
<li>
<p><strong>空行与段落:</strong><br />
Markdown 使用一个或多个空行来分隔不同的段落。如果要换行但不创建新段落,在行尾添加两个或更多空格后回车即可。</p>
</li>
<li>
<p><strong>转义字符:</strong><br />
如果想要显示 Markdown 特殊符号而不被解析,比如 <code>*</code><code>#</code><code>\</code> 等,可以在前面加上反斜杠 <code>\</code></p>
<pre data-lang="markdown" style="background-color:#151515;color:#e8e8d3;" class="language-markdown "><code class="language-markdown" data-lang="markdown"><span>\*这不是斜体,而是普通的星号\*
</span></code></pre>
<p><strong>渲染效果:</strong><br />
*这不是斜体,而是普通的星号*</p>
</li>
<li>
<p><strong>原始文本展示:</strong><br />
为了展示 Markdown 源码而不被渲染,请使用代码块(反引号包围)或适用平台支持的原始文本标签(例如 <code>{% raw %}</code><code>{% endraw %}</code>)。</p>
</li>
</ol>
<hr />
<p><strong>Done.</strong></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/about-gfs/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">乱七八糟:GFS项目考量笔记</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/network-download-1/">
<span class="button__text">下载系列(1):下载技术的历史</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,333 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-mechrev-keyboard/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-mechrev-keyboard/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-mechrev-keyboard/">乱七八糟:机械革命键盘失灵拯救记</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2023-09-04
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 机械革命作为一款极高性价比的笔记本,其优惠的力度和问题不断的故障让玩家们爱恨交织;作者在其上安装 Linux 时遇到了键盘失灵的问题,为了避免更多人踩坑,故写本文。</p>
<span id="continue-reading"></span><h2 id="yi-gu-zhang-qing-kuang">一.故障情况</h2>
<p>作者在一台锐龙平台的笔记本上安装 Debian 时,先在虚拟机中尝试安装,没有发现异常;随后在实体机安装时发现 liveCD 中键盘不可用无法设置密码和主机名在连接外接键盘后安装完成却发现Fn快捷键仍然可用。</p>
<h2 id="er-ju-ti-si-lu">二.具体思路</h2>
<p>根据机革一贯的“特性”,作者猜测是因为 BIOS 或者 ACPI 出现了故障,随后在翻阅论坛时发现是由于锐龙笔记本键盘中断描述与其他键盘不同:其为边缘敏 感、低电平有效的而蛟龙16K机器键盘实际是边缘敏感、高电平有效Edge ActiveHigh。结合 linux 的特性,读取到边缘敏感、低电平有效的中断时,会认为 BIOS 有Bug会直接当成边缘敏感、高电平有效进行处理。因此键盘就没有了响应。</p>
<h2 id="san-jie-jue-fang-fa">三.解决方法</h2>
<p>既然是高低电平表述的错误那么我们只需建立DSDT 表副本,将其修改,然后让它优先启动,从而让键盘配置正常;另外还存在 BIOS 修复,内核编译的方法,比较复杂,这里不做说明。</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>首先建立一个DSDT文件夹
</span><span>sudo su
</span><span>mkdir -p /home/dsdt
</span><span>
</span><span>随后将系统的DSDT表读取到里面并安装acpica-tools
</span><span>cat /sys/firmware/acpi/tables/DSDT &gt; dsdt.dat
</span><span>apt install acpica-tools
</span><span>iasl -d dsdt.dat
</span><span>
</span><span>进入vim编辑DSDT表没有vim的先安装一个
</span><span>apt install vim
</span><span>vim dsdt.dsl
</span><span>
</span><span>搜索并替换 Device(PS2K) 下面的
</span><span>IRQ (Edge, ActiveLow, Shared, )
</span><span>
</span><span>IRQ (Edge, ActiveHigh, Shared, )
</span><span>
</span><span>vim搜索的方法为在命令模式下按下“/”键入搜索字符并回车即可按“n”跳转到下一处“N”跳转到前一处按: wq保存
</span><span>
</span><span>随后搜索DefinitionBlock将其步进值增加一十六进制即更改
</span><span>DefinitionBlock (&quot;&quot;, &quot;DSDT&quot;, 2, &quot;ALASKA&quot;, &quot;A M I&quot;, 0x01072009)
</span><span>
</span><span>DefinitionBlock (&quot;&quot;, &quot;DSDT&quot;, 2, &quot;ALASKA&quot;, &quot;A M I&quot;, 0x0107200A)
</span><span>
</span><span>关闭DSDT并设置其优先启动
</span><span>iasl dsdt.dsl
</span><span>mkdir -p kernel/firmware/acpi
</span><span>cp dsdt.aml kernel/firmware/acpi/
</span><span>find kernel | cpio -H newc --create &gt; acpi_override
</span><span>cp acpi_override /boot/acpi_override
</span><span>echo &quot;GRUB_EARLY_INITRD_LINUX_CUSTOM=\&quot;acpi_override\&quot;&quot; &gt;&gt;/etc/default/grub
</span><span>
</span><span>更新并重启:
</span><span>
</span><span>sudo grub-mkconfig -o /boot/grub/grub.cfg
</span><span>sudo grub-install /dev/sdX
</span><span>sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub
</span><span>
</span><span>update-grub2
</span><span>reboot
</span></code></pre>
<p>不出意外,重启后键盘即可使用,若系统不同将 apt 替换即可。</p>
<h2 id="si-qi-ta-wen-ti">四.其他问题</h2>
<p>对于Redmi 或 Lenovo刚发布的AMD R7 6800H机型</p>
<ul>
<li>WIFI没有驱动 - (螃蟹卡 8852be</li>
<li>蓝牙没有驱动 - (螃蟹卡 8852be)。</li>
<li>开启窗口特效后kwin_x11进程CPU占用飙升。</li>
<li>电源管理,无论怎么调,笔记本都发热很严重。</li>
</ul>
<h3 id="xiu-fu-wifiqu-dong">修复wifi驱动</h3>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span># 内核小于5.18的
</span><span>git clone https://github.com/HRex39/rtl8852be.git
</span><span># 内核大于等于5.18的
</span><span>git clone https://github.com/HRex39/rtl8852be.git -b dev
</span><span>
</span><span>cd rtl8852be
</span><span>make -j8
</span><span>sudo make install
</span><span>sudo modprobe 8852be
</span></code></pre>
<h3 id="xiu-fu-lan-ya-qu-dong">修复蓝牙驱动</h3>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span># 内核=5.15
</span><span>git clone https://github.com/HRex39/rtl8852be_bt.git -b 5.15
</span><span># 内核=5.18
</span><span>git clone https://github.com/HRex39/rtl8852be_bt.git -b 5.18
</span><span>
</span><span>cd rtl8852be_bt
</span><span>make -j8
</span><span>sudo make install
</span></code></pre>
<h3 id="xiu-fu-kwin-x11xian-qia-wei-qu-dong">修复kwin_x11显卡未驱动</h3>
<p>首先去amd官网下载最新的linux-amd驱动</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>https://www.amd.com/zh-hans/support/linux-drivers // 22.20 for Ubuntu 20.04.5 HWE
</span></code></pre>
<p>修改Deepin为ubuntu</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo vim /etc/os-release // ID=Deepin =&gt; ID=ubuntu
</span><span>
</span><span>sudo apt install ./amdgpu-install_22.20.50200-1_all.deb
</span><span>
</span><span>sudo vim /etc/apt/sources.list.d/amdgpu.list // focal =&gt; bionic
</span><span>
</span><span>sudo apt update
</span><span>
</span><span>sudo amdgpu-install --no-dkms
</span><span>
</span><span>sudo apt install inxi clinfo
</span></code></pre>
<p>安装成功以后用inxi查看下</p>
<p><code>inxi -G</code></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>Graphics: Device-1: AMD Rembrandt driver: amdgpu v: kernel
</span><span> Display: x11 server: X.Org 1.20.11 driver: amdgpu,ati unloaded: fbdev,modesetting,vesa
</span><span> resolution: 1920x1080~60Hz
</span><span> OpenGL: renderer: AMD YELLOW_CARP (LLVM 14.0.1 DRM 3.42 5.15.34-amd64-desktop)
</span><span> v: 4.6 Mesa 22.1.0-devel
</span></code></pre>
<p>最后还原最初的修改:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo vim /etc/os-release // ID=ubuntu =&gt; ID=Deepin
</span><span>sudo apt purge amdgpu-install
</span></code></pre>
<p>看下效果图:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>➜ ~ glxinfo -B
</span><span>name of display: :0
</span><span>display: :0 screen: 0
</span><span>direct rendering: Yes
</span><span>Extended renderer info (GLX_MESA_query_renderer):
</span><span> Vendor: AMD (0x1002)
</span><span> Device: AMD YELLOW_CARP (LLVM 14.0.1, DRM 3.42, 5.15.34-amd64-desktop) (0x1681)
</span><span> Version: 22.1.0
</span><span> Accelerated: yes
</span><span> Video memory: 2048MB
</span><span> Unified memory: no
</span><span> Preferred profile: core (0x1)
</span><span> Max core profile version: 4.6
</span><span> Max compat profile version: 4.6
</span><span> Max GLES1 profile version: 1.1
</span><span> Max GLES[23] profile version: 3.2
</span><span>Memory info (GL_ATI_meminfo):
</span><span> VBO free memory - total: 1388 MB, largest block: 1388 MB
</span><span> VBO free aux. memory - total: 3047 MB, largest block: 3047 MB
</span><span> Texture free memory - total: 1388 MB, largest block: 1388 MB
</span><span> Texture free aux. memory - total: 3047 MB, largest block: 3047 MB
</span><span> Renderbuffer free memory - total: 1388 MB, largest block: 1388 MB
</span><span> Renderbuffer free aux. memory - total: 3047 MB, largest block: 3047 MB
</span><span>Memory info (GL_NVX_gpu_memory_info):
</span><span> Dedicated video memory: 2048 MB
</span><span> Total available memory: 5120 MB
</span><span> Currently available dedicated video memory: 1388 MB
</span><span>OpenGL vendor string: AMD
</span><span>OpenGL renderer string: AMD YELLOW_CARP (LLVM 14.0.1, DRM 3.42, 5.15.34-amd64-desktop)
</span><span>OpenGL core profile version string: 4.6 (Core Profile) Mesa 22.1.0-devel
</span><span>OpenGL core profile shading language version string: 4.60
</span><span>OpenGL core profile context flags: (none)
</span><span>OpenGL core profile profile mask: core profile
</span><span>
</span><span>OpenGL version string: 4.6 (Compatibility Profile) Mesa 22.1.0-devel
</span><span>OpenGL shading language version string: 4.60
</span><span>OpenGL context flags: (none)
</span><span>OpenGL profile mask: compatibility profile
</span><span>
</span><span>OpenGL ES profile version string: OpenGL ES 3.2 Mesa 22.1.0-devel
</span><span>OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
</span></code></pre>
<h3 id="shou-dong-guan-li-dian-yuan-bi-mian-cpuguo-du-shi-yong-er-fa-re">手动管理电源避免CPU过度使用而发热</h3>
<p>安装下面的三方电源管理工具 <code>Boost Changer</code>,选择 <code>Performance</code>策略即可</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>wget https://github.com/nbebaw/boostchanger/releases/download/v4.4.0/boostchanger_4.4.0_amd64.deb
</span></code></pre>
<h2 id="can-kao">参考</h2>
<p><a href="https://zhuanlan.zhihu.com/p/530643928">https://zhuanlan.zhihu.com/p/530643928</a></p>
<p><a href="https://github.com/HRex39/rtl8852be">https://github.com/HRex39/rtl8852be</a></p>
<p><a href="https://github.com/HRex39/rtl8852be_bt">https://github.com/HRex39/rtl8852be_bt</a></p>
<p><a href="https://bbs.deepin.org/post/241607">https://bbs.deepin.org/post/241607</a></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/about-accurate-pronunciation/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">乱七八糟:常见发音错误术语集合</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-blog/">
<span class="button__text">乱七八糟:个人博客搭建</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,302 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-opensource/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-opensource/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-opensource/">乱七八糟:开源软件与协议</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2024-03-03
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 本文旨在介绍开源以及开源许可证,这些许可证规定了使用、修改和分发开源软件的条件。通过了解不同类型的开源许可证及其特点,读者将能够更好地理解在开发和使用开源软件时的法律和道德责任。</p>
<span id="continue-reading"></span><h2 id="kai-yuan-de-gai-nian">开源的概念</h2>
<p>「开源」一词对应英文 Open Source最初起源于软件开发领域因此也称为「开放源代码」对应的软件则称为开源软件Open Source Software简称 OSS。除了我们熟知的开源软件以外开源的表现形式还有很多例如开源硬件Open Source Hardware、开放设计Open Design、开放文档Open Document等等。开源的目的是分享共享、加速创新可以说开源已经成为一种超越软件生产界限的运动和工作方式。</p>
<p>对于很多刚踏入软件这个行业的小伙伴来说「开源」是个比较陌生的概念。但是随着经手项目逐渐增多会发现很多项目尤其是一些大型项目经常会引用到别人一些优秀的开源代码而这些优秀的开源代码通常都会在最开始简单地附上一段关于授权的声明或在项目根目录下提供完整的授权声明文件比如「The project is licensed under the Apache 2 license.」,诸如此类便是「开源许可证」。</p>
<p>开源不等于免费,开源也不等于没有约束</p>
<h3 id="kai-yuan-de-hao-chu"><strong>开源的好处</strong></h3>
<ol>
<li>
<p>透明度和安全性
开源软件的代码是公开的,任何人都可以检查和改进它。这使得潜在的安全漏洞更容易被发现和修复,提升了软件的安全性。</p>
</li>
<li>
<p>促进创新
开源允许开发者自由研究和修改代码推动技术进步。例如Linux、Python、TensorFlow 等开源项目极大地促进了计算机科学和人工智能的发展。</p>
</li>
<li>
<p>降低成本
企业和个人可以免费使用开源软件,而不需要支付高昂的许可证费用。例如,使用 Linux 服务器代替 Windows Server 可以减少 IT 成本。</p>
</li>
<li>
<p>快速迭代和社区支持
开源项目通常由全球开发者社区维护和改进Bug 修复和新功能开发的速度比封闭源代码的软件更快。例如,开源浏览器 Firefox 就依赖社区贡献不断改进。</p>
</li>
<li>
<p>避免供应商锁定
开源软件允许用户自由选择和修改代码而不是被某个公司的专有软件绑定避免了供应商锁定的问题。例如MySQL 和 PostgreSQL 等开源数据库是很多企业的首选,避免依赖单一厂商。</p>
</li>
</ol>
<h2 id="kai-yuan-ruan-jian">开源软件</h2>
<p>开源软件顾名思义是指能够免费且不受限制地使用、再开发、再发布的软件。但在狭义上只有符合开放源代码促进会Open Source Initiative定义的软件才能被称为开源软件。这个定义提出了十个特征必须全部符合才能认定为开源软件。</p>
<p>这些特征包括:</p>
<ul>
<li>可自由再分发。</li>
<li>提供源代码。</li>
<li>允许衍生作品。</li>
<li>不得过度限制原始代码的修改。</li>
<li>不得歧视特定人、群体或用途。</li>
<li>必须「技术中立」等。</li>
</ul>
<p>根据这些标准一些看似自由使用的软件可能不符合开源软件的定义。例如Elasticsearch原本使用Apache 2.0授权是真正的开源软件。但面对云服务提供商如AWS等将其用于营利目的却不回馈改进的情况Elasticsearch在2021年1月选择了SSPLServer Side Public License服务器端公共许可证和Elastic License两种许可证并行SSPL要求如果将程序的功能或修改后的版本作为服务提供给第三方则必须免费公开提供服务源代码这违背了开源软件的定义。另一方面Elastic License要求不能向第三方提供主机或托管服务也违反了开源软件的定义因此也不算严格意义上的「开源」。</p>
<h2 id="kai-yuan-xu-ke-zheng">开源许可证</h2>
<p>开源许可证是软件许可证的一种特殊形式,用于规定开源软件的使用、修改、分享等相关事宜。它是一种格式合同,涉及版权、专利、商标等权利义务,自动生效。</p>
<p>在美国一些法院认为软件许可证是合同contract一些法院则认为是许可license。两者的区别在于许可在传统上是由地产或物主作出的目的在于允许他人使用自己的地块或物品。因此它是单方向的不构成完整的合同而是作为合同的一个要素用来和他人交换的条件。由于合同和许可之分在法律上有着重要的意义它们的违约救济和版权侵权救济等方面有着不同的规定。</p>
<p>与美国不同,大陆法系国家如中国普遍认为开源软件许可证构成合同,但这种合同是事先规定好的标准化格式合同,并且自动生效。</p>
<p>开源许可证的种类繁多据不完全统计广义上的开源许可证超过200种其中OSI批准的许可证有96个。这些许可证的内容各不相同有些条款非常有意思例如啤酒软件许可证Beerware License规定用户与作者聚会时可以请作者喝一杯啤酒Jason Hunter 许可证规定,如果将该许可证下的代码用于商业目的,那么项目开发团队的所有成员都必须拥有 Jason Hunter 撰写的《Java Servlet编程》最新版。</p>
<h2 id="chang-jian-kai-yuan-xu-ke-zheng">常见开源许可证</h2>
<p>世界上的开源许可证Open Source License大概有上百种而常见的开源协议大致有GPL、BSD、MIT、Mozilla、Apache和LGPL等。
<img src="https://www.ruanyifeng.com/blogimg/asset/201105/free_software_licenses.png" alt="alt text" /></p>
<blockquote>
<p><a href="https://choosealicense.com/">Choose an open source license</a></p>
</blockquote>
<h2 id="apache-license">Apache License</h2>
<p>Apache LicenseApache许可证是Apache软件基金会发布的一个自由软件许可证。</p>
<p>Apache Licence 是著名的非盈利开源组织 Apache 采用的协议。该协议和BSD类似同样鼓励代码共享和最终原作者的著作权同样允许源代码修改和再发布。但是也需要遵循以下条件</p>
<ul>
<li>需要给代码的用户一份 Apache Licence。</li>
<li>如果修改了代码,需要再被修改的文件中说明。</li>
<li>在衍生的代码中(修改和有源代码衍生的代码中)需要带有原来代码中的协议,商标,专利声明和其他原来作者规定需要包含的说明。</li>
<li>如果再发布的产品中包含一个 Notice 文件则在Notice文件中需要带有 Apache Licence。你可以在 Notice 中增加自己的许可,但是不可以表现为对 Apache Licence 构成更改。</li>
</ul>
<p>Apache Licence 也是对商业应用友好的许可。使用者也可以再需要的时候修改代码来满足并作为开源或商业产品发布/销售。</p>
<p>使用这个协议的好处是:</p>
<ul>
<li>永久权利 一旦被授权,永久拥有。</li>
<li>全球范围的权利 在一个国家获得授权,适用于所有国家。假如你在美国,许可是从印度授权的,也没有问题。</li>
<li>授权免费 无版税, 前期、后期均无任何费用。</li>
<li>授权无排他性 任何人都可以获得授权</li>
<li>授权不可撤消 一旦获得授权,没有任何人可以取消。比如,你基于该产品代码开发了衍生产品,你不用担心会在某一天被禁止使用该代码</li>
</ul>
<h2 id="bsd">BSD</h2>
<p>BSD 是"Berkeley Software Distribution"的缩写,意思是"伯克利软件发行版"。</p>
<p>BSD开源协议是一个给于使用者很大自由的协议。可以自由的使用修改源代码也可以将修改后的代码作为开源或者专有软件再发布。 当你发布使用了BSD协议的代码或则以BSD协议代码为基础做二次开发自己的产品时需要满足三个条件</p>
<ul>
<li>
<p>如果再发布的产品中包含源代码则在源代码中必须带有原来代码中的BSD协议。</p>
</li>
<li>
<p>如果再发布的只是二进制类库/软件,则需要在类库/软件的文档和版权声明中包含原来代码中的BSD协议。</p>
</li>
<li>
<p>不可以用开源代码的作者/机构名字和原来产品的名字做市场推广。</p>
</li>
</ul>
<p>BSD代码鼓励代码共享但需要尊重代码作者的著作权。BSD由于允许使用者修改和重新发布代码也允许使用或在BSD代码上开发商业软件发布和销售因此是对商业集成很友好的协议。而很多的公司企业在选用开源产品的时候都首选BSD协议因为可以完全控制这些第三方的代码在必要的时候可以修改或者二次开发。</p>
<h2 id="gpl">GPL</h2>
<p>GPL GNU General Public License GNU通用公共许可协议。</p>
<p>Linux 采用了 GPL。</p>
<p>GPL 协议和 BSD, Apache Licence 等鼓励代码重用的许可很不一样。GPL 的出发点是代码的开源/免费使用和引用/修改/衍生代码的开源/免费使用,但不允许修改后和衍生的代码做为闭源的商业软件发布和销售。这也就是为什么我们能用免费的各种 linux包括商业公司的 linux 和 linux 上各种各样的由个人,组织,以及商业软件公司开发的免费软件了。</p>
<h2 id="lgpl">LGPL</h2>
<p>LGPL是GPL的一个为主要为类库使用设计的开源协议。和 GPL 要求任何使用/修改/衍生之GPL类库的的软件必须采用GPL协议不同。LGPL允许商业软件通过类库引用(link)方式使用LGPL类库而不需要开源商业软件的代码。这使得采用 LGPL 协议的开源代码可以被商业软件作为类库引用并发布和销售。</p>
<p>但是如果修改 LGPL 协议的代码或者衍生,则所有修改的代码,涉及修改部分的额外代码和衍生的代码都必须采用 LGPL 协议。因此LGPL协议的开源代码很适合作为第三方类库被商业软件引用但不适合希望以 LGPL 协议代码为基础,通过修改和衍生的方式做二次开发的商业软件采用。</p>
<p>GPL/LGPL都保障原作者的知识产权避免有人利用开源代码复制并开发类似的产品。</p>
<h2 id="mit">MIT</h2>
<p>MIT是和BSD一样宽范的许可协议,源自麻省理工学院Massachusetts Institute of Technology, MIT又称X11协议。作者只想保留版权,而无任何其他了限制。MIT与BSD 类似,但是比 BSD 协议更加宽松是目前最少限制的协议。这个协议唯一的条件就是在修改后的代码或者发行包包含原作者的许可信息。适用商业软件。使用MIT的软件项目有jquery、Node.js。</p>
<p>MIT与BSD类似但是比BSD协议更加宽松是目前最少限制的协议。这个协议唯一的条件就是在修改后的代码或者发行包包含原作者的许可信息。适用商业软件。使用MIT的软件项目有jquery、Node.js。</p>
<h2 id="mpl-mozilla-public-license-1-1">MPL (Mozilla Public License 1.1)</h2>
<p>MPL 协议允许免费重发布、免费修改,但要求修改后的代码版权归软件的发起者 。这种授权维护了商业软件的利益它要求基于这种软件的修改无偿贡献版权给该软件。这样围绕该软件的所有代码的版权都集中在发起开发人的手中。但MPL是允许修改无偿使用得。MPL 软件对链接没有要求。</p>
<h2 id="epl-eclipse-public-license-1-0">EPL (Eclipse Public License 1.0)</h2>
<p>EPL允许 Recipients 任意使用、复制、分发、传播、展示、修改以及改后闭源的二次商业发布。</p>
<p>使用EPL协议需要遵守以下规则</p>
<p>当一个 Contributors 将源码的整体或部分再次开源发布的时候,必须继续遵循EPL开源协议来发布,而不能改用其他协议发布.除非你得到了原"源码"Owner 的授权;</p>
<p>EPL协议下,你可以将源码不做任何修改来商业发布.但如果你要发布修改后的源码,或者当你再发布的是 Object Code 的时候,你必须声明它的 Source Code 是可以获取的,而且要告知获取方法;</p>
<p>当你需要将EPL下的源码作为一部分跟其他私有的源码混和着成为一个 Project 发布的时候,你可以将整个 Project/Product 以私人的协议发布,但要声明哪一部分代码是EPL下的,而且声明那部分代码继续遵循EPL</p>
<p>4.独立的模块(Separate Module),不需要开源。</p>
<h2 id="creative-commons-zhi-shi-gong-xiang-xie-yi">Creative Commons 知识共享协议</h2>
<p>Creative Commons (CC) 许可协议并不能说是真正的开源协议,它们大多是被使用于设计类的工程上。 CC 协议种类繁多,每一种都授权特定的权利。 一个 CC 许可协议具有四个基本部分,这几个部分可以单独起作用,也可以组合起来。下面是这几部分的简介:</p>
<ul>
<li>
<p>署名 作品上必须附有作品的归属。如此之后,作品可以被修改,分发,复制和其它用途。</p>
</li>
<li>
<p>相同方式共享 作品可以被修改、分发或其它操作但所有的衍生品都要置于CC许可协议下。</p>
</li>
<li>
<p>非商业用途 作品可以被修改、分发等等,但不能用于商业目的。但语言上对什么是"商业"的说明十分含糊不清 (没有提供精确的定义),所以你可以在你的工程里对其进行说明。例如,有些人简单的解释"非商业"为不能出售这个作品。而另外一些人认为你甚至不能在有广告的网站上使用它们。 还有些人认为"商业"仅仅指你用它获取利益。</p>
</li>
<li>
<p>禁止衍生作品</p>
</li>
</ul>
<p>CC 许可协议的这些条款可以自由组合使用。大多数的比较严格的CC协议会声明 "署名权,非商业用途,禁止衍生"条款这意味着你可以自由的分享这个作品但你不能改变它和对其收费而且必须声明作品的归属。这个许可协议非常的有用它可以让你的作品传播出去但又可以对作品的使用保留部分或完全的控制。最少限制的CC协议类型当属 "署名"协议,这意味着只要人们能维护你的名誉,他们对你的作品怎么使用都行。</p>
<p>CC 许可协议更多的是在设计类工程中使用,而不是开发类,但没有人或妨碍你将之使用与后者。只是你必须要清楚各部分条款能覆盖到的和不能覆盖到的权利。</p>
<h2 id="can-kao">参考</h2>
<ul>
<li><a href="https://opensource.guide/zh-hans/">开源软件指南</a></li>
<li><a href="https://www.tldrlegal.com/browse">Browse Software Licenses and Summaries</a></li>
<li><a href="https://opensource.org/license">开源协议检索</a></li>
<li><a href="https://oschina.gitee.io/opensource-guide/">开源指北</a></li>
</ul>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/network-how-email-works-2/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">网络艺术:自建域名邮箱</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-rss-read/">
<span class="button__text">乱七八糟:RSS阅读指南</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,213 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-podcast-use/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-podcast-use/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-podcast-use/">乱七八糟:播客收听指北</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2024-03-06
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 讲起播客,许多人第一反应是喜马拉雅,但其实播客的订阅和收听有许多种方式。本文带你了解订阅播客的各种方式,并告诉你市面上有哪些不错的播客客户端可供选择。</p>
<span id="continue-reading"></span><h2 id="yi-shen-me-shi-bo-ke">一.什么是播客</h2>
<p>播客是一种通过互联网传播音频或视频文件的媒体形式。这个词汇是由“广播”broadcasting和“iPod”一种流行的便携式媒体播放器两个词组合而成的。播客通常是由个人、组织或公司制作并通过互联网上的订阅服务分享给观众。</p>
<ul>
<li>
<p>定期更新: 播客通常以系列形式发布,每一集都是一个独立的音频或视频文件。制作者会定期发布新的内容,让观众订阅后能够定期收听或观看。</p>
</li>
<li>
<p>订阅:观众可以通过订阅播客来自动获取最新的内容。这意味着一旦订阅了某个播客,新的内容就会自动下载到用户的设备上,方便随时收听或观看。</p>
</li>
<li>
<p>多样的内容: 播客内容非常多样化,涵盖了几乎所有可能的主题,包括新闻、科技、文化、教育、娱乐等。从个人讲述生活故事到专业领域的讨论,播客的形式和内容都非常灵活。</p>
</li>
<li>
<p>低门槛制作:制作播客相对来说不需要太多的专业设备和技能,因此许多个人或小团队可以轻松开始制作自己的播客。</p>
</li>
</ul>
<p>播客的流行得益于它提供了一种轻松、灵活、个性化的信息传递方式,让人们可以方便地在各种主题上深入了解或娱乐。</p>
<h2 id="er-ru-he-ting-bo-ke">二.如何听播客</h2>
<p>要收听播客,首先得确定自己所用的平台和客户端,一般有以下几种:</p>
<ul>
<li>
<p>使用播客应用: 最常见的方式是使用专门的播客应用程序,这些应用可以在智能手机、平板电脑或计算机上安装。一些常见的播客应用包括 Apple Podcasts苹果播客、Spotify、Google Podcasts谷歌播客、Pocket Casts等。这些应用通常允许你搜索、订阅和播放播客。像喜马拉雅以及各大云音乐等非泛用型播客客户端这类软件的特点是收听方便种类繁多但一般不开源也没有 RSS 链接。</p>
</li>
<li>
<p>在网页上收听: 许多播客也提供在其官方网站上在线收听的选项。你可以在制作者的网站上找到相应的播客链接,然后直接在浏览器中收听,或者使用浏览器插件。</p>
</li>
<li>
<p>通过流媒体服务: 一些流媒体服务,如 Spotify、Apple Music 等,也提供了播客的功能。你可以在这些服务中搜索并订阅你感兴趣的播客。</p>
</li>
<li>
<p>通过RSS订阅 几乎每个独立播客的主播都会反复强调「请使用节目 RSS 链接在 泛用型播客客户端 里订阅节目」,一定程度上有无 RSS 订阅链接是作为独立播客的判断标准。使用 RSS 链接订阅播客其实非常简单——得到节目的 RSS 订阅链接后将之粘贴到你的播客客户端内通常是节目的搜索栏或地址栏即可。大多数播客应用都支持这种方式。注意例如喜马拉雅、荔枝等平台是没有原生RSS链接的因此对第三方服务生成的 RSS 链接要注意鉴别。有些服务提供者会在不告知主播和听众的前提下,私自在节目中间插入广告,非常影响节目收听体验,在使用时请注意甄别。</p>
</li>
</ul>
<h2 id="san-chang-jian-ke-hu-duan-you-que-dian">三.常见客户端优缺点</h2>
<p><code>我个人推荐使用开源的 AntennaPod 。</code></p>
<h2 id="si-bo-ke-zi-yuan">四.播客资源</h2>
<p><a href="https://tianxianzi.me/2023/12/11/selected_podcast/">天仙子的播客年度总结:播客选录</a></p>
<p><a href="https://xyzrank.com/#/">中文播客榜</a></p>
<p><a href="https://www.listennotes.com/">Podcast search</a></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/about-rss-read/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">乱七八糟:RSS阅读指南</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-shortcut-key/">
<span class="button__text">乱七八糟:常用实用快捷键</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,382 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-rss-read/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-rss-read/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-rss-read/">乱七八糟:RSS阅读指南</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2024-03-05
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 RSS 提供了一种数据格式,以 XML可扩展标记语言的形式组织信息包括文章标题、摘要、链接和发布日期等。这些信息形成了所谓的“订阅源”Feed用户可以使用RSS阅读器Feed Reader来订阅这些源。</p>
<span id="continue-reading"></span><h2 id="yi-shen-me-shi-rss">一.什么是RSS</h2>
<p>如果你使用过类似红板报,轻芒杂志,摸鱼 kiki,今日热榜等 APP应该对 RSS 并不陌生。</p>
<p>RSSReally Simple Syndication是一种用于发布经常更新的内容的标准通常用于博客、新闻网站和其他线上发布的信息。RSS 允许用户订阅这些站点的内容,以便在内容有更新时,用户能够获得及时的通知。</p>
<p>基本上RSS 提供了一种数据格式,以 XML可扩展标记语言的形式组织信息包括文章标题、摘要、链接和发布日期等。这些信息形成了所谓的“订阅源”Feed用户可以使用 RSS 阅读器Feed Reader来订阅这些源。</p>
<p>RSS 的主要优势包括:</p>
<ul>
<li>
<p>即时通知:用户订阅了 RSS 源后,当源中的内容有更新时,用户将立即收到通知,而无需手动检查网站。</p>
</li>
<li>
<p>集中管理:使用 RSS 阅读器,用户可以集中管理多个网站的更新,而无需逐个访问这些站点。</p>
</li>
<li>
<p>隐私保护RSS 订阅不需要提供个人信息,用户只需关注感兴趣的内容,而无需注册账户。</p>
</li>
<li>
<p>定制内容:用户可以选择订阅感兴趣的主题或网站,定制他们的信息流。</p>
</li>
<li>
<p>减少信息过载:通过只关注真正感兴趣的内容,用户可以减少信息过载,集中注意力在最关键的信息上。</p>
</li>
</ul>
<p>如果我们想更高效地获取信息,不在多个应用间来回切换,另一方面拒绝算法给我们推荐的内容,那么建议用回原始的 RSS。</p>
<p>虽然 RSS 曾经非常流行但随着社交媒体和其他信息传递方式的兴起逐渐成为时代的眼泪。然而RSS 仍然是一种有效的信息分发和获取方式,许多网站和博客仍提供 RSS 源。题主曾经计划使用 Kindle 作为专门的RSS阅读器后来由于过于昂贵而作罢。</p>
<h2 id="er-ru-he-jin-xing-rssyue-du">二.如何进行RSS阅读</h2>
<p>基本上有以下几步:</p>
<ul>
<li>
<p>寻找 RSS 订阅源</p>
</li>
<li>
<p>确定 RSS 客户端</p>
</li>
<li>
<p>自建 RSS 服务端(可选)</p>
</li>
</ul>
<p><strong>寻找RSS订阅源</strong></p>
<p>要知道一个网站是否支持 RSS 订阅最直接的方法就是看网站的底部或侧边栏是否有 RSS 图标。一般来说图标所指向的地址就是该网站的订阅链接可以直接点击 跳转到 RSS 客户端内进行订阅,也可以复制粘贴按钮中的地址到自己在用的 RSS 服务中订阅这些网站中的内容。</p>
<p>在浏览器中推荐使用 RSS Hub radar 插件可以自动找到可用的RSS源并提示。</p>
<p>有时候网站不会直接给出订阅源,这时候你也可以尝试在网站域名后面加上 /feed  /rss 或许可以碰巧猜中比如少数派的 RSS 订阅链接就是 https://sspai.com/feed。当然你也可以直接通过搜索引擎通过 网站名 + RSS 的关键字进行搜索往往都能找到支持网站的 RSS 链接。</p>
<p>MoreRSS这个网站提供中、英文的RSS源并且显示源的订阅量对于一些受欢迎的英文 RSS还提供了中文翻译。但此网站还在建设中收录量不大、功能也不完善可以关注其更新。</p>
<p>有一些中文博客聚合网站收录了多则1000+少则几百的中文博客PS.经查世界上现存的大熊猫数量约2600只知名的有十年之约、博友圈、BlogFinder 、积薪、川流 等,不一一列举了。</p>
<p>Feedsearch如果在网站的首页看不到 RSS 信息,可以使用这个 RSS 源搜索服务,实测准确度很高,我用它找出来很多隐藏的 RSS 源,如果这个网站搜不到,那可能是网站确实没有提供 RSS。</p>
<p>RSSAnything ,如果 RSSHub 也没有找到需要的 RSS可以尝试使用这个网站生成 RSS这是我试过的效果最好的但要看运气有的时候效果很好有的时候达不到期望值。</p>
<p>有一些针对具体的社会化媒体生成 RSS 的服务,但或者收费,或者稳定性欠佳失效,或者收费且稳定性欠佳失效(我就订阅了一个微信公众号的 RSS 服务没用多久就失效了还不退款想了下就不在这里列举了感兴趣可以直接在https://morerss.com/tools_zh.html查找。</p>
<blockquote>
<p>英文RSS源翻译<br />
可以把外语信息源翻译为中文的,这里推荐的服务器是 RSS-Translator功能强大但需要一定的能力。MoreRSS 基于 RSS-Translator 的服务,翻译了一批优质的外语信息源,可以直接订阅。</p>
</blockquote>
<p>当然,我们也可以直接导入现有的订阅源,一般为 OPML 文件,如 RSS Source;或者调用第三方的 RSS 服务,如 anyfeeder等等。</p>
<p>这里介绍一个 RSS 神器,由 DIygod 发起的RSShub项目</p>
<p>RSSHub 是一个开源项目旨在为用户提供一个集中化、可定制的RSSReally Simple Syndication源的生成器。该项目的目标是通过从各种网站和平台获取信息将其聚合到用户自定义的RSS源中从而使用户能够方便地订阅他们关心的内容。</p>
<ul>
<li>
<p>开源性质: RSSHub 是一个开源项目,其源代码可以在 GitHub 上找到。这意味着任何人都可以查看、使用、修改和贡献代码。</p>
</li>
<li>
<p>支持的站点: RSSHub 支持从各种网站和平台提取数据,包括但不限于新闻网站、社交媒体、博客、视频分享平台等。用户可以根据自己的需求选择要订阅的站点。</p>
</li>
<li>
<p>自定义生成: 用户可以通过指定参数和规则来定制他们的 RSS 源,以便获取特定主题或关键字的更新。这使得用户能够灵活地定制他们的订阅流。</p>
</li>
<li>
<p>社区参与: RSSHub 是一个社区驱动的项目,有很多开发者和贡献者参与其中。社区可以通过 GitHub 进行讨论、报告问题和提交代码。</p>
</li>
<li>
<p>部署方式: RSSHub 可以自行部署用户可以在自己的服务器上搭建RSSHub实例以便更好地控制和定制生成的RSS源。</p>
</li>
</ul>
<p><strong>确定RSS客户端</strong></p>
<p>RSS客户端非常丰富包括 Android 端IOS 端Windows 端linux 端,浏览器插件,甚至 Vscode 插件(用来摸鱼)等等。这里推荐一些阅读器,当然,也可以选择类似 Feedly 的服务商。</p>
<ul>
<li>
<p>AndroidNews在Fdorid里可下载中文名为“新闻”界面简洁功能全面支持本地或连接自建服务端。</p>
</li>
<li>
<p>IOSInoreader 其提供了方便的阅读体验,支持离线阅读、标签和快速搜索。</p>
</li>
<li>
<p>WindowsFluent Reader,在github上开源界面优雅支持本地或连接自建服务端。</p>
</li>
<li>
<p>linuxFluent Reader或Newsboat 是 Newsbeuter 的一个分支,一款文本控制台 RSS/Atom 订阅阅读器。</p>
</li>
</ul>
<p><strong>自建RSS服务端</strong></p>
<p>开源的RSS服务端软件可以用来搭建个人的RSS阅读服务</p>
<ul>
<li>
<p>FreshRSS: FreshRSS 是一款简单易用的自建 RSS 服务端软件。它提供了丰富的功能,包括标签、筛选器、阅读统计等,并支持多用户。</p>
</li>
<li>
<p>Miniflux: Miniflux 是一个轻量级的 RSS/Atom 阅读器服务,支持自建。它采用 Go 语言编写,具有快速响应和简洁的用户界面。</p>
</li>
<li>
<p>Tiny Tiny RSS (tt-rss): Tiny Tiny RSS 是一款功能丰富的自建RSS服务端软件提供了类似于 Google Reader 的界面,并支持标签、过滤器、插件等。</p>
</li>
<li>
<p>Selfoss: Selfoss 是一款支持多种数据源包括RSS的自建聚合器。它的界面简洁支持标签、过滤器和插件同时也提供了跨平台的客户端。</p>
</li>
<li>
<p>Miniflux 2: 不要与上面提到的 Miniflux 混淆Miniflux 2 是 Miniflux 的一个全新版本,同样支持自建 RSS 服务。</p>
</li>
</ul>
<p>这里以MiniFlux为例其优势在与</p>
<ul>
<li>
<p>程序设计极简,不处理任何订阅之外的事情。</p>
</li>
<li>
<p>程序无外部依赖,运行性能高。</p>
</li>
<li>
<p>支持自动抓取并缓存图片,加速浏览。</p>
</li>
<li>
<p>有限支持自动将摘要替换为全文进行抓取。</p>
</li>
<li>
<p>支持多账号登录,支持 Fever API ,允许客户端从外部登录。</p>
</li>
<li>
<p>支持集成 PinBoard 、Instapaper、 Pocket、Wallabag、Nunux Keeper 等服务。</p>
</li>
<li>
<p>提供 Open API、书签快速订阅脚本。</p>
</li>
<li>
<p>维护者和社区相对活跃,更新频率高。</p>
</li>
</ul>
<p><strong>步骤:</strong></p>
<p>1.安装docker 和docker-compose</p>
<p>2.Docker 安装 miniflux</p>
<p>1创建并进入你想安装 Miniflux 的文件夹:</p>
<p><code>mkdir ~/miniflux</code> # 在根目录创建名为miniflux的文件夹</p>
<p><code>cd ~/miniflux</code> # 进入miniflux文件夹</p>
<p>2创建docker-compose.yml文件</p>
<p><code>nano docker-compose.yml</code> # 使用nano编辑器创建会自动打开文件以写入内容</p>
<p>3在文件中写入以下内容并保存</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>version: &#39;3.4&#39;
</span><span>
</span><span>services:
</span><span>
</span><span> miniflux:
</span><span>
</span><span> image: miniflux/miniflux:latest
</span><span>
</span><span> ports:
</span><span>
</span><span> - &quot;127.0.0.1:8080:8080&quot; #调整一增加localhost ip 并改port为8080
</span><span>
</span><span> depends_on:
</span><span>
</span><span> - db
</span><span>
</span><span> environment:
</span><span>
</span><span> - DATABASE_URL=postgres://miniflux:secret@db/miniflux?sslmode=disable
</span><span>
</span><span> - RUN_MIGRATIONS=1
</span><span>
</span><span> - CREATE_ADMIN=1
</span><span>
</span><span> - ADMIN_USERNAME=admin # 登录Miniflux的用户名可自定义
</span><span>
</span><span> - ADMIN_PASSWORD=password # 登录Miniflux的密码可自定义至少6位
</span><span>
</span><span> - &quot;BASE_URL=https://enter.your.url&quot; # 调整二输入想用来访问Miniflux的域名
</span><span>
</span><span> healthcheck:
</span><span>
</span><span> test: [&quot;CMD&quot;, &quot;/usr/bin/miniflux&quot;, &quot;-healthcheck&quot;, &quot;auto&quot;]
</span><span>
</span><span> db:
</span><span>
</span><span> image: postgres:latest
</span><span>
</span><span> environment:
</span><span>
</span><span> - POSTGRES_USER=miniflux
</span><span>
</span><span> - POSTGRES_PASSWORD=secret
</span><span>
</span><span> volumes:
</span><span>
</span><span> - miniflux-db:/var/lib/postgresql/data
</span><span>
</span><span> healthcheck:
</span><span>
</span><span> test: [&quot;CMD&quot;, &quot;pg_isready&quot;, &quot;-U&quot;, &quot;miniflux&quot;]
</span><span>
</span><span> interval: 10s
</span><span>
</span><span> start_period: 30s
</span><span>
</span><span>volumes:
</span><span>
</span><span> miniflux-db:
</span></code></pre>
<p>该 docker-compose.yml 文档内容基于 Miniflux 官方文档 ,并在细节上进行了调整。调整有两处:一是将 port 改为127.0.0.1:8080:8080主要目的是错开常用port 80并调整 localhost 为127.0.0.1来跟 nginx 的设置一致(如不调整, miniflux 将使用0.0.0.0,无法顺利运行 nginx );二是在 miniflux 的environment 中加入新的 configuration BASE_URL请将内容换为你想用来访问 Miniflux 的域名。</p>
<p>//如何用 nano 保存文件:可以使用 ctrl+X在退出编辑时选择Y来保存所有更改再敲一次回车便可以回到命令行。//</p>
<p>4运行以下代码进行安装</p>
<p><code>docker-compose up -d</code></p>
<p>在浏览器中访问服务器ip:端口号如http://123.45.67.890:8080如显示登录界面即代表安装成功。域名解析和反代步骤略。</p>
<h2 id="hou-ji">后记</h2>
<p><a href="https://morerss.com/tools_zh.html">RSS源</a></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/about-opensource/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">乱七八糟:开源软件与协议</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-podcast-use/">
<span class="button__text">乱七八糟:播客收听指北</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,505 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-server-set/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-server-set/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-server-set/">乱七八糟:服务器初始化与安全设置</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2024-06-12
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 本文记录服务器常用操作步骤。</p>
<span id="continue-reading"></span><h2 id="doamin">Doamin</h2>
<p>建站不一定需要服务器、域名和备案。尤其不要买腾讯云不要买CN域名备案过程要填很多个人信息且一周没有解析网站备案就会自动注销。</p>
<ul>
<li>
<p><strong>cn 域名没有隐私保护whois protection</strong>。国内域名注册商说的隐私保护根本是自欺欺人,在它们隐私保护就是在自己的查询服务隐藏注册人信息。但在别的地方是能查到的,在<a href="https://whois.cnnic.cn/">中国互联网络信息中心</a>可以查到每个 cn 域名注册人的姓名和邮箱。</p>
</li>
<li>
<p><strong>注册 cn 域名必须使用真实身份信息</strong>。要是你想用假信息注册来保护隐私,那就太天真了。审核的时候不会通过的。真的不想用自己的信息注册的话,要么以公司名义注册,但公司的法定代表人还是能查到的。要么叫别人注册域名之后给你用,可谁愿意冒这种风险呢。</p>
</li>
<li>
<p><strong>cn 域名无法删除</strong>。如果你觉得 cn 域名暴露了你的隐私,那对不起,这是不能注销的<a href="https://cyrusyip.org/zh-cn/post/2021/05/25/damn-cn-domain/#fn:3">3</a>。你只能修改邮箱地址,然后等到它过期。或者转让给别人,不过感觉把别人推到火坑里不太好啊。</p>
</li>
<li>
<p><strong>cn 域名有被停用的风险</strong>。2008 年,有人以跳水奥运冠军吴敏霞拼音注册了 wuminxia.cn<a href="https://www.cnbeta.com/articles/tech/62209.htm">结果被中国互联网络信息中心CNNIC回收了域名</a>,并转交给国家体育总局。此域名在 2021 年 2 月 28 日被优视科技<a href="https://whois.cnnic.cn/WhoisServlet?queryType=Domain&amp;domain=wuminxia.cn">注册</a>呵呵。2009 年,牛博网被域名注册商万网停止解析。</p>
</li>
</ul>
<h2 id="vps">VPS</h2>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span># 更新系统
</span><span>apt update &amp;&amp; apt upgrade -y
</span><span>apt install wget curl vim sudo neofetch
</span><span># 创建用户并赋予sudo
</span><span>adduser xxx
</span><span>sudo usermod -aG sudo xxx
</span></code></pre>
<h2 id="bbr">BBR</h2>
<ul>
<li>查询系统所支持的拥塞控制算法</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sysctl net.ipv4.tcp_available_congestion_control
</span></code></pre>
<ul>
<li>查询正在使用中的拥塞控制算法Linux 绝大部分系统默认为 Cubic 算法)</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sysctl net.ipv4.tcp_congestion_control
</span></code></pre>
<ul>
<li>指定拥塞控制算法为 bbr</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>echo net.ipv4.tcp_congestion_control=bbr &gt;&gt; /etc/sysctl.conf &amp;&amp; sysctl -p
</span></code></pre>
<h2 id="safe">Safe</h2>
<blockquote>
<p>使用密码登录更换SSH端口+安装UFW+安装Fail2ban
使用密钥登录:不用额外操作</p>
</blockquote>
<h3 id="geng-huan-sshduan-kou">更换SSH端口</h3>
<p>使用root账户或已经有sudo权限的用户登录到系统。</p>
<p>打开SSH配置文件<code>sshd_config</code>可以使用文本编辑器如nano或vi。以下是使用nano编辑器的示例</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo vim /etc/ssh/sshd_config
</span></code></pre>
<p>在配置文件中找到以下行:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>Port 22
</span></code></pre>
<p>这是SSH默认的端口号你可以将其更改为你想要的任何未被占用的端口号。例如将端口更改为2222</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>Port 2222
</span></code></pre>
<p>保存并关闭文本编辑器。重新启动SSH服务以应用更改</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo service ssh restart
</span></code></pre>
<p>或者如果你的系统使用systemd可以使用以下命令</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl restart ssh
</span></code></pre>
<h3 id="an-zhuang-ufw">安装 UFW</h3>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo apt install ufw
</span></code></pre>
<p><strong>如果你在远程位置连接你的服务器,在启用 UFW 防火墙之前,你必须显式允许进来的 SSH 连接。否则,你将永远都无法连接到机器上。</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo ufw allow 22/tcp
</span></code></pre>
<blockquote>
<p>如果 SSH 运行在非标准端口,你需要将上述命令中的 22 端口替换为对应的 SSH 端口。</p>
</blockquote>
<p><strong>启动 UFW</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo ufw enable
</span></code></pre>
<h3 id="an-zhuang-fail2ban">安装 Fail2ban</h3>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo apt-get install fail2ban
</span></code></pre>
<p><strong>2、Debian 12 及以上的版本需要手动安装 rsyslog</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo apt-get install rsyslog
</span></code></pre>
<p><strong>3、启动 Fail2ban 服务</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl start fail2ban
</span></code></pre>
<p><strong>4、开机自启动</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl enable fail2ban
</span></code></pre>
<p><strong>5、查看 Fail2ban 服务状态。</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl status fail2ban
</span></code></pre>
<h3 id="gai-wei-mi-yao-deng-lu">改为密钥登录</h3>
<ul>
<li>执行以下命令生成.pub后缀的公钥和无后缀的密钥</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>ssh-keygen
</span></code></pre>
<p>注意不同密钥对名称不能相同;同时可以为这两个文件用密码加密;</p>
<ul>
<li>
<p>随后将.pub后缀的公钥中的内容写入服务器的<code>~/.ssh/authorized_keys</code>中;</p>
</li>
<li>
<p>使用以下命令编译服务器的SSH配置</p>
</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>vim /etc/ssh/sshd_config
</span></code></pre>
<p>将其中的该行改为<code>PasswordAuthentication no</code>,保存退出;随后使用</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl restart sshd
</span></code></pre>
<p>重启SSH即可禁用密码登录</p>
<ul>
<li>
<p><strong>PermitRootLogin</strong>一栏改为<strong>PermitRootLogin prohibit-password</strong>即可实现仅root用户密钥登录</p>
</li>
<li>
<p>使用以下命令查看输出,</p>
</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo cat /etc/ssh/sshd_config | grep -E &#39;PasswordAuthentication|PubkeyAuthentication&#39;
</span></code></pre>
<p>如有<strong>PasswordAuthentication no → 禁用密码登录</strong>以及<strong>PubkeyAuthentication yes → 允许密钥登录</strong>则成功。</p>
<blockquote>
<p>注意<strong>authorized_keys</strong>的权限为600如果不是则需要改正<code>chmod 600 ~/.ssh/authorized_keys</code></p>
</blockquote>
<h2 id="chang-yong-huan-jing">常用环境</h2>
<ul>
<li>ALL</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>apt install curl wget gpg vim nano sudo neofetch openssh-server
</span></code></pre>
<ul>
<li>C/C++</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo apt install build-essential gdb cmake clangd clang-format libstdc++-dev
</span></code></pre>
<ul>
<li>Miniconda</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
</span><span>bash Miniconda3-latest-Linux-x86_64.sh
</span></code></pre>
<ul>
<li>UV</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>curl -LsSf https://astral.sh/uv/install.sh | sh
</span></code></pre>
<ul>
<li>Docker</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>curl -fsSL https://get.docker.com -o get-docker.sh
</span><span>sudo sh get-docker.sh
</span></code></pre>
<ul>
<li>OpenCV</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo apt install tree libx11-dev libgtk-3-dev freeglut3-dev libopencv-dev libdlib-dev
</span></code></pre>
<ul>
<li>Vmware</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo apt install open-vm-tools
</span><span>sudo apt install open-vm-tools-desktop
</span></code></pre>
<blockquote>
<p>Vscode无法连接需要删除本地存储的错误密钥powershell</p>
</blockquote>
<pre data-lang="powershell" style="background-color:#151515;color:#e8e8d3;" class="language-powershell "><code class="language-powershell" data-lang="powershell"><span>(Get-Content </span><span style="color:#556633;">&quot;</span><span style="color:#ffb964;">$env:USERPROFILE</span><span style="color:#99ad6a;">\.ssh\known_hosts</span><span style="color:#556633;">&quot;</span><span>) |
</span><span>Where-Object { $_ -notmatch </span><span style="color:#556633;">&#39;</span><span style="color:#99ad6a;">&lt;你的IP&gt;</span><span style="color:#556633;">&#39; </span><span>} |
</span><span>Set-Content </span><span style="color:#556633;">&quot;</span><span style="color:#ffb964;">$env:USERPROFILE</span><span style="color:#99ad6a;">\.ssh\known_hosts</span><span style="color:#556633;">&quot;
</span></code></pre>
<h2 id="1panel">1panel</h2>
<p>执行如下命令一键安装 1Panel:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh &amp;&amp; sudo bash quick_start.sh
</span></code></pre>
<h3 id="jin-yong-ipv6">禁用 IPv6</h3>
<p>手动 禁用 VPS 的 IPv6 命令:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sysctl -w net.ipv6.conf.all.disable_ipv6=1
</span><span>sysctl -w net.ipv6.conf.default.disable_ipv6=1
</span></code></pre>
<p>如果想重启系统也生效, 执行:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>echo &#39;net.ipv6.conf.all.disable_ipv6=1&#39; &gt;&gt; /etc/sysctl.conf
</span><span>echo &#39;net.ipv6.conf.default.disable_ipv6=1&#39; &gt;&gt; /etc/sysctl.conf
</span></code></pre>
<p>手动 启用 VPS 的 IPv6 命令:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sysctl -w net.ipv6.conf.all.disable_ipv6=0
</span><span>sysctl -w net.ipv6.conf.default.disable_ipv6=0
</span></code></pre>
<p>重新载入 sysctl 配置</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sysctl --system # reload sysctl
</span></code></pre>
<p>如果重载, 还无效果, 可能要 reboot 重启下.
查看 VPS 的 IPv6 信息</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>ip -6 addr show scope global
</span><span>
</span><span>或者 curl ipv6.ip.sb
</span></code></pre>
<h2 id="ipzheng-shu-shen-qing-bu-shu">IP证书申请部署</h2>
<ul>
<li>
<p><a href="https://zerossl.com/">ZeroSSL</a> 中申请一个90天的证书</p>
</li>
<li>
<p>然后在VPS上输入以下命令</p>
</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>mkdir -p ./.well-known/pki-validation
</span></code></pre>
<ul>
<li>
<p>随后在ZeroSSL中将所给出的类似<strong>B992F08CB46748D02E4C553A4038BC.txt</strong>复制;</p>
</li>
<li>
<p>将从ZeroSSL下载得到的文件打开复制里面的东西形成以下的格式:<code>将pki-validation/之后EOF之前的内容</code>替换为你自己的。</p>
</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>cat &lt;&lt; EOF | sudo tee ./.well-known/pki-validation/B992F08CB46748D02E4C553A4038BC.txt
</span><span>254563C20918258D661E7D43D6A43A2A258857E191977DD5F740FBB9ABD25279
</span><span>comodoca.com
</span><span>ca5792984e3f0a1
</span><span>EOF
</span></code></pre>
<p>随后在VPS上运行该命令。</p>
<ul>
<li>开启一个临时HTTP服务器</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>python3 -m http.server 80
</span></code></pre>
<ul>
<li>随后即可在ZeroSSL中验证证书并开启SSL。</li>
</ul>
<h2 id="wang-ji-mi-ma-zen-me-ban">忘记密码怎么办</h2>
<p>通过恢复模式 (Recovery Mode) 修改用户权限:</p>
<ul>
<li>
<p>重启计算机,按住 Shift 键进入 GRUB 菜单(或者按 Esc 键)。</p>
</li>
<li>
<p>在 GRUB 菜单中,选择<code>Advanced options for Ubuntu</code>然后选择带有<code>recovery mode</code>的内核版本。</p>
</li>
<li>
<p>进入恢复模式后,选择<code>root Drop to root shell prompt</code>进入 root shell不需要密码</p>
</li>
<li>
<p>挂载文件系统为可写模式:</p>
</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>mount -o remount,rw /
</span></code></pre>
<ul>
<li>将用户添加到 sudo 组:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>usermod -aG sudo 用户名
</span></code></pre>
<ul>
<li>重启计算机:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>reboot
</span></code></pre>
<h2 id="geng-huan-nei-he">更换内核</h2>
<p>以Xanmod为例</p>
<ol>
<li>添加 XanMod 仓库密钥和源</li>
</ol>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span>echo </span><span style="color:#556633;">&#39;</span><span style="color:#99ad6a;">deb [signed-by=/usr/share/keyrings/xanmod.gpg] http://deb.xanmod.org releases main</span><span style="color:#556633;">&#39; </span><span>| </span><span style="color:#ffb964;">sudo</span><span> tee /etc/apt/sources.list.d/xanmod.list
</span><span style="color:#ffb964;">curl -fsSL</span><span> https://dl.xanmod.org/gpg.key | </span><span style="color:#ffb964;">gpg --dearmor </span><span>| </span><span style="color:#ffb964;">sudo</span><span> tee /usr/share/keyrings/xanmod.gpg &gt; /dev/null
</span></code></pre>
<ol start="2">
<li>更新软件包列表</li>
</ol>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">sudo</span><span> apt update
</span></code></pre>
<ol start="3">
<li>搜索可用内核</li>
</ol>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>apt search xanmod
</span><span>sudo apt install linux-image-6.8.6-x64v3-xanmod1 linux-headers-6.8.6-x64v3-xanmod1
</span></code></pre>
<h3 id="chang-jian-xanmod-nei-he-hou-zhui-han-yi-dui-bi">常见 XanMod 内核后缀含义对比</h3>
<table><thead><tr><th>后缀示例</th><th>含义简述</th><th>适合用途</th></tr></thead><tbody>
<tr><td><code>xanmod1</code>, <code>xanmod2</code>, …</td><td>主线 XanMod 版本编号(带通用优化)</td><td>桌面、通用、游戏</td></tr>
<tr><td><code>x64v3-xanmod1</code></td><td>针对 <strong>x86_64-v3 架构优化</strong>AVX2 以上指令集)</td><td>高性能桌面、较新 CPU2011+</td></tr>
<tr><td><code>rt-xanmod1</code></td><td><strong>实时RT内核</strong>,用于极低延迟任务</td><td>音频制作、工业控制</td></tr>
<tr><td><code>lts-xanmod1</code></td><td><strong>长期支持版本</strong>LTS</td><td>服务器、稳定性优先</td></tr>
<tr><td><code>edge-xanmod1</code></td><td>更前沿、不稳定的测试版本</td><td>喜欢尝鲜的高级用户</td></tr>
<tr><td><code>x64v2-xanmod1</code>, <code>x64v4-…</code></td><td>针对特定 <strong>微架构CPU 指令集)</strong> 的优化版本</td><td>有特定硬件支持的系统</td></tr>
</tbody></table>
<p>你可以用以下命令检测你的 CPU 是否支持 <code>x64v3</code></p>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">lscpu </span><span>| </span><span style="color:#ffb964;">grep</span><span> avx2
</span></code></pre>
<p>如果输出中有 <code>avx2</code>,就可以用 <code>x64v3</code> 版本。</p>
<ol start="4">
<li>更新 GRUB 并重启</li>
</ol>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">sudo</span><span> update-grub
</span><span style="color:#ffb964;">sudo</span><span> reboot
</span><span style="color:#ffb964;">uname -r
</span></code></pre>
<ol start="5">
<li>移除旧内核(可选)</li>
</ol>
<p>查看已安装内核:</p>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">dpkg --list </span><span>| </span><span style="color:#ffb964;">grep</span><span> linux-image
</span></code></pre>
<p>移除旧的:</p>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">sudo</span><span> apt remove linux-image-5.10.0-26-amd64
</span></code></pre>
<hr />
<ol start="6">
<li>自动选择 XanMod 为默认(可选)</li>
</ol>
<p>如果你想默认引导到 XanMod 内核:</p>
<p>编辑 <code>/etc/default/grub</code></p>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">GRUB_DEFAULT</span><span>=</span><span style="color:#556633;">&quot;</span><span style="color:#99ad6a;">Advanced options for Debian&gt;Debian, with Linux 6.8.6-x64v3-xanmod1</span><span style="color:#556633;">&quot;
</span></code></pre>
<p>然后:</p>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">sudo</span><span> update-grub
</span></code></pre>
<h2 id="geng-huan-xi-tong">更换系统</h2>
<p>除了到VPS后台更换外还可以使用这个脚本</p>
<p><a href="https://blog.dich.bid/about-server-set/github.com/bin456789/reinstall">bin456789/reinstall</a></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>一键重装到 Linux支持 19 种常见发行版
</span><span>一键重装到 Windows使用官方原版 ISO 而非自制镜像,脚本支持自动查找 ISO 链接、自动安装 VirtIO 等公有云驱动
</span><span>支持任意方向重装,即 Linux to Linux、Linux to Windows、Windows to Windows、Windows to Linux
</span><span>自动设置 IP智能设置动静态支持 /32、/128、网关不在子网范围内、纯 IPv6、IPv4/IPv6 在不同的网卡
</span><span>专门适配低配小鸡,比官方 netboot 需要更少的内存
</span><span>全程用分区表 ID 识别硬盘,确保不会写错硬盘
</span><span>支持 BIOS、EFI 引导,支持 ARM 服务器
</span><span>不含自制包,所有资源均实时从镜像源获得
</span></code></pre>
<hr />
<p><strong>Done.</strong></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/about-cslearning/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">乱七八糟:计算机科学优质视频</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/network-docker/">
<span class="button__text">网络艺术:Docker建站与反向代理</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,425 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-shortcut-key/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-shortcut-key/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-shortcut-key/">乱七八糟:常用实用快捷键</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2024-05-23
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 在日常使用浏览器时,掌握一些快捷键和技巧可以节省大量时间,提高工作和学习效率。通过学习和实践,能够更加轻松地应对各种网页浏览场景,让浏览器成为工作和学习的得力助手。</p>
<span id="continue-reading"></span><h2 id="liu-lan-qi-kuai-jie-jian">浏览器快捷键</h2>
<h3 id="chang-yong">常用</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td>Ctrl + A</td><td>全选</td></tr>
<tr><td>Ctrl + C</td><td>复制</td></tr>
<tr><td>Ctrl + X</td><td>剪切</td></tr>
<tr><td>Ctrl + V</td><td>粘贴</td></tr>
<tr><td>Ctrl + F</td><td>查找</td></tr>
<tr><td>Ctrl + Q</td><td>退出</td></tr>
<tr><td>Ctrl + T</td><td>新建标签页</td></tr>
<tr><td>Ctrl + W</td><td>关闭标签页</td></tr>
<tr><td>Ctrl + N</td><td>新建窗口</td></tr>
<tr><td>Ctrl + Shift + P</td><td>新建隐私浏览窗口</td></tr>
</tbody></table>
<h3 id="li-shi">历史</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td>Ctrl + H</td><td>历史侧栏</td></tr>
<tr><td>Ctrl + Shift + H</td><td>我的足迹窗口(历史)</td></tr>
<tr><td>Ctrl + Shift + Del</td><td>清除最近历史记录</td></tr>
</tbody></table>
<h3 id="shu-qian">书签</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td>Ctrl + D</td><td>将此页加为书签</td></tr>
<tr><td>Ctrl + I</td><td>页面信息</td></tr>
<tr><td>Ctrl + Shift + O</td><td>显示全部书签(我的足迹窗口)</td></tr>
<tr><td>Ctrl + B / Ctrl + Shift + B</td><td>书签侧栏 / 顶栏</td></tr>
</tbody></table>
<h3 id="xia-zai-yu-cha-jian">下载与插件</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td>Ctrl + Shift + Y</td><td>下载</td></tr>
<tr><td>Ctrl + Shift + A</td><td>附加组件 / 插件</td></tr>
</tbody></table>
<h3 id="kong-zhi-tai-yu-kai-fa">控制台与开发</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td>Ctrl + Shift + K</td><td>Web 控制台</td></tr>
<tr><td>Ctrl + Shift + C</td><td>查看器</td></tr>
<tr><td>Shift + F7</td><td>样式编辑器</td></tr>
<tr><td>Shift + F5</td><td>分析器</td></tr>
<tr><td>Ctrl + Shift + E</td><td>网络</td></tr>
<tr><td>Ctrl + U</td><td>页面源码</td></tr>
<tr><td>Ctrl + Shift + J</td><td>浏览器控制台</td></tr>
</tbody></table>
<h3 id="biao-qian-ye-yu-jie-mian">标签页与界面</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td>Ctrl + S</td><td>界面保存</td></tr>
<tr><td>Ctrl + +</td><td>放大</td></tr>
<tr><td>Ctrl + -</td><td>缩小</td></tr>
<tr><td>Ctrl + 0</td><td>重置缩放</td></tr>
<tr><td>Ctrl + K / J</td><td>搜索</td></tr>
<tr><td>Ctrl + Home / End</td><td>到文件头 / 尾</td></tr>
<tr><td>Ctrl + Page Up</td><td>切换到左边标签页</td></tr>
<tr><td>Ctrl + Page Down</td><td>切换到右边标签页</td></tr>
<tr><td>Ctrl + Shift + Page Up</td><td>当前标签页左移</td></tr>
<tr><td>Ctrl + Shift + Page Down</td><td>当前标签页右移</td></tr>
</tbody></table>
<h3 id="qi-ta-cao-zuo">其他操作</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td>Alt + Space</td><td>KDE 搜索栏</td></tr>
<tr><td>Alt + → / ←</td><td>前进 / 后退</td></tr>
<tr><td>Alt + 数字键</td><td>选择标签页18</td></tr>
<tr><td>Alt + M</td><td>静音</td></tr>
<tr><td>End</td><td>到达页尾</td></tr>
<tr><td>Home</td><td>到达页首</td></tr>
<tr><td>F6</td><td>地址栏</td></tr>
</tbody></table>
<h2 id="vs-code-kuai-jie-jian">VS Code 快捷键</h2>
<h3 id="jie-mian-gai-lan">界面概览</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>cmd + shift + e</code></td><td>文件资源管理器</td></tr>
<tr><td><code>cmd + shift + f</code></td><td>跨文件搜索</td></tr>
<tr><td><code>ctrl + shift + g</code></td><td>源代码管理</td></tr>
<tr><td><code>cmd + shift + d</code></td><td>启动和调试</td></tr>
<tr><td><code>cmd + shift + x</code></td><td>扩展管理</td></tr>
<tr><td><code>cmd + shift + p</code></td><td>查找并运行所有命令</td></tr>
<tr><td><code>cmd + j</code></td><td>打开、关闭面板</td></tr>
</tbody></table>
<h3 id="ming-ling-xing-de-shi-yong">命令行的使用</h3>
<table><thead><tr><th>命令</th><th>描述</th></tr></thead><tbody>
<tr><td><code>code $path</code></td><td>新窗口中打开文件或文件夹</td></tr>
<tr><td><code>code -r $path</code></td><td>窗口复用打开文件</td></tr>
<tr><td><code>code -r -g $file:lineno</code></td><td>打开文件并跳转到指定行</td></tr>
<tr><td><code>code -r -d $file1 $file2</code></td><td>比较两个文件</td></tr>
<tr><td><code>ls code -</code></td><td>查看可用命令</td></tr>
</tbody></table>
<h3 id="guang-biao-yi-dong">光标移动</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>option + 左/右方向键</code></td><td>按单词移动光标</td></tr>
<tr><td><code>cmd + 左/右方向键</code></td><td>移动到行首/行尾</td></tr>
<tr><td><code>cmd + shift + \</code></td><td>在花括号之间跳转</td></tr>
<tr><td><code>cmd + 上/下方向键</code></td><td>移动到文档首/尾</td></tr>
</tbody></table>
<h3 id="wen-ben-xuan-ze">文本选择</h3>
<ul>
<li>使用 <code>shift + 光标移动</code> 进行文本选择。</li>
</ul>
<h3 id="shan-chu-cao-zuo">删除操作</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>cmd + fn + del</code></td><td>删除到行尾</td></tr>
<tr><td><code>cmd + del</code></td><td>删除到行首</td></tr>
<tr><td><code>option + del</code></td><td>向前删除单词</td></tr>
<tr><td><code>option + fn + del</code></td><td>向后删除单词</td></tr>
</tbody></table>
<h3 id="dai-ma-xing-bian-ji">代码行编辑</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>cmd + shift + k</code></td><td>删除行</td></tr>
<tr><td><code>cmd + x</code></td><td>剪切行</td></tr>
<tr><td><code>cmd + enter</code></td><td>在当前行下方插入新行</td></tr>
<tr><td><code>cmd + shift + enter</code></td><td>在当前行上方插入新行</td></tr>
<tr><td><code>option + 上/下方向键</code></td><td>移动当前行</td></tr>
<tr><td><code>option + shift + 上/下方向键</code></td><td>复制当前行</td></tr>
<tr><td><code>cmd + /</code></td><td>注释/取消注释当前行</td></tr>
<tr><td><code>option + shift + a</code></td><td>注释/取消注释代码块</td></tr>
<tr><td><code>option + shift + f</code></td><td>格式化代码</td></tr>
<tr><td><code>cmd + k cmd + f</code></td><td>格式化选中代码</td></tr>
<tr><td><code>ctrl + t</code></td><td>调换光标前后字符</td></tr>
<tr><td><code>cmd + shift + p</code> + <code>transform to up/low case</code></td><td>转换大小写</td></tr>
<tr><td><code>ctrl + j</code></td><td>合并代码行</td></tr>
<tr><td><code>cmd + u</code></td><td>撤销光标移动</td></tr>
</tbody></table>
<h3 id="chuang-jian-duo-ge-guang-biao">创建多个光标</h3>
<ul>
<li>使用鼠标:<code>option + 鼠标左键</code></li>
<li>使用键盘:</li>
</ul>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>cmd + option + 上/下方向键</code></td><td>创建多个光标</td></tr>
<tr><td><code>cmd + d</code></td><td>选中相同单词并创建多个光标</td></tr>
<tr><td><code>option + shift + i</code></td><td>在选中的多行后创建光标</td></tr>
</tbody></table>
<h3 id="wen-jian-tiao-zhuan">文件跳转</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>ctrl + tab</code></td><td>文件标签之间跳转</td></tr>
<tr><td><code>cmd + p</code></td><td>打开文件列表</td></tr>
</tbody></table>
<h3 id="xing-tiao-zhuan">行跳转</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>ctrl + g</code></td><td>跳转到指定行</td></tr>
</tbody></table>
<h3 id="fu-hao-tiao-zhuan">符号跳转</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>cmd + shift + o</code></td><td>当前文件所有符号列表</td></tr>
<tr><td><code>@:</code></td><td>符号分类排列</td></tr>
<tr><td><code>cmd + t</code></td><td>在多个文件中进行符号跳转</td></tr>
<tr><td><code>cmd + F12</code></td><td>跳转到函数的实现位置</td></tr>
<tr><td><code>shift + F12</code></td><td>查看函数引用列表</td></tr>
<tr><td><code>ctrl + -</code></td><td>跳回上一次光标所在位置</td></tr>
<tr><td><code>ctrl + shift + -</code></td><td>跳回下一次光标所在位置</td></tr>
</tbody></table>
<h3 id="dai-ma-zi-dong-bu-quan">代码自动补全</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>ctrl + space</code></td><td>调出建议列表</td></tr>
<tr><td><code>cmd + shift + space</code></td><td>调出参数预览窗口</td></tr>
<tr><td><code>cmd + .</code></td><td>快速修复建议列表</td></tr>
<tr><td><code>F2</code></td><td>函数名重构</td></tr>
</tbody></table>
<h3 id="dai-ma-zhe-die">代码折叠</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>cmd + option + [</code></td><td>最内层折叠</td></tr>
<tr><td><code>cmd + option + ]</code></td><td>最内层展开</td></tr>
<tr><td><code>cmd + k cmd + 0</code></td><td>全部折叠</td></tr>
<tr><td><code>cmd + k cmd + j</code></td><td>全部展开</td></tr>
</tbody></table>
<h3 id="sou-suo">搜索</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>cmd + f</code></td><td>搜索</td></tr>
<tr><td><code>cmd + g</code></td><td>搜索并跳转</td></tr>
<tr><td><code>cmd + option + f</code></td><td>查找替换</td></tr>
<tr><td><code>cmd + shift + f</code></td><td>多文件搜索</td></tr>
</tbody></table>
<h3 id="bian-ji-qi-cao-zuo">编辑器操作</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>cmd + \</code></td><td>拆分编辑器</td></tr>
<tr><td><code>option + cmd + 左/右方向键</code></td><td>编辑器间切换</td></tr>
<tr><td><code>cmd + 数字键</code></td><td>在拆分的编辑器窗口跳转</td></tr>
<tr><td><code>cmd + /</code></td><td>缩放整个工作区</td></tr>
<tr><td><code>cmd + shift + p</code> + <code>reset zoom</code></td><td>重置缩放</td></tr>
</tbody></table>
<h3 id="zhuan-zhu-mo-shi">专注模式</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>cmd + b</code></td><td>打开或关闭侧边栏</td></tr>
<tr><td><code>cmd + j</code></td><td>打开或关闭面板</td></tr>
<tr><td><code>cmd + shift + p</code> + <code>Toggle Zen Mode</code></td><td>切换禅模式</td></tr>
<tr><td><code>cmd + shift + p</code> + <code>Toggle Centered Layout</code></td><td>切换居中布局</td></tr>
</tbody></table>
<h3 id="ming-ling-mian-ban">命令面板</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>cmd + shift + p</code></td><td>打开命令面板</td></tr>
</tbody></table>
<p>命令面板的前缀符号功能:</p>
<ul>
<li><code>?</code>:列出所有可用功能</li>
<li><code>&gt;</code>:显示所有命令</li>
<li><code>@</code>:显示并跳转文件中的符号</li>
<li><code>@:</code>:按类别归类符号</li>
<li><code>#</code>:显示并跳转工作区中的符号</li>
<li><code>:</code>:跳转到当前文件中的某一行</li>
<li><code>edt</code>:显示所有已打开的文件</li>
<li><code>edt active</code>:显示当前活动组中的文件</li>
<li><code>ext</code>:插件管理</li>
<li><code>ext install</code>:搜索和安装插件</li>
<li><code>task</code>:任务管理</li>
<li><code>debug</code>:调试功能</li>
<li><code>term</code>:创建和管理终端实例</li>
<li><code>view</code>:打开各个 UI 组件</li>
</ul>
<h3 id="chuang-kou-guan-li">窗口管理</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>ctrl + w</code></td><td>关闭当前窗口</td></tr>
<tr><td><code>ctrl + r</code></td><td>切换文件夹</td></tr>
<tr><td><code>ctrl + r</code> + <code>cmd + enter</code></td><td>新建窗口打开文件夹</td></tr>
</tbody></table>
<h3 id="ji-cheng-zhong-duan">集成终端</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td>`ctrl + ``</td><td>切换集成终端</td></tr>
<tr><td>`ctrl + shift + ``</td><td>新建集成终端</td></tr>
<tr><td><code>cmd + shift + p</code> + <code>Run Active File In Active Terminal</code></td><td>在终端中运行当前文件</td></tr>
<tr><td><code>cmd + shift + p</code> + <code>Run Selected Text In Active Terminal</code></td><td>在终端中运行选中文本</td></tr>
</tbody></table>
<h3 id="ren-wu-guan-li">任务管理</h3>
<table><thead><tr><th>快捷键</th><th>描述</th></tr></thead><tbody>
<tr><td><code>cmd + shift + p</code> + <code>run task</code></td><td>自动检测可运行的任务</td></tr>
<tr><td><code>cmd + shift + p</code> + <code>Configure Task</code></td><td>配置任务</td></tr>
<tr><td><code>cmd + shift + b</code></td><td>运行默认的生成任务</td></tr>
</tbody></table>
<h3 id="shu-biao-cao-zuo">鼠标操作</h3>
<ul>
<li>
<p><strong>文本选择</strong></p>
<ul>
<li>双击:选中单词</li>
<li>三击:选中一行</li>
<li>四击:选中整个文档</li>
<li>单击行号:选中整行</li>
</ul>
</li>
<li>
<p><strong>文本编辑</strong></p>
<ul>
<li>拖动选中文本:移动文本</li>
<li>拖动时按住 <code>option</code>:复制文本</li>
</ul>
</li>
<li>
<p><strong>函数提示</strong></p>
<ul>
<li>在悬停窗口上按下 <code>cmd</code>:提示函数的实现</li>
</ul>
</li>
</ul>
<hr />
<p><strong>Done.</strong></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/about-podcast-use/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">乱七八糟:播客收听指北</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/windows-1-install/">
<span class="button__text">Windows系列(1):系统安装与设置</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,219 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-sports/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-sports/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-sports/">乱七八糟:运动健身基本理论</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2025-07-05
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 本文记录着无器械健身理论以及相关的读后感。</p>
<span id="continue-reading"></span><h2 id="qian-yan">前言</h2>
<p>人类的发展史决定了增肥比减肥容易,脂肪的快速积累能力保障了我们的祖先在冰河/饥荒/战乱年代的生存,否则将带来极大的生存劣势;而如今食物的匮乏在大多数国家已经不是问题,肥胖/超重问题频发。</p>
<blockquote>
<p>BMI身体质量指数(Body Mass Index)计算体重kg/身高(m)2,如体重70kg身高1.75m则BMI为22.86.</p>
</blockquote>
<table><thead><tr><th>BMI 值</th><th>体重分类</th></tr></thead><tbody>
<tr><td>&lt; 18.5</td><td>体重过轻</td></tr>
<tr><td>18.5 23.9</td><td>正常范围</td></tr>
<tr><td>24 27.9</td><td>超重</td></tr>
<tr><td>28 及以上</td><td>肥胖</td></tr>
</tbody></table>
<h2 id="xun-lian-mu-biao">训练目标</h2>
<p><strong>提高五大综合水平</strong></p>
<ul>
<li>力量:包括肌肉力量和爆发力</li>
<li>耐力:保持运动时间的长短</li>
<li>速度:快速做系列动作的能力</li>
<li>协调:包括平衡性和精确动作能力</li>
<li>柔韧:可做到动作幅度的大小</li>
</ul>
<p>自体重训练完全可以达到预期效果,实现简单方便,无须复杂器械。</p>
<h2 id="ji-ben-li-lun">基本理论</h2>
<ul>
<li>减肥:消耗热量大于摄入热量,减掉赘余脂肪</li>
<li>静息代谢率(RMR):指休息时维持身体所有功能要消耗的热量,主要由肌肉消耗,可以理解为电脑功耗;</li>
<li>有氧运动:有氧运动的消耗热量并不高,且会带来饥饿感,甚至消耗肌肉,应该用间隔力量训练替代;</li>
<li>减肥方法1.提高RMR,通过力量训练锻炼出消耗热量的肌肉;2.控制饮食,减少摄入热量;</li>
</ul>
<h2 id="wu-qu">误区</h2>
<ul>
<li>局部减肥:减脂肪是全身同时进行的,单单通过某部位锻炼,可能会造成肌肉外推脂肪导致外形不显;</li>
<li>肌肉转换:肌肉并不能转换为脂肪,二者是完全不同的细胞;</li>
<li>严格节食:会降低新陈代谢率,减少热量消耗,往往适得其反;</li>
<li>过度发达实际上男性一个月增重0.68kg女性增重0.23kg是很困难的,减肥同理;</li>
</ul>
<h2 id="ying-yang">营养</h2>
<ul>
<li>基本食物种类:蔬菜/水果/坚果/种子/肉类/蛋类/鱼类</li>
<li>深加工食物的营养价值有待商榷,容易打乱内分泌和增加食欲;</li>
<li>少食多餐每天吃5~6餐间隔3小时左右让身体意识到无须过于储存脂肪</li>
<li>高糖类食物会提高胰岛素分泌降低血糖,使我们容易感到疲劳和更想摄入糖分,形成恶性循环;</li>
<li>蛋白质和水的摄入非常重要,不要等到口渴的时候才喝水;</li>
</ul>
<h2 id="xun-lian">训练</h2>
<p>未完待续...</p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/about-gpg/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">乱七八糟:GPG使用小记</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/linux-2-stm32/">
<span class="button__text">Linux-STM32开发环境部署</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,268 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-ventoy/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-ventoy/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-ventoy/">乱七八糟:Ventoy战斗盘部署</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2025-02-14
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 Ventoy 是一款开源免费的多系统启动盘制作工具,这里说明其主要功能的制作流程。</p>
<span id="continue-reading"></span><h3 id="jie-shao">介绍</h3>
<p>Ventoy 是一款开源免费的多系统启动盘制作工具旨在简化操作系统的安装过程。与传统的启动盘制作方法不同Ventoy 允许用户将多个操作系统的镜像文件<code>如 ISO、WIM、IMG、VHD(x)、EFI 等</code>直接复制到 U 盘,无需反复格式化或使用专门的工具写入镜像。</p>
<p><img src="https://www.ventoy.net/static/img/screen/screen_uefi_cn.png?v=4" alt="ventoy" /></p>
<h2 id="mu-biao">目标</h2>
<blockquote>
<p>PE启动盘 / ISO系统安装盘 / Win-to-go / Linux-to-go / 文件存储 五功能合一</p>
</blockquote>
<h2 id="zhi-zuo-liu-cheng">制作流程</h2>
<ul>
<li>首先<code>在官网下载</code><a href="https://www.ventoy.net/cn/download.html">Ventoy</a></li>
<li>随后在<code>language</code>中改为中文显示,可以看到左上角有<code>配置选项</code></li>
<li>将分区类型设置为<code>GPT</code>,开启安全启动支持;</li>
<li><code>分区格式</code>设置为NTFS</li>
<li>随后在<code>分区设置</code>中进行分区,选择在<code>磁盘后保留一段空间</code>,这里的空间将不被分区,即为空闲空间,可以当作普通的文件存储盘;</li>
<li>Ventoy分区则会使用<code>U盘总容量-保留空间-ventoy保留分区</code>的空间新建一个盘,这里可以放<code>ISO、WIM、IMG、VHD(x)、EFI</code>等等</li>
<li>随后<code>选择磁盘</code>并开始安装;</li>
<li>制作完成后即可使用 <code>BIOS Legacy</code>模式 或 <code>UEFI</code> 模式启动。</li>
</ul>
<blockquote>
<p>注意不可在PE环境下安装Ventoy</p>
</blockquote>
<h2 id="wen-jian-cun-chu-pan">文件存储盘</h2>
<p>使用<code>DiskGenius</code>或其他磁盘工具可以看到刚刚制作的磁盘有两个分区ventoy保留分区(有文件)和Ventoy分区(无文件)以及一个空闲空间。</p>
<p>将空闲空间<code>格式化并新建磁盘</code>,随后会出现一个新的可用盘,<code>可以用这个盘进行存储</code></p>
<h2 id="peqi-dong-pan-zhi-zuo">PE启动盘制作</h2>
<p>将PE的ISO文件放入Ventoy分区即可。常用PE:</p>
<ul>
<li><a href="https://www.wepe.com.cn/download.html">微PE</a></li>
<li><a href="https://github.com/VirtualHotBar/HotPEToolBox">HotPE</a></li>
</ul>
<h2 id="isoxi-tong-an-zhuang-pan">ISO系统安装盘</h2>
<p>将要安装的系统的ISO镜像放入Ventoy分区即可。常用系统:</p>
<ul>
<li><a href="https://ubuntu.com/download">Ubuntu</a></li>
<li><a href="https://cdimage.debian.org/debian-cd/">Debian-DVD</a></li>
<li><a href="https://massgrave.dev/genuine-installation-media">Windows</a></li>
</ul>
<h2 id="win-to-go">Win-to-go</h2>
<p>Ventoy 使用名为ventoy_vhdboot插件来支持直接启动 VHD(x) 文件(Win7以上).支持 Legacy BIOS 和 UEFI 模式。<code>支持固定大小以及动态扩展类型</code>的 VHD/VHDX 格式。</p>
<p>从下面任意一个链接中下载<code>ventoy_vhdboot.img</code>文件即可(几个链接中的文件都是一样的)。</p>
<ul>
<li><a href="https://github.com/ventoy/vhdiso/releases">Github</a></li>
<li><a href="https://ventoy.lanzoub.com/b01dlxuaj">蓝奏云/密码7my4</a></li>
</ul>
<p>把下载后的文件放在U盘第1个分区就是放ISO文件的分区的 ventoy 目录下(默认没有这个目录,<code>需手动创建,注意大小写</code>),即 /ventoy/ventoy_vhdboot.img 就可以了。</p>
<p>随后将vhd或vhdx后缀的Windows虚拟机镜像放入其中即可出现在启动栏。</p>
<blockquote>
<p>可以使用<a href="https://www.virtualbox.org/">Virtualbox</a>创建Windows虚拟机并将镜像复制到ventoy中。</p>
</blockquote>
<h2 id="linux-to-go">Linux-to-go</h2>
<p>Ventoy 使用<code>plugin_vtoyboot</code>插件来支持在物理机上直接启动安装了 Linux系统的 vdisk 文件 vhd/vdi/raw 等)。这种模式的优点有:</p>
<ul>
<li>系统是在真实物理机上运行,并不是在虚拟机里运行,<code>没有性能损失</code></li>
<li>同一个 vhd/vdi 文件<code>既可以在 Legacy BIOS 模式下启动,也可以在 UEFI 模式</code>下启动。</li>
<li>Linux系统<code>无需独占一个磁盘或者分区</code>相当于把一个完整的Linux系统放在一个文件里。 比如,你的主系统是 C 盘里的 Windows 系统你可以在D盘里放一些</li>
<li>Deepin、UOS、Ubuntu、Arch 等系统的 VHD 文件,想启动哪个选哪个,不用了就把对应的 VHD 文件删除即可。</li>
</ul>
<p>支持的 vdisk 格式:</p>
<ul>
<li><code>固定大小的 vhd</code> 注意只能是vhd, 不支持vhdx</li>
<li><code>固定大小的 vdi</code></li>
<li><code>Raw Disk 镜像</code>格式</li>
</ul>
<h3 id="an-zhuang-linux-xi-tong-dao-vdisk">安装 Linux 系统到 vdisk</h3>
<p>VirtualBox中创建固定大小的 vhd/vdi注意<code>只支持静态大小的,不支持动态扩展类型的</code>。然后把支持的 Linux 系统安装到 vhd/vdi 中即可。</p>
<p>注意:</p>
<ul>
<li><code>虚拟硬盘必须是全新创建的</code>,不能使用之前用过的。</li>
<li>新版本的 VirtualBox 在创建虚拟机时不要选择操作系统ISO文件等创建完虚拟机之后再添加ISO文件进行安装。</li>
<li>安装系统时VirtualBox <code>必须设置为 UEFI 模式</code></li>
<li>注意,系统安装完之后<code>不能对虚拟机创建快照</code>,否则会导致 vdi/vhd 无法识别。</li>
</ul>
<p>有一些系统安装完之后还需要再额外安装一个 grub 的包才可以,否则最终的 vhd/vdi 文件只能在 UEFI 模式下启动,无法在 Legacy BIOS 模式下启动。对于这种,在前面表格最后的 "备注" 一栏有说明,没有特殊说明的就不需要。详见<a href="https://www.ventoy.net/cn/plugin_vtoyboot.html">Linux vDisk 文件启动插件</a></p>
<h3 id="zai-xi-tong-xia-zhi-xing-vtoyboot-jiao-ben">在系统下执行 vtoyboot 脚本</h3>
<ul>
<li>
<p>安装完成并启动到 Linux 系统中之后,执行 vtoyboot 脚本。这一步是为了在系统中做一些处理以支持Ventoy启动。</p>
</li>
<li>
<p>vtoyboot 是配套 Ventoy 开发的一个项目,单独发布。从 https://github.com/ventoy/vtoyboot/releases 下载压缩包即可。</p>
</li>
<li>
<p>下载到 Linux 系统中解压然后以root权限执行里面的脚本 sudo bash vtoyboot.sh 脚本执行完之后,使用 poweroff 命令关机。</p>
</li>
<li>
<p>注意 vtoyboot 会经常更新以支持更多的 Linux 版本以及修复 BUG所以请使用最新版本。</p>
</li>
</ul>
<blockquote>
<p>如果是对内核、驱动进行了升级、或者类似于通过 dnf update 命令进行了系统的大升级之后, 建议再重新执行一次 vtoyboot 脚本防止下次重启之后vDisk文件无法启动。</p>
</blockquote>
<p>随后拷贝到U盘改后缀名为 .vtoy 然后用 Ventoy 启动即可。</p>
<hr />
<p><strong>Done.</strong></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/network-homenet-2/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">家庭组网系列(2):路由器性能测试</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/network-frp/">
<span class="button__text">网络艺术:FRP使用指南</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,424 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about-virtual/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about-virtual/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about-virtual/">乱七八糟:虚拟化常用设置与操作</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2024-08-16
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
<div class="post-content">
<p>前言 本文记录常用虚拟化平台的使用与操作包括VmwareHypr-vQEMU等等。</p>
<span id="continue-reading"></span><h1 id="yi-vmware">一.Vmware</h1>
<h2 id="xia-zai">下载</h2>
<p>Vmware最新版本对个人已经免费不需要再寻找激活码</p>
<p>由于博通官网下载Vmware需要登录账号这里给出第三方下载站链接<a href="https://www.techspot.com/downloads/189-vmware-workstation-for-windows.html">techspot</a></p>
<h2 id="an-zhuang-ubuntuxu-ni-ji">安装ubuntu虚拟机</h2>
<p><strong>前期准备</strong></p>
<ul>
<li>下载 Ubuntu ISO 镜像</li>
<li>确保你的主机支持虚拟化Intel VT-x / AMD-V并在 BIOS/UEFI 中启用</li>
</ul>
<p><strong>开始安装</strong></p>
<ol>
<li>启动 VMware → 选择 “Create a New Virtual Machine” 或 “新建虚拟机”。</li>
<li>在安装来源 (Installer source) 页选择 “Installer disc image file (ISO)” → 浏览并选中你下载的 Ubuntu ISO 文件。</li>
<li>在“Guest OS Family / 来宾操作系统类型”中选择 <strong>Linux</strong></li>
<li>在 OS 版本中选择 “Ubuntu 64-bit” 或者 “Other Linux 64-bit”如果没有明确 Ubuntu 选项)。</li>
<li>给虚拟机起一个名字,例如 “Ubuntu-VM”。</li>
<li>指定存放虚拟机文件 (.vmx, .vmdk 等) 的文件夹位置。默认位置在<code>C:\Users\&lt;你的用户名&gt;\Documents\Virtual Machines\&lt;虚拟机名称&gt;\</code>下.</li>
<li>在磁盘设置部分设置虚拟磁盘大小,推荐 <strong>25-40 GB</strong>。选择把虚拟磁盘存为一个文件或拆分为多个文件,这两种方式各有优劣(一个文件通常略快些)。</li>
<li>自定义硬件设置</li>
</ol>
<table><thead><tr><th>硬件</th><th>推荐配置 / 注意事项</th></tr></thead><tbody>
<tr><td>CPU 核心数</td><td>2 或更多</td></tr>
<tr><td>内存</td><td>至少 4 GB若要流畅用 GNOME 桌面建议 8 GB</td></tr>
<tr><td>显示适配</td><td>开启 3D 加速(如果 VMware 支持)</td></tr>
<tr><td>硬盘控制器类型</td><td>通常 VMware 默认就行SATA/SCSI一般 Ubuntu 支持都不错</td></tr>
<tr><td>网卡</td><td>使用 NAT 或桥接,根据是否要虚拟机直接在局域网中可访问来定</td></tr>
</tbody></table>
<ol start="9">
<li>启动虚拟机并选择“Install Ubuntu”。</li>
<li>安装 VMware Tools 或 Open-VM-Tools</li>
</ol>
<p>安装这些工具能增强体验,例如鼠标整合、屏幕分辨率自动调整、剪贴板共享等等。</p>
<p>Ubuntu 的方式通常是用 <code>open-vm-tools</code> 包:</p>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">sudo</span><span> apt update
</span><span style="color:#ffb964;">sudo</span><span> apt install open-vm-tools-desktop
</span><span style="color:#ffb964;">sudo</span><span> reboot
</span></code></pre>
<h3 id="faq">FAQ</h3>
<ul>
<li>屏幕分辨率不能拉大/全屏:安装 open-vm-tools + open-vm-tools-desktop开启 3D 支持;在虚拟机设置里提升视频内存。</li>
<li>虚拟机启动慢:给虚拟机分配更多 RAMCPU关闭不必要的服务确保主机虚拟化支持开启。</li>
<li>无法挂载 ISO 或虚拟光驱:检查虚拟机设置里 CD/DVD 光驱是否连接ISO 文件是否损坏。</li>
<li>时间不对同步差:安装 VMware 工具通常能解决时间同步;也可手动配置 NTP 服务。</li>
<li>网络不通:检查虚拟机网卡类型;如果用 NAT看主机网络如果用桥接看是否有权限或防火墙问题。</li>
</ul>
<h1 id="er-hyper-v">二.Hyper-V</h1>
<p>Hyper-V 是微软内建的虚拟化平台native hypervisor。开启后它会占用硬件虚拟化特性Intel VT-x / AMD-V这可能会和 VMware、VirtualBox 等第三方虚拟化软件冲突。</p>
<h2 id="kai-qi-hyper-v">开启 Hyper-V</h2>
<ul>
<li>PowerShell以管理员权限运行</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
</span></code></pre>
<ul>
<li>DISM部署映像服务和管理工具</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V
</span></code></pre>
<ul>
<li>Windows 功能 GUI 操作:
<code>控制面板 → 程序和功能 → 启用或关闭 Windows 功能</code>中勾选 “Hyper-V”、 “Hyper-V 平台”、 “Hyper-V 管理工具” 等相关项目,然后按提示操作。</li>
</ul>
<h2 id="guan-bi-hyper-v">关闭 Hyper-V</h2>
<ul>
<li>PowerShell管理员权限</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
</span></code></pre>
<ul>
<li>DISM</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>DISM /Online /Disable-Feature:Microsoft-Hyper-V
</span></code></pre>
<ul>
<li>用 bcdedit 修改启动配置,使系统启动时不加载 HypervisorHyper-V 的虚拟化内核)但保留功能安装:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>bcdedit /set hypervisorlaunchtype off
</span></code></pre>
<p>若要恢复加载,则:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>bcdedit /set hypervisorlaunchtype auto
</span></code></pre>
<ul>
<li>Windows 功能 GUI 中,取消勾选 Hyper-V 相应项。</li>
</ul>
<h2 id="shi-yong-fang-fa">使用方法</h2>
<p>下面是几个典型的场景和命令:</p>
<ol>
<li><strong>给 VMware 或 VirtualBox 使用环境临时关闭 Hyper-V</strong></li>
</ol>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>bcdedit /set hypervisorlaunchtype off
</span></code></pre>
<p>然后重启 Windows就能让这些软件正常启动虚拟机。要还原 Hyper-V改为 <code>auto</code><code>on</code>:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>bcdedit /set hypervisorlaunchtype auto
</span></code></pre>
<ol start="2">
<li><strong>从命令行完全关闭 Hyper-V 功能</strong></li>
</ol>
<pre data-lang="powershell" style="background-color:#151515;color:#e8e8d3;" class="language-powershell "><code class="language-powershell" data-lang="powershell"><span>Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
</span></code></pre>
<p>或者用 DISM</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>DISM /Online /Disable-Feature:Microsoft-Hyper-V
</span></code></pre>
<ol start="3">
<li><strong>检查当前 Hyper-V 是否正在运行</strong></li>
</ol>
<ul>
<li><code>msinfo32.exe</code>(系统信息)看 “Hyper-V Requirements” 部分或者在命令提示符PowerShell 用 <code>systeminfo</code> 查看是否显示 “Hypervisor has been detected” 之类信息。</li>
</ul>
<ol start="4">
<li><strong>用 GUI 控制 Windows 功能开关</strong></li>
</ol>
<ul>
<li>打开 <code>控制面板 → 程序 → 启用或关闭 Windows 功能</code></li>
<li>勾选 “Hyper-V” 及 Hyper-V 平台 / 虚拟机平台等</li>
<li>点击确定,重启即可。</li>
</ul>
<h2 id="faq-1">FAQ</h2>
<ul>
<li>Windows 家庭版Home通常不提供完整的 Hyper-V 功能 GUI但系统中某些虚拟化基于安全的功能例如 VBS、Core Isolation / Memory Integrity依然可能启用这样也会表现为“Hyper-V 在运行”,建议更换到专业工作站版本。</li>
<li>部分软件(如 Android 模拟器、BlueStacks 等)在检测到 Hyper-V 存在时性能可能受影响关闭后可能解决问题。比如Steam游戏安卓模拟器HCL等等。</li>
</ul>
<h1 id="san-qemu">三.QEMU</h1>
<h2 id="bei-fen">备份</h2>
<p>QEMU安装的系统默认在此位置下可以使用Root用户将其复制到其他位置并备份</p>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">[root@dos:/var/lib/libvirt/images]ls
</span><span style="color:#ffb964;">ubuntu24.04-2.qcow2
</span></code></pre>
<h2 id="ge-shi-zhuan-huan">格式转换</h2>
<p>QEMU默认使用qcow2格式几乎可以转换为所有其他虚拟机格式我们可以使用<code>qemu-img</code>QEMU 提供的镜像管理工具)来创建、转换、检查、调整虚拟机磁盘镜像。</p>
<p><strong>基本语法</strong></p>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">qemu-img </span><span style="color:#8fbfdc;">[</span><span>command</span><span style="color:#8fbfdc;">] [</span><span>options</span><span style="color:#8fbfdc;">]</span><span> filename
</span></code></pre>
<p><strong>镜像格式转换命令大全</strong></p>
<p><code>qemu-img convert -f &lt;源格式&gt; -O &lt;目标格式&gt; &lt;源文件&gt; &lt;目标文件&gt;</code></p>
<p><strong>常见虚拟机平台格式</strong></p>
<table><thead><tr><th>平台/软件</th><th>格式</th><th>示例扩展名</th></tr></thead><tbody>
<tr><td>QEMU/KVM</td><td>qcow2</td><td><code>.qcow2</code></td></tr>
<tr><td>VirtualBox</td><td>vdi</td><td><code>.vdi</code></td></tr>
<tr><td>VMware</td><td>vmdk</td><td><code>.vmdk</code></td></tr>
<tr><td>Microsoft Hyper-V</td><td>vhd/vhdx</td><td><code>.vhd</code> / <code>.vhdx</code></td></tr>
<tr><td>Xen</td><td>raw</td><td><code>.img</code></td></tr>
</tbody></table>
<ul>
<li><code>raw ↔ qcow2</code></li>
</ul>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#888888;"># raw → qcow2
</span><span style="color:#ffb964;">qemu-img</span><span> convert</span><span style="color:#ffb964;"> -f</span><span> raw</span><span style="color:#ffb964;"> -O</span><span> qcow2 disk.img disk.qcow2
</span><span>
</span><span style="color:#888888;"># qcow2 → raw
</span><span style="color:#ffb964;">qemu-img</span><span> convert</span><span style="color:#ffb964;"> -f</span><span> qcow2</span><span style="color:#ffb964;"> -O</span><span> raw disk.qcow2 disk.img
</span></code></pre>
<ul>
<li><code>qcow2 ↔ vdi (VirtualBox)</code></li>
</ul>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#888888;"># qcow2 → vdi
</span><span style="color:#ffb964;">qemu-img</span><span> convert</span><span style="color:#ffb964;"> -f</span><span> qcow2</span><span style="color:#ffb964;"> -O</span><span> vdi disk.qcow2 disk.vdi
</span><span>
</span><span style="color:#888888;"># vdi → qcow2
</span><span style="color:#ffb964;">qemu-img</span><span> convert</span><span style="color:#ffb964;"> -f</span><span> vdi</span><span style="color:#ffb964;"> -O</span><span> qcow2 disk.vdi disk.qcow2
</span></code></pre>
<ul>
<li><code>qcow2 ↔ vmdk (VMware)</code></li>
</ul>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#888888;"># qcow2 → vmdk
</span><span style="color:#ffb964;">qemu-img</span><span> convert</span><span style="color:#ffb964;"> -f</span><span> qcow2</span><span style="color:#ffb964;"> -O</span><span> vmdk disk.qcow2 disk.vmdk
</span><span>
</span><span style="color:#888888;"># vmdk → qcow2
</span><span style="color:#ffb964;">qemu-img</span><span> convert</span><span style="color:#ffb964;"> -f</span><span> vmdk</span><span style="color:#ffb964;"> -O</span><span> qcow2 disk.vmdk disk.qcow2
</span></code></pre>
<ul>
<li><code>qcow2 ↔ vhd/vhdx (Hyper-V)</code></li>
</ul>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#888888;"># qcow2 → vhdx
</span><span style="color:#ffb964;">qemu-img</span><span> convert</span><span style="color:#ffb964;"> -f</span><span> qcow2</span><span style="color:#ffb964;"> -O</span><span> vhdx disk.qcow2 disk.vhdx
</span><span>
</span><span style="color:#888888;"># vhdx → qcow2
</span><span style="color:#ffb964;">qemu-img</span><span> convert</span><span style="color:#ffb964;"> -f</span><span> vhdx</span><span style="color:#ffb964;"> -O</span><span> qcow2 disk.vhdx disk.qcow2
</span></code></pre>
<ul>
<li><code>raw ↔ vdi/vmdk/vhdx</code></li>
</ul>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#888888;"># raw → vdi
</span><span style="color:#ffb964;">qemu-img</span><span> convert</span><span style="color:#ffb964;"> -f</span><span> raw</span><span style="color:#ffb964;"> -O</span><span> vdi disk.img disk.vdi
</span><span>
</span><span style="color:#888888;"># raw → vmdk
</span><span style="color:#ffb964;">qemu-img</span><span> convert</span><span style="color:#ffb964;"> -f</span><span> raw</span><span style="color:#ffb964;"> -O</span><span> vmdk disk.img disk.vmdk
</span><span>
</span><span style="color:#888888;"># raw → vhdx
</span><span style="color:#ffb964;">qemu-img</span><span> convert</span><span style="color:#ffb964;"> -f</span><span> raw</span><span style="color:#ffb964;"> -O</span><span> vhdx disk.img disk.vhdx
</span></code></pre>
<h2 id="kuo-zhan">扩展</h2>
<ol>
<li>扩展大小</li>
</ol>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>virsh domblklist &lt;虚拟机名字&gt;
</span><span>Target Source
</span><span>vda /var/lib/libvirt/images/ubuntu-24-04.qcow2
</span><span>
</span><span>qemu-img resize /var/lib/libvirt/images/ubuntu-24-04.qcow2 +20G
</span></code></pre>
<ol start="2">
<li>查看磁盘情况:</li>
</ol>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">lsblk
</span></code></pre>
<ol start="3">
<li>如果是单分区系统ext4</li>
</ol>
<ul>
<li>安装工具:</li>
</ul>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">sudo</span><span> nix-env</span><span style="color:#ffb964;"> -iA</span><span> nixos.cloud-utils </span><span style="color:#888888;"># 提供 growpart
</span></code></pre>
<ul>
<li>扩展分区:</li>
</ul>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">sudo</span><span> growpart /dev/vda 1
</span></code></pre>
<ul>
<li>扩展文件系统:</li>
</ul>
<p>ext4</p>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">sudo</span><span> resize2fs /dev/vda1
</span></code></pre>
<p>xfs</p>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">sudo</span><span> xfs_growfs /
</span></code></pre>
<h2 id="ya-suo">压缩</h2>
<p>有时候我们需要备份QEMU的镜像但是镜像大小非常庞大可以对其进行压缩。</p>
<p>首先在虚拟机里以Ubuntu为例执行</p>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">sudo</span><span> apt clean
</span><span style="color:#ffb964;">sudo</span><span> rm</span><span style="color:#ffb964;"> -rf</span><span> /var/log/*log /var/log/journal/* </span><span style="color:#888888;"># 清理日志
</span></code></pre>
<p>然后填充空闲空间:</p>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">sudo</span><span> dd if=/dev/zero of=/zero.fill bs=1M || </span><span style="color:#ffb964;">true
</span><span style="color:#ffb964;">sudo</span><span> sync
</span><span style="color:#ffb964;">sudo</span><span> rm</span><span style="color:#ffb964;"> -f</span><span> /zero.fill
</span></code></pre>
<p>随后关闭虚拟机,在宿主机上使用 <code>qemu-img</code> 压缩:</p>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">qemu-img</span><span> convert</span><span style="color:#ffb964;"> -O</span><span> qcow2 ubuntu24.04-2.qcow2 ubuntu24.04-2-compressed.qcow2
</span></code></pre>
<p>可选:加上 <code>-c</code> 开启压缩:</p>
<pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">qemu-img</span><span> convert</span><span style="color:#ffb964;"> -O</span><span> qcow2</span><span style="color:#ffb964;"> -c</span><span> ubuntu24.04-2.qcow2 ubuntu24.04-2-compressed.qcow2
</span></code></pre>
<blockquote>
<p><strong>不要直接删除原始文件</strong>,先确认新文件能正常启动。如果你的 qcow2 镜像是直接被写满了(比如里面确实存了很多真实数据),那即使压缩也不会小太多。如果镜像内部用了 LVM还可以在 LVM 里使用sudo fstrim -av进行fstrim.</p>
</blockquote>
<hr />
<p><strong>Done.</strong></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/network-docker/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">网络艺术:Docker建站与反向代理</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-2024/">
<span class="button__text">乱七八糟:2024年度总结</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

150
public/about/index.html Normal file
View File

@@ -0,0 +1,150 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/about/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/about/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li class="active"><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/about/">About Me</a></h1>
<div class="post-meta-inline">
<span class="post-date"></span>
</div>
<div class="post-content">
<h2 id="welcome-to-dich-blog">Welcome to dich' Blog!</h2>
<p>用电子罗盘,转赛博核桃,勘电磁风水,寻网络龙脉</p>
<blockquote>
<p>一个人应该能够给孩子换尿布、计划一次侵略行动、杀猪、驾驶飞船、设计建筑物、写诗、做会计账目、砌墙、接合断骨、照顾临终的人、执行命令、下达命令、与人合作、独立行动、解方程式、分析一个新问题、施肥、编程、做一餐美味的饭、高效地战斗、勇敢地死去。专业化是为昆虫准备的。 ——<em>罗伯特·海因莱恩</em></p>
</blockquote>
<p>有事请联系 admin@dich.bid</p>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

636
public/archive/index.html Normal file
View File

@@ -0,0 +1,636 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/archive/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/archive/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li><a href="https://blog.dich.bid">Blog</a></li>
<li class="active"><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post">
<h1 class="post-title">Archive</h1>
<ul><li class="post-list">
<a href="https://blog.dich.bid/linux-3-android-dev/">
<span class="post-date">2025-11-20</span>
:: <span class="post-list-title">Linux-Android开发环境部署</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/linux/">#Linux</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/linux-2-stm32/">
<span class="post-date">2025-07-20</span>
:: <span class="post-list-title">Linux-STM32开发环境部署</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/linux/">#Linux</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-sports/">
<span class="post-date">2025-07-05</span>
:: <span class="post-list-title">乱七八糟:运动健身基本理论</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-gpg/">
<span class="post-date">2025-06-17</span>
:: <span class="post-list-title">乱七八糟:GPG使用小记</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/network-ssh/">
<span class="post-date">2025-05-02</span>
:: <span class="post-list-title">网络艺术:SSH使用指南</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/network/">#Network</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-baci/">
<span class="post-date">2025-04-23</span>
:: <span class="post-list-title">乱七八糟:Baci实验笔记</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-lazyvim/">
<span class="post-date">2025-04-20</span>
:: <span class="post-list-title">乱七八糟:lazyvim快速上手</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/network-aria2/">
<span class="post-date">2025-04-15</span>
:: <span class="post-list-title">下载系列(3):Aria2使用指南</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/network/">#Network</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/network-yt-dlp/">
<span class="post-date">2025-04-12</span>
:: <span class="post-list-title">下载系列(2):Yt-dlp使用指南</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/network/">#Network</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/network-download-1/">
<span class="post-date">2025-04-11</span>
:: <span class="post-list-title">下载系列(1):下载技术的历史</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/network/">#Network</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-markdown/">
<span class="post-date">2025-04-08</span>
:: <span class="post-list-title">乱七八糟:Markdown使用快速教程</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-gfs/">
<span class="post-date">2025-03-18</span>
:: <span class="post-list-title">乱七八糟:GFS项目考量笔记</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/network-frp/">
<span class="post-date">2025-03-01</span>
:: <span class="post-list-title">网络艺术:FRP使用指南</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/network/">#Network</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-ventoy/">
<span class="post-date">2025-02-14</span>
:: <span class="post-list-title">乱七八糟:Ventoy战斗盘部署</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/network-homenet-2/">
<span class="post-date">2025-01-22</span>
:: <span class="post-list-title">家庭组网系列(2):路由器性能测试</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/network/">#Network</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/network-homenet-1/">
<span class="post-date">2025-01-21</span>
:: <span class="post-list-title">家庭组网系列(1):方案与设备选购</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/network/">#Network</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-2024/">
<span class="post-date">2025-01-04</span>
:: <span class="post-list-title">乱七八糟:2024年度总结</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-virtual/">
<span class="post-date">2024-08-16</span>
:: <span class="post-list-title">乱七八糟:虚拟化常用设置与操作</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/network-docker/">
<span class="post-date">2024-07-14</span>
:: <span class="post-list-title">网络艺术:Docker建站与反向代理</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/network/">#Network</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-server-set/">
<span class="post-date">2024-06-12</span>
:: <span class="post-list-title">乱七八糟:服务器初始化与安全设置</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-cslearning/">
<span class="post-date">2024-05-31</span>
:: <span class="post-list-title">乱七八糟:计算机科学优质视频</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/windows-5-py/">
<span class="post-date">2024-05-31</span>
:: <span class="post-list-title">Windows系列(5):Python开发配置</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/windows/">#Windows</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/windows-6-c/">
<span class="post-date">2024-05-30</span>
:: <span class="post-list-title">Windows系列(6):C&#x2F;C++开发配置</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/windows/">#Windows</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/windows-4-auto/">
<span class="post-date">2024-05-29</span>
:: <span class="post-list-title">Windows系列(4):封装与全自动安装</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/windows/">#Windows</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/windows-3-jh/">
<span class="post-date">2024-05-26</span>
:: <span class="post-list-title">Windows系列(3):分类与激活</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/windows/">#Windows</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/windows-2-set/">
<span class="post-date">2024-05-25</span>
:: <span class="post-list-title">Windows系列(2):常用操作与配置</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/windows/">#Windows</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/windows-1-install/">
<span class="post-date">2024-05-24</span>
:: <span class="post-list-title">Windows系列(1):系统安装与设置</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/windows/">#Windows</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-shortcut-key/">
<span class="post-date">2024-05-23</span>
:: <span class="post-list-title">乱七八糟:常用实用快捷键</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-podcast-use/">
<span class="post-date">2024-03-06</span>
:: <span class="post-list-title">乱七八糟:播客收听指北</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-rss-read/">
<span class="post-date">2024-03-05</span>
:: <span class="post-list-title">乱七八糟:RSS阅读指南</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-opensource/">
<span class="post-date">2024-03-03</span>
:: <span class="post-list-title">乱七八糟:开源软件与协议</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/network-how-email-works-2/">
<span class="post-date">2024-02-22</span>
:: <span class="post-list-title">网络艺术:自建域名邮箱</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/network/">#Network</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/network-how-email-works-1/">
<span class="post-date">2024-02-20</span>
:: <span class="post-list-title">网络艺术:电子邮件的工作原理</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/network/">#Network</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/network-cdn/">
<span class="post-date">2024-02-16</span>
:: <span class="post-list-title">网络艺术:CDN技术与应用</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/network/">#Network</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/network-ssl/">
<span class="post-date">2024-02-15</span>
:: <span class="post-list-title">网络艺术:SSL&#x2F;TLS证书</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/network/">#Network</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/network-isps/">
<span class="post-date">2024-02-10</span>
:: <span class="post-list-title">网络艺术:国内&#x2F;国际骨干ISP线路整理</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/network/">#Network</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-git/">
<span class="post-date">2023-12-15</span>
:: <span class="post-list-title">乱七八糟:Git使用简明手册</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-junk-cleanup/">
<span class="post-date">2023-11-19</span>
:: <span class="post-list-title">乱七八糟:垃圾清理的艺术</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-blog/">
<span class="post-date">2023-10-12</span>
:: <span class="post-list-title">乱七八糟:个人博客搭建</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-mechrev-keyboard/">
<span class="post-date">2023-09-04</span>
:: <span class="post-list-title">乱七八糟:机械革命键盘失灵拯救记</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-accurate-pronunciation/">
<span class="post-date">2023-08-25</span>
:: <span class="post-list-title">乱七八糟:常见发音错误术语集合</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/about-calling-cards/">
<span class="post-date">2023-08-24</span>
:: <span class="post-list-title">乱七八糟:流量卡购买与套路</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/awesome-arch-linux/">
<span class="post-date">2023-08-16</span>
:: <span class="post-list-title">综合工程:Arch-linux 安装与配置</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/zong-he-gong-cheng/">#综合工程</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/awesome-android-tv/">
<span class="post-date">2023-08-14</span>
:: <span class="post-list-title">综合工程:Android-TV 折腾小记</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/zong-he-gong-cheng/">#综合工程</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/awesome-android-root/">
<span class="post-date">2023-08-13</span>
:: <span class="post-list-title">综合工程:安卓刷机与root教程</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/zong-he-gong-cheng/">#综合工程</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/awesome-openwrt/">
<span class="post-date">2023-08-12</span>
:: <span class="post-list-title">综合工程:OpenWrt路由部署与软件编译</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/zong-he-gong-cheng/">#综合工程</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/awesome-pve-mcsm/">
<span class="post-date">2023-08-11</span>
:: <span class="post-list-title">综合工程:PVE安装与MC服务器搭建</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/zong-he-gong-cheng/">#综合工程</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/awesome-vm-android/">
<span class="post-date">2023-08-10</span>
:: <span class="post-list-title">综合工程:linux搭建安卓虚拟机</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/zong-he-gong-cheng/">#综合工程</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/linux-1-command/">
<span class="post-date">2023-07-20</span>
:: <span class="post-list-title">Linux-命令行操控</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/linux/">#Linux</a></span>
</li>
<li class="post-list">
<a href="https://blog.dich.bid/linux-0-start/">
<span class="post-date">2023-06-20</span>
:: <span class="post-list-title">Linux-优雅过渡</span></a>
<span class="post-tags-inline">
::
<a class="post-tag" href="https://blog.dich.bid/tags/linux/">#Linux</a></span>
</li>
</ul>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

1361
public/atom.xml Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,470 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/awesome-android-root/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/awesome-android-root/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li class="active"><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/awesome-android-root/">综合工程:安卓刷机与root教程</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2023-08-13
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/zong-he-gong-cheng/">#综合工程</a></span>
<div class="post-content">
<p>前言 自安卓系统诞生以来root 一直是玩机的必备过程。时至今日,在安卓定制系统日益完善的情况下,能 root 的机型越来越少,本文以小米手机为例,介绍 root 的具体方法。</p>
<span id="continue-reading"></span><h2 id="yi-shen-me-shi-root"><strong>一.什么是root</strong></h2>
<p>这涉及安卓的权限系统。Andoird 系统是基于 Linux 内核的Linux中的root用户为超级用户<code>root 权限则为系统的最高权限</code>,与 Windows 的 system 权限相当(比 administer 还高。日常使用中我们可以发现一般软件权限需要经过用户同意即每次安装前出现的各种请求弹窗。我们看似可以做到许多事情但有些地方比如安卓的根目录没有root就无法查看。</p>
<p>所谓 Root 也就是使手机获得超级管理员的权限,但是出于种种原因,厂商默认不提供超级管理员的权限,因此,<code>root的本质就是一个提权的过程</code></p>
<h2 id="er-wei-shen-me-yao-root"><strong>二.为什么要root</strong></h2>
<ol>
<li>
<p>国内定制的安卓系统充满着云控,反诈以及各种广告,预装软件,这种系统实在为极客们所不容;而当我们具备了 root 权限后,就可以实现许多功能,例如屏蔽广告,虚拟定位,安装 Google 框架和软件满血运行CPU删除系统自带软件等等。</p>
</li>
<li>
<p>某种意义上不能root的手机相当于只有使用权而无所有权不能完全控制自己的数据。</p>
</li>
<li>
<p>我可以不要但你厂商不能不给。</p>
</li>
</ol>
<blockquote>
<p>云控一般指为了计划性报废而特地远程操控使用户的手机变的卡顿加快换机也有另一层含义在UP主测试手机时调整设置使其跑分虚高而用户到手的手机分数远不如测试的时候的情况。</p>
</blockquote>
<blockquote>
<p>反诈:一般指厂商与网络安全部门合作的后门或漏洞,可以监控用户行为,例如某
“其他”品牌手机系统的webview级别的网址拦截</p>
</blockquote>
<blockquote>
<p>广告:一般指系统自带的弹窗广告,自带系统应用中的广告和“负一屏”中的广告。</p>
</blockquote>
<h2 id="san-na-xie-ji-xing-ke-yi-root"><strong>三.哪些机型可以root</strong></h2>
<p>在 2023 年的今天,能 root 的机型还是比较少。<a href="https://github.com/KHwang9883/MobileModels/blob/master/misc/bootloader-kernel-source.md">各品牌手机root情况汇总</a></p>
<table><thead><tr><th>品牌 / 机型</th><th>BL 解锁情况</th><th>等待时长</th><th>支持回锁</th><th>Root/越狱 能力</th></tr></thead><tbody>
<tr><td>OnePlus</td><td>✅ 支持</td><td>秒解</td><td>✅ 支持</td><td>✅ 容易 root</td></tr>
<tr><td>Google (Pixel)</td><td>✅ 支持</td><td>秒解</td><td>✅ 支持</td><td>✅ 容易 root</td></tr>
<tr><td>Nothing Phone</td><td> 社区支持</td><td></td><td></td><td>✅ 社区方法多</td></tr>
<tr><td>Motorola</td><td>✅ 支持</td><td>官方发解锁码</td><td>⚠️ 部分</td><td>✅ 社区方法多</td></tr>
<tr><td>Xiaomi/Redmi/POCO</td><td>⚠️ 支持</td><td>~714 天</td><td>⏹ 部分</td><td>✅ 可 root需等待</td></tr>
<tr><td>Lenovo</td><td>✅ 支持</td><td>秒解</td><td>⚠️ 部分</td><td>✅ 容易 root</td></tr>
<tr><td>Sony</td><td>⚠️ 支持</td><td></td><td>⚠️ 部分</td><td>✅ 海外版易 root</td></tr>
<tr><td>OPPO / Realme</td><td>⚠️ 支持</td><td></td><td></td><td>❌ 部分型号难 root</td></tr>
<tr><td>Vivo / iQOO</td><td>⚠️ 支持</td><td></td><td></td><td>❌ 部分型号难 root</td></tr>
<tr><td>Huawei</td><td>❌ 不支持</td><td></td><td></td><td>❌ 基本不可 root</td></tr>
<tr><td>Honor</td><td>❌ 不支持</td><td></td><td></td><td>⚠️ 少数型号有社区支持</td></tr>
<tr><td>ASUS</td><td>❌ 不支持</td><td></td><td></td><td>❌ 不可 root</td></tr>
<tr><td>Black Shark</td><td>❌ 不支持</td><td></td><td></td><td>❌ 不可 root</td></tr>
<tr><td>LG</td><td>❌ 不支持</td><td></td><td>✅ 支持</td><td>⚠️ 旧机型可能可 root</td></tr>
<tr><td>Meizu</td><td>❌ 不支持</td><td></td><td></td><td>⚠️ 部分机型有 root 方法</td></tr>
<tr><td>Samsung</td><td>⚠️ 支持</td><td></td><td></td><td>❌ 解锁后 Knox 熔断Pay 功能被禁用</td></tr>
<tr><td>Apple iPhone</td><td>❌ 不支持</td><td></td><td></td><td>✅ iPhone 10 前可越狱</td></tr>
</tbody></table>
<p><code>刷机有风险root 需谨慎</code>!刷机前要了解相应的厂商,考虑保修和变砖的问题!</p>
<h2 id="si-que-ding-ni-yao-shua-de-xi-tong"><strong>四.确定你要刷的系统</strong></h2>
<p>可以选择<code>官方原版,官改版,海外版和类原生版</code>。官方原版镜像一般用来救砖;官改版在一些方面例如性能更为强大;海外版本如EEA欧盟版为符合法规对隐私保护更好且广告更少而类原生版是在AOSP的基础上进行简单修改最为纯净原生。</p>
<p>需要注意这些rom的搜索往往使用的海外名得先搜索你所对应机型的海外名称/代号。</p>
<ul>
<li>
<p><a href="https://mi.fiime.cn/Android">Android原生项目大全</a></p>
</li>
<li>
<p><a href="https://miuiver.com/">小米各机型 MIUI 历史版本分类索引</a></p>
</li>
</ul>
<blockquote>
<p>需要注意的是刷类原生系统较之其他系统可能会有如下问题如果你只需要root推荐使用原厂系统。</p>
</blockquote>
<ul>
<li>解锁BL之后Tee假死无法使用指纹付款</li>
<li>由于原厂相机驱动不开源,相机变的模糊;</li>
<li>部分机型无法快充;</li>
<li>12306无法使用前置人脸识别</li>
<li>5G可能无法使用</li>
</ul>
<h2 id="wu-ru-he-root"><strong>五.如何root</strong></h2>
<p>首先我们要了解安卓系统的分区和启动。安卓的分区包括:</p>
<ul>
<li>
<p><code>recovery 分区</code>类似PC端的PE环境手机上的恢复出厂设置即为从 recovery 恢复;</p>
</li>
<li>
<p><code>cache 分区</code>,保存系统最常访问的数据和应用程序。 擦除这个分区,不会影响个人数据,只是删除了这个分区中已经保存的缓存内容;</p>
</li>
<li>
<p><code>boot 分区</code>类似PC端的MBR分区用来引导系统启动擦除后手机会卡在开机 logo 的界面;</p>
</li>
<li>
<p><code>system 分区</code>包括操作系统与软件vendor 定制文件与库文件等等,擦除后会卡在开机的动画界面;</p>
</li>
<li>
<p><code>data 分区</code>,存放用户数据和系统设置,擦除后不影响系统的运行。</p>
</li>
</ul>
<blockquote>
<p>除了以上5大分区外手机启动阶段还存在名为 bootloader 的程序通常位于设备的专用引导区域如boot ROM或firmware分区的一部分与 PC 端的 BIOS 类似,被称为 fastboot 模式,厂商一般会将其锁定,要刷机的话必须解开它。</p>
</blockquote>
<blockquote>
<p>早些年间,存在大量一键 rootkingroot 之类的软件,可以直接刷写 root 包,获得 root 权限,但成功率不高,且有植入木马之嫌。</p>
</blockquote>
<p>因此,现在<strong>主流的刷机步骤</strong></p>
<ul>
<li>
<p><code>备份手机数据</code>,即备份Data分区(可使用Neobackup或系统自带),字库/基带/官方固件,桌面样式截图以及该机器的官方原厂包;</p>
</li>
<li>
<p>打开机器上的<code>允许USB调试</code>;</p>
</li>
<li>
<p><code>解开 bootloader</code>俗称解BL锁. <a href="https://telegra.ph/BL%E9%94%81%E7%9A%84%E5%8E%9F%E7%90%86%E6%98%AF%E4%BB%80%E4%B9%88-05-29">BL锁原理参考</a></p>
</li>
<li>
<p>下载要刷的第三方系统包和原厂系统包并提取以上两个包中的 boot.img 和 recovery.img 文件;</p>
</li>
<li>
<p>将机器与PC等设备连接,并<code>进入 bootloader</code>;</p>
</li>
<li>
<p><code>刷入第三方 recovery</code>,比如大名鼎鼎的 TWRP,或者对应新系统的recovery.img</p>
</li>
<li>
<p>进入 recovery 模式清空原系统数据并刷入新系统Zip包,随后重启,即可进入新系统。</p>
</li>
</ul>
<p><strong>主流的root步骤</strong>:</p>
<ul>
<li>Magisk:在recovery中<code>刷入 Magisk </code>(面具)zip包随后重启进入桌面,安装 Magisk(apk),在其中选择直接安装;</li>
<li>Apatch:安装apk软件并修补提取出来的boot.img,随后在fastboot模式中<code>fastboot flash boot apatch_patched-boot.img</code>,重启即可。</li>
<li>KernelSU:修补init_boot.img或者刷入GKI内核修补若官方无支持需要自行编译GKI内核。</li>
</ul>
<p><strong>常用root方案</strong></p>
<ul>
<li><a href="https://jesse205.github.io/MagiskChineseDocument/">Magisk</a></li>
<li><a href="https://jesse205.github.io/MagiskChineseDocument/delta/main.html">Kitsune Mask</a></li>
<li><a href="https://kernelsu.org/zh_CN/">KernelSU</a></li>
<li><a href="https://rifsxd.github.io/KernelSU-Next/zh/index.html">KernelSU Next</a></li>
<li><a href="https://apatch.dev/zh_CN/">APatch</a></li>
</ul>
<h2 id="liu-qian-zhi-zhi-shi"><strong>六.前置知识</strong></h2>
<h3 id="adb-ming-ling"><strong>adb 命令</strong></h3>
<table><thead><tr><th>命令</th><th>说明</th></tr></thead><tbody>
<tr><td><code>adb devices</code></td><td>列出 adb 设备</td></tr>
<tr><td><code>adb reboot</code></td><td>重启设备</td></tr>
<tr><td><code>adb reboot bootloader</code></td><td>重启到 fastboot 模式</td></tr>
<tr><td><code>adb reboot recovery</code></td><td>重启到 recovery 模式</td></tr>
<tr><td><code>adb reboot edl</code></td><td>重启到 edl 模式</td></tr>
<tr><td><code>adb sideload &lt;要刷写的文件路径&gt;</code></td><td>刷写模块,如 Magisk</td></tr>
</tbody></table>
<p><strong>使用adb备份分区</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>adb shell ls -l /dev/block/bootdevice/by-name
</span></code></pre>
<p>可以看到有很多分区,例如这些</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>...
</span><span>lrwxrwxrwx 1 root root 15 1970-12-24 11:30 frp -&gt; /dev/block/sda5
</span><span>lrwxrwxrwx 1 root root 16 1970-12-24 11:30 fsc -&gt; /dev/block/sdf13
</span><span>lrwxrwxrwx 1 root root 16 1970-12-24 11:30 fsg -&gt; /dev/block/sdf12
</span><span>lrwxrwxrwx 1 root root 15 1970-12-24 11:30 hyp_a -&gt; /dev/block/sde5
</span><span>lrwxrwxrwx 1 root root 16 1970-12-24 11:30 hyp_b -&gt; /dev/block/sde40
</span><span>...
</span></code></pre>
<p>随后使用root备份分区到手机上</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>adb root
</span><span>
</span><span>adb shell &quot;dd if=/dev/block/sda2 of=/sdcard/partition_backup/persist.img&quot;
</span></code></pre>
<p>然后可以上传到PC端</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>adb pull /sdcard/partition_backup/ ./backup/
</span></code></pre>
<h3 id="fastboot-ming-ling"><strong>fastboot 命令</strong></h3>
<table><thead><tr><th>命令</th><th>说明</th></tr></thead><tbody>
<tr><td><code>fastboot devices</code></td><td>列出 fastboot 设备</td></tr>
<tr><td><code>fastboot reboot</code></td><td>重启设备</td></tr>
<tr><td><code>fastboot reboot-bootloader</code></td><td>重启到 fastboot 模式</td></tr>
<tr><td><code>fastboot flash &lt;分区名称&gt; &lt;镜像文件名&gt;</code></td><td>刷写分区</td></tr>
<tr><td><code>fastboot oem reboot-&lt;模式名称&gt;</code></td><td>重启到相应模式</td></tr>
<tr><td><code>fastboot oem device-info</code></td><td>查看解锁状态</td></tr>
</tbody></table>
<h2 id="qi-ju-ti-cao-zuo-liu-cheng"><strong>七.具体操作流程</strong></h2>
<blockquote>
<p>以 Poco F2 这款手机为例,</p>
</blockquote>
<ol>
<li>
<p>首先我们进入手机设置界面,进入“我的设备”,在“全部参数”中找到“ MIUI 版本”,连续点击后开启开发者模式,随后在“更多设置”中开启 USB 调试, USB安装 功能。</p>
</li>
<li>
<p>然后我们进入<a href="https://www.miui.com/unlock/download.html">小米官网</a> 下载官方解锁工具需要登陆小米账号并等待7天随后即可解锁。</p>
</li>
<li>
<p>解锁完成后在<a href="https://mifirm.net/downloadtwrp/148">MiFirm网</a> 中下载对应的 TWRP 版本。</p>
</li>
<li>
<p>随后用数据线连接手机,用其中的一键刷写刷入 TWRP随后下载你要刷的系统的 rom 包,下载时注意一并下载 boot.img 文件,作为 Magisk 的修补用。然后下载 <a href="https://magisk.me/zip/">Magisk</a> 包,与 rom 一起存入TF卡或者U盘中。</p>
</li>
</ol>
<blockquote>
<p>注意,由于本机型为新型<a href="https://www.jianshu.com/p/b2726b304801"><strong>AB分区</strong></a>因此如果刷机失败需要下载原厂包用以恢复AB分区否则无法启动和安装rom。</p>
</blockquote>
<ol start="5">
<li>
<p>进入 recovery 模式,首先我们<code>清除Data、Cache两个分区</code>,俗称“双清”,随后在高级清除选项中<code>清除 Data、Cache、Dalvik Cache 和 System 分区</code>,俗称“四清”。</p>
</li>
<li>
<p>清除完成后即可开始刷机。将 TF 卡或者U盘插入手机在“安装”中选择 rom 包,右滑确认刷机;随后如法炮制,刷入 magisk.zip 包,不然会卡在开机 logo 界面,俗称“卡米”。</p>
</li>
<li>
<p>刷完之后重启,则会进入安装界面。<strong>注意:如果刷的是海外版的包,千万不能联网安装,否则会失败且变为国内版。</strong></p>
</li>
<li>
<p>此刻我们将下载好的 boot.img 文件复制到手机上,打开 Magisk 软件,在其中选择修补一个文件,选中 boot.img修复完成后可以看到超级用户一栏可以使用了说明 root 完成。</p>
</li>
</ol>
<blockquote>
<p>以一加oneplus为例</p>
</blockquote>
<ol>
<li>
<p>打开开发者模式并开启USB调试连接到提前装好ADB/Fastboot驱动的电脑</p>
</li>
<li>
<p>随后进入fastboot模式adb reboot bootloader执行<code>fastboot oem unlock</code>或者<code>fastboot flashing unlock</code>,查看<code>fastboot oem device-info</code>,若为<code>Device unlocked: true</code>表示已成功解锁。</p>
</li>
<li>
<p>随后刷入新系统的recovery.img,使用命令<code>fastboot flash recovery xxx.img</code>;四清操作可以用<code>fastboot erase data / fastboot erase cache / fastboot erase system / fastboot erase metadata</code> 代替。</p>
</li>
<li>
<p>随后进入新系统的recovery使用命令<code>fastboot reboot recovery</code>,在其中<code>adb sideload xxx.zip</code>,即为刷入新系统的全量包。</p>
</li>
<li>
<p>随后 <code>adb reboot</code> 即可进入新系统。</p>
</li>
</ol>
<blockquote>
<p>如果你不想安装TWRP也可以直接安装要刷的系统的recovery一般放在系统zip包的中如果没有则需要手动解包payload.bin可以安装payload-dumper-go并在解压出来的系统文件夹中使用<code>payload-dumper-go payload.bin</code>,随后会将所有.img后缀的文件放在文件夹中。</p>
</blockquote>
<h2 id="ba-roothou-de-mo-kuai-an-zhuang"><strong>八.Root后的模块安装</strong></h2>
<p>在 Root 管理器中安装 Zygisk-Lsposed 模块,即可使用 Lsposed在 Lsposed 中可以安装 HMA, Amarok QAuxiliary 模块,并配合 MMRL 等软件等等。</p>
<blockquote>
<p>免 Root 的平替方法,目前这一套流程也很成熟了:利用 ADB 权限的 Shizuku;利用 Device Owner 权限的 Dhizuku等等。</p>
</blockquote>
<blockquote>
<p>常用模块</p>
</blockquote>
<ul>
<li><a href="https://github.com/mywalkb/LSPosed_mod">LSPosed</a></li>
<li><a href="https://github.com/MhmRdd/NoHello">NoHello</a></li>
<li><a href="https://github.com/thelordalex/WAHideBootloader">WAHideBootloader</a></li>
<li><a href="https://github.com/Dr-TSNG/ZygiskNext">ZygiskNext</a></li>
<li><a href="https://github.com/snake-4/Zygisk-Assistant">Zygisk-Assistant</a></li>
</ul>
<h2 id="fu-lu"><strong>附录</strong></h2>
<h3 id="xi-tong-bian-qian-biao">系统变迁表</h3>
<table><thead><tr><th>厂商</th><th>系统 / 子品牌</th><th>演变历史及时间点</th></tr></thead><tbody>
<tr><td><strong>Xiaomi</strong></td><td>MIUI → 澎湃OSHyperOS / Surge OS</td><td>2010 年推出 MIUI2023 年 10 月 17 日官方宣布替代 MIUI 的 HyperOS中文名“澎湃OS”2023 年 10 月 26 日随 Xiaomi 14 系列一起发布2024 年起全面替代 MIUI</td></tr>
<tr><td><strong>Huawei</strong></td><td>EMUI → HarmonyOS</td><td>2012 年采用 EMUI2021 年宣布推出基于微内核的鸿蒙 HarmonyOS新机逐步切换。</td></tr>
<tr><td><strong>OPPO</strong></td><td>ColorOS</td><td>2013 年推出 ColorOS2020 年对版本号体系调整至与 Android 主版本同步(例如从 7 跳到 11之后持续 UI 与功能迭代。</td></tr>
<tr><td><strong>Realme</strong></td><td>Realme UI</td><td>2019 年从 ColorOS 分支出 Realme UI此后持续独立更新、优化未查到主要时间节点</td></tr>
<tr><td><strong>Vivo / iQOO</strong></td><td>Funtouch OS → OriginOS (+ Ocean/Pux 系列)</td><td>2012 年左右推出 Funtouch OS2020 年推出 OriginOS后续版本如 OriginOS Ocean、Pux 迭代 UI 核心。</td></tr>
<tr><td><strong>OnePlus</strong></td><td>HydrogenOS (中国) → OxygenOS (海外) → 合并后 OPOS</td><td>2014 年中国区发布 HydrogenOS2015 年海外推 OxygenOS2021 年底与 OPPO 合并,代码库统一(国内使用 ColorOS全球继续用 OxygenOS但官方未明确推出 "OPOS" 这一新名。</td></tr>
<tr><td><strong>Samsung</strong></td><td>TouchWiz → Samsung Experience → OneUI (+ One UI Core)</td><td>2009 年推出 TouchWiz2016 年改名为 Samsung Experience2018 年重塑为 OneUI2020 年开始细化为标准与精简版 OneUI Core。</td></tr>
<tr><td><strong>Asus</strong></td><td>ZenUI</td><td>2014 年推出 ZenUI后续多年持续在视觉与功能上迭代。</td></tr>
<tr><td><strong>Motorola</strong></td><td>MotoBlur → My UX</td><td>2009 年推出 MotoBlur2020 年推出基于原生 Android 的 My UX。</td></tr>
<tr><td><strong>Sony</strong></td><td>Xperia UI</td><td>自 Xperia 系列以来Sony 一直使用 Xperia UI接近原生 Android逐步做微调。</td></tr>
</tbody></table>
<h3 id="gu-jian-bao-zhong-shi-ji-wen-jian">固件包中实际文件</h3>
<table><thead><tr><th>文件名</th><th>说明与功能</th></tr></thead><tbody>
<tr><td><strong>abl.img</strong></td><td>Android Boot Loader第二阶段引导加载器负责从 XBL 启动 Android kernel。</td></tr>
<tr><td><strong>aop.img / aop_config.img</strong></td><td>Always-On Processor负责处理低功耗任务辅助系统唤醒等操作。Config 存配置。</td></tr>
<tr><td><strong>bluetooth.img</strong></td><td>蓝牙固件,负责设备蓝牙功能的驱动与协议栈加载。</td></tr>
<tr><td><strong>boot.img / init_boot.img</strong></td><td>启动分区:包含 kernelinit_boot 从 Android 13+ 将 ramdisk 拆出)</td></tr>
<tr><td><strong>cpucp.img / cpucp_dtb.img</strong></td><td>CPU Control Processor处理内核 CPU 调度或控制器DTB 部分存设备树信息。</td></tr>
<tr><td><strong>devcfg.img</strong></td><td>Device Configuration设备硬件配置例如 I/O 设置等参数。</td></tr>
<tr><td><strong>dsp.img</strong></td><td>Digital Signal Processor 固件,处理音频等信号处理任务。</td></tr>
<tr><td><strong>dtbo.img</strong></td><td>设备树覆盖层Device Tree Blob Overlay定义硬件特定参数。</td></tr>
<tr><td><strong>engineering_cdt.img</strong></td><td>工程测试用 partition常含硬件校正或测试数据。</td></tr>
<tr><td><strong>featenabler.img</strong></td><td>Feature Enabler启用或关闭厂商定制功能或隐藏功能的标记配置区。</td></tr>
<tr><td><strong>imagefv.img</strong></td><td>Image Feature Version存储镜像版本控制或签名校验信息。</td></tr>
<tr><td><strong>hyp.img</strong></td><td>Hypervisor虚拟化层固件用于安全隔离或多系统调度。</td></tr>
<tr><td><strong>keymaster.img</strong></td><td>安全模块 Keymaster处理加密密钥、安全认证等功能。</td></tr>
<tr><td><strong>modem.img</strong></td><td>基带固件控制数据通信LTE/5G/Wi-Fi/Bluetooth等。</td></tr>
<tr><td><strong>odm.img</strong></td><td>OEM 驱动与功能,硬件相关组件:摄像头、传感器等逻辑支持层。</td></tr>
<tr><td><strong>oplus_sec.img / oplusstanvbk.img</strong></td><td>厂商定制安全配置或分区OnePlus 专用)。</td></tr>
<tr><td><strong>product.img</strong></td><td>OEM 或 carrier 定制应用和配置Android 9+ 新增分区</td></tr>
<tr><td><strong>qupfw.img</strong></td><td>Qualcomm UFS或其他闪存媒体驱动固件通常用于闪存控制器。</td></tr>
<tr><td><strong>recovery.img</strong></td><td>Recovery 启动镜像,用于刷机、恢复环境。</td></tr>
<tr><td><strong>shrm.img</strong></td><td>Secure Hardware Resource Management安全资源管理模块。</td></tr>
<tr><td><strong>splash.img</strong></td><td>启动动画或厂商 Logo 展示图片。</td></tr>
<tr><td><strong>system.img / system_ext.img / system_dlkm.img</strong></td><td>系统分区:包含 Android 框架、扩展库dlkm 存模块)</td></tr>
<tr><td><strong>tz.img</strong></td><td>TrustZone 安全环境固件QSEE / TEE</td></tr>
<tr><td><strong>uefi.img / uefisecapp.img</strong></td><td>UEFI 启动环境及安全应用层,用于兼容启动和安全验证。</td></tr>
<tr><td><strong>vbmeta.img / vbmeta_system.img / vbmeta_vendor.img</strong></td><td>Verified Boot 签名校验 metadata确保完整性安全。</td></tr>
<tr><td><strong>vendor.img / vendor_boot.img / vendor_dlkm.img</strong></td><td>厂商驱动层及扩展vendor_boot 是引导层dlkm 是模块。</td></tr>
<tr><td><strong>xbl.img / xbl_config.img / xbl_ramdump.img</strong></td><td>Qualcomm XBLeXtensible Boot Loader引导加载 ABL 等ramdump 用于调试。</td></tr>
</tbody></table>
<h2 id="can-kao"><strong>参考</strong></h2>
<ul>
<li><a href="https://download.lineageos.org/devices/lmi/builds">lineageos镜像</a></li>
<li><a href="https://wiki.lineageos.org/devices/lmi/install/variant1/">lineageos教程</a></li>
<li><a href="https://wiki.lineageos.org/devices/lmi/variant2/">机型介绍</a></li>
<li><a href="https://xdaforums.com/t/no-sound-issue-can-u-help.4479225/">XDA-没有声音的问题解决</a></li>
<li><a href="https://xdaforums.com/t/kernel-overclocked-no-gravity-2023-08-28-protonclang.4531497/">XDA-更换内核</a></li>
</ul>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/awesome-openwrt/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">综合工程:OpenWrt路由部署与软件编译</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/awesome-android-tv/">
<span class="button__text">综合工程:Android-TV 折腾小记</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,385 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/awesome-android-tv/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/awesome-android-tv/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li class="active"><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/awesome-android-tv/">综合工程:Android-TV 折腾小记</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2023-08-14
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/zong-he-gong-cheng/">#综合工程</a></span>
<div class="post-content">
<p>前言 由于 AppleTV 的高昂的售价和普通电视盒子广告的泛滥,一台开源、多功能的原生安卓电视盒子逐渐成为智能家居的必备神器。出于对 IPTV、YouTube 和家庭影院等需求,以及对一面赏心悦目电视墙的期待,这里分享 Android TV 以下简称ATV安装的一些要点。</p>
<span id="continue-reading"></span><h2 id="ling-yao-shi-xian-de-mu-biao">零.要实现的目标</h2>
<ul>
<li>实现自己的设备(X86/Arm)上安装TV系统</li>
<li>实现<strong>无开机广告和内置广告</strong></li>
<li>实现<strong>海报墙效果</strong>(矩形磁帖),或自定义安卓桌面启动器;</li>
<li>实现<strong>影视番剧观看</strong>基于TVbox/Kodi/Kazumi</li>
<li>实现<strong>国内流媒体观看</strong>包括Bilibili爱优腾等等</li>
<li>实现<strong>国外流媒体观看</strong>包括NetflixYouTubeDisney+Spotify等等</li>
<li>实现<strong>家庭影院</strong>Emby类软件自动刮削</li>
<li>实现<strong>IPTV</strong>观看,采用自抓取源或者公共源;</li>
<li>实现<strong>复古游戏</strong>游玩包括GBA/FC等等基于RetroArch/PPSSPP/Emuelec,可以连接手柄;</li>
<li>实现<strong>游戏主机串流</strong>包括PS/Xbox/Switch等等</li>
</ul>
<h2 id="yi-xuan-ze-he-gua-de-ping-tai">一.选择合适的平台</h2>
<p>X86还是Arm两者之间各有优点截止到今天各种Arm电视盒子已经非常成熟价格便宜也可以使用运营商的电视盒子进行刷机性能并不会太弱而X86平台往往价格偏贵且驱动不全解码性能和功能适配没有和电视生态联系紧密因此建议首选Arm平台.</p>
<p>本文以s905l3a盒子为示例截止目前平均价格在60rmb左右非常具有性价比。</p>
<table><thead><tr><th>项目</th><th>规格说明</th></tr></thead><tbody>
<tr><td>CPU 架构</td><td>四核 ARM Cortex-A53 (64-bit)</td></tr>
<tr><td>主频</td><td>~1.8 GHz</td></tr>
<tr><td>制程工艺</td><td>12 nm</td></tr>
<tr><td>GPU</td><td>Mali-G31 MP2约 850 MHz20.8 GFLOPS</td></tr>
<tr><td>视频解码</td><td>H.265 4Kp75 (10-bit), H.264 4Kp30</td></tr>
<tr><td>视频编码</td><td>H.264/H.265 1080p60</td></tr>
<tr><td>最大显示输出</td><td>4K @ 75fps</td></tr>
<tr><td>内存支持</td><td>支持 DDR3, DDR4-2666, LPDDR4-3200设备常见 2 GB DDR4</td></tr>
<tr><td>存储</td><td>常见 8 GB eMMC5.1</td></tr>
<tr><td>接口支持</td><td>USB2.0/3.0, HDMI 2.0b/2.1</td></tr>
<tr><td>网络支持</td><td>千兆 MAC (常见盒子为 10/100), Wi-Fi, BT4.1/5.0</td></tr>
<tr><td>发布时间/制程</td><td>Q3 202212 nm</td></tr>
</tbody></table>
<blockquote>
<p>如果预算充足也可以选择s905x3s905x4以及rk3528等等芯片的盒子。如果有旧手机也可以改装为电视盒子比如骁龙865盒子性能非常强大。</p>
</blockquote>
<h2 id="er-xuan-ze-he-gua-de-xi-tong">二.选择合适的系统</h2>
<p>无论是运营商自带的电视盒子还是各种所谓的“无广告”电视盒子往往都基于以下两种系统且要小心一些所谓的“无广告”电视盒子或者外贸盒子它们往往配置低性价比不高且还是有内置付费项目甚至有一些还会偷偷跑PCDN。因此建议买到手之后自行刷写固件。</p>
<table><thead><tr><th>特性</th><th><strong>Android-x86</strong></th><th><strong>Android TV</strong></th></tr></thead><tbody>
<tr><td><strong>目标用户</strong></td><td>面向 PC 用户,将 Android 运行在 x86/x86_64 设备上。</td><td>面向电视和机顶盒用户,优化用于遥控器或语音操作。</td></tr>
<tr><td><strong>适配设备</strong></td><td>传统 PC、笔记本、平板电脑等 x86 架构设备。</td><td>智能电视、电视盒子等 ARM 或特定芯片架构设备。</td></tr>
<tr><td><strong>界面设计</strong></td><td>和标准 Android 类似,为触摸屏和鼠标键盘优化。</td><td>专为大屏设计,使用 Leanback UI适配遥控器操作。</td></tr>
<tr><td><strong>Google 服务</strong></td><td>默认不包含 Google 服务,需要用户手动安装。</td><td>官方版本内置 Google 服务(例如 Play Store、Assistant</td></tr>
<tr><td><strong>开机启动器</strong></td><td>使用标准 Android 桌面启动器Launcher3</td><td>使用电视优化的启动器Leanback Launcher</td></tr>
<tr><td><strong>架构支持</strong></td><td>专注于 <strong>x86/x86_64</strong>,但支持 ARM 仿真(通过 Houdini</td><td>主要支持 <strong>ARM/ARM64</strong> 架构,有限支持 x86。</td></tr>
<tr><td><strong>硬件支持</strong></td><td>需要额外优化,部分硬件(如 GPU 驱动)可能无法正常工作。</td><td>深度集成硬件,默认支持电视硬件(如 HDMI CEC、音频输出</td></tr>
<tr><td><strong>应用市场</strong></td><td>默认不内置 Google Play需要手动安装 Aurora Store 等替代方案。</td><td>默认集成 Google Play 商店,提供大屏优化的应用程序。</td></tr>
<tr><td><strong>遥控器支持</strong></td><td>不适配遥控器,主要使用鼠标键盘操作。</td><td>专为遥控器优化,支持按键导航和语音输入。</td></tr>
<tr><td><strong>开源贡献</strong></td><td>由社区维护,支持各种自定义和实验功能。</td><td>由 Google 官方主导OEM 厂商提供硬件优化支持。</td></tr>
</tbody></table>
<blockquote>
<p>Android-x86 的安装类似windowsAndroid TV安装类似 Android手机通过刷分区或TWRP卡刷安装。</p>
</blockquote>
<blockquote>
<p>Tosathony 制作的 Android TV x86 是一个由社区成员制作的定制化 Android TV 版本,针对 Android TV 的大屏界面 和 遥控器操作 进行特别优化,但某些硬件(如 Wi-Fi、GPU、音频设备等的驱动可能不兼容或需要额外的配置,本文不再说明Android TV x86的安装与使用。</p>
</blockquote>
<p>刷写固件可以买一个“刷机神器”HDMI短接器和一个双公头的USB线即可使用<a href="https://androidmtk.com/download-amlogic-usb-burning-tool">usb-burning-tool</a>来进行刷机推荐使用2.2.4版本.</p>
<h2 id="san-an-zhuang-ruan-jian">三.安装软件</h2>
<p>安装软件有很多方法可以使用U盘将apk安装包拷入也可以使用localsend将apk安装包通过内网传输过去。这里介绍一种通过ADB安装软件的方法。</p>
<ul>
<li>
<p>首先我们在设置中找到“设置”&gt;“设备首选项”&gt;“关于”,然后在“构建”上点击几次以解锁<code>开发者模式</code>随后开启USB调试开关。</p>
</li>
<li>
<p>随后在设置 &gt; 设备首选项 &gt; 关于 &gt; 状态中找到并记下IP 地址然后用ADB连接上去这里使用命令<code>adb connect &lt;IP 地址&gt;:&lt;端口&gt; </code>随后在ATV端授权连接例如</p>
</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span> adb connect 192.168.1.666:9527
</span><span>
</span><span>connected to 192.168.1.666:9527
</span><span>
</span><span> adb devices
</span><span>
</span><span>xxxxxxxxx sideload
</span></code></pre>
<ul>
<li>接着使用命令<code>adb install &lt;path to android app.apk&gt;</code>将要安装的软件包上传,也可以将文件拖到命令提示符窗口上以复制其路径,回车确认。</li>
</ul>
<p><strong>一些 ADB 常用命令</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>adb reboot #将重启 Android 设备。
</span><span>
</span><span>adb reboot recovery #将设备重新启动到恢复模式。
</span><span>
</span><span>adb push &lt;local&gt; &lt;remote&gt; #将文件从您的 PC 复制到您的 Android 设备。
</span><span>
</span><span>adb shell wm density &lt;dpi&gt; #改变显示器的像素密度。
</span><span>
</span><span>adb kill server #切断 PC 和 Android TV 之间的连接。
</span></code></pre>
<p><strong>要安装的软件</strong></p>
<ul>
<li>
<p><a href="https://github.com/o0HalfLife0o/TVBoxOSC/releases/tag/20250706-1456">TVBox</a>:前猫影视,可自行添加源,包括电影电视剧等等,选择 armeabi-generic-java.apk</p>
</li>
<li>
<p><a href="https://www.ppsspp.org/download/">PPSSPP</a>:PSP模拟器支持高清修复游戏选择 APK for Android</p>
</li>
<li>
<p><a href="https://github.com/xiaye13579/BBLL">BBLL</a>:第三方开源哔哩哔哩客户端适配TV界面不需要额外VIP</p>
</li>
<li>
<p><a href="https://www.right.com.cn/FORUM/thread-8437225-1-1.html">酷9TV</a>:经典IPTV播放器功能丰富可导入IPTV源使用</p>
</li>
<li>
<p><a href="http://www.videolan.org/vlc/download-android.html">VLC</a>:老牌开源音视频播放器,支持远程和串流功能</p>
</li>
<li>
<p><a href="https://github.com/xbmc/xbmc">Kodi</a>:开源的跨平台多功能媒体播放器和数字媒体娱乐中心,非常强大</p>
</li>
<li>
<p><a href="https://github.com/truefedex/tv-bro">TV-Bro</a>:适用与安卓TV的浏览器经过了遥控器优化设计可以作为网页播放器</p>
</li>
<li>
<p><a href="https://github.com/zhanghai/MaterialFiles">MaterialFiles</a>:又名质感文件,优秀的开源文件管理器</p>
</li>
<li>
<p><a href="https://github.com/localsend/localsend">Localsend</a>:经典内网互传工具可以通过它传输apk安装包或者视频到TV上</p>
</li>
<li>
<p><a href="https://www.fenxm.com/592.html">ATV Launcher</a>:平铺风格的安卓启动器,可以形成海报墙效果</p>
</li>
</ul>
<blockquote>
<p>注意s905l3a为32位架构需要下载带armv7a的软件</p>
</blockquote>
<h2 id="si-she-zhi-atvzhuo-mian">四.设置ATV桌面</h2>
<p>安装所需的软件包后我们可以删除自带的牛马软件或者不需要的软件比如我们要安装ATV就可以删除当贝桌面。</p>
<ol>
<li>ADB连接连接到ADB成功后我们使用<code>adb shell</code>进入shell随后使用命令<code>pm list packages</code>列出所有软件包;</li>
</ol>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>pm list packages -s 列出系统软件包
</span><span>pm list packages -3 列出第三方软件包
</span></code></pre>
<ol start="2">
<li>获取包名:对于暂时无法确定包名的软件,可以先打开,再使用</li>
</ol>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>adb shell dumpsys activity activities | grep mResumedActivity
</span></code></pre>
<p>获取当前前台应用的包名,随后再禁用或者删除.</p>
<ol start="3">
<li>删除软件:可以先使用</li>
</ol>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>pm disable-user --user 0 com.dangbei1.tvlauncher
</span></code></pre>
<p>禁用软件,确认没有问题之后再用</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>pm uninstall -k --user 0 com.dangbei1.tvlauncher
</span></code></pre>
<p>删除;</p>
<ol start="4">
<li>备份软件对于想要备份的软件可以使用1和2中的方法获取软件包名然后使用例如以下命令</li>
</ol>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>adb shell pm path org.videolan.vlc
</span><span>
</span><span>package:/data/app/~~hY2Y0_PdaDlasfVwkUNcoQ==/org.videolan.vlc-WnNhCJLQUJdZYYzUxzBNBA==/base.apk
</span></code></pre>
<p>获取到安装路径随后将apk包拿走就可以</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>adb pull /data/app/~~hY2Y0_PdaDlasfVwkUNcoQ==/org.videolan.vlc-WnNhCJLQUJdZYYzUxzBNBA==/base.apk ./Downloads/
</span></code></pre>
<ol start="5">
<li>备份分区如果你想要修改当前系统的img可以用adb提取并导出</li>
</ol>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span># 确定分区对应关系
</span><span>ls -l /dev/block
</span><span>ls -l /dev/block/platform
</span><span>cat /proc/mounts
</span><span>
</span><span>
</span><span># 导出到 /sdcard/
</span><span>dd if=/dev/block/boot of=/sdcard/boot.img
</span><span>dd if=/dev/block/recovery of=/sdcard/recovery.img
</span><span>dd if=/dev/block/system of=/sdcard/system.img
</span><span>dd if=/dev/block/vendor of=/sdcard/vendor.img
</span><span>dd if=/dev/block/product of=/sdcard/product.img
</span><span>dd if=/dev/block/odm of=/sdcard/odm.img
</span><span>
</span><span># 拉去到PC
</span><span>adb pull /sdcard/boot.img
</span><span>adb pull /sdcard/recovery.img
</span><span>adb pull /sdcard/system.img
</span><span>adb pull /sdcard/vendor.img
</span><span>adb pull /sdcard/product.img
</span><span>adb pull /sdcard/odm.img
</span></code></pre>
<ol start="5">
<li>修改桌面可以进入安卓原生设置里面将默认主屏幕应用改为ATV代替掉自带的桌面,并使用</li>
</ol>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>adb shell pm disable-user --user 0 com.google.android.tvlauncher
</span><span>adb shell pm disable-user --user 0 com.google.android.tungsten.setupwraith
</span></code></pre>
<p>命令禁用原来的默认桌面。随后重启盒子即可看到海报墙效果如果ATV桌面没有开机自启动可以使用Launch on Boot工具。</p>
<p><strong>最终效果</strong></p>
<p><img src="/images/s905-atv.webp" alt="s905-atv" /></p>
<h2 id="hou-ji">后记</h2>
<ul>
<li>
<p><a href="https://github.com/googlesamples/leanback-showcase">Android TV google 官方 TV 库</a></p>
</li>
<li>
<p><a href="https://github.com/boxmate/tvframe">智能电视,电视盒子开发 SDK</a></p>
</li>
<li>
<p><a href="https://github.com/EZJasonBoy/FocusChangeAnimation">选中框切换动画,适用于电视</a></p>
</li>
<li>
<p><a href="https://github.com/FrozenFreeFall/Android-tv-widget">Android tv盒子投影仪 控件</a></p>
</li>
<li>
<p><a href="https://github.com/genius158/TVProjectUtils">TV 项目常用工具(焦点问题,适配问题等.)</a></p>
</li>
<li>
<p><a href="https://github.com/Calmact/e900v22c">e900v22c项目与讨论组文档</a></p>
</li>
</ul>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/awesome-android-root/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">综合工程:安卓刷机与root教程</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/awesome-arch-linux/">
<span class="button__text">综合工程:Arch-linux 安装与配置</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,574 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/awesome-arch-linux/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/awesome-arch-linux/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li class="active"><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/awesome-arch-linux/">综合工程:Arch-linux 安装与配置</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2023-08-16
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/zong-he-gong-cheng/">#综合工程</a></span>
<div class="post-content">
<p>前言 Arch linux是一个轻量、灵活、滚动更新的 Linux 发行版衍生了诸多优秀的桌面端linux。其官方Wiki更是被称为技术界的“武林秘籍”这里介绍其安装与使用。</p>
<span id="continue-reading"></span><h2 id="an-zhuang">安装</h2>
<p>一般而言有以下几种安装方法:</p>
<ul>
<li>原版 Arch linux 的命令行安装;</li>
<li>原版 Arch linux 的脚本安装;</li>
<li>第三方发行版的图形界面安装。</li>
</ul>
<p>前两种方法较为繁琐这里说明第三种方法常见的Arch发行版有GarudaCachyos以及EndeavourOS等等。</p>
<ul>
<li><a href="https://cachyos.org/download/">Cachyos下载</a></li>
<li><a href="https://garudalinux.org/editions">Garuda下载</a></li>
<li><a href="https://endeavouros.com/">EndeavourOS下载</a></li>
</ul>
<p>安装方法同ubuntu一样是基于Calamares的图形化界面安装。一般步骤为<code>选择语言American English--选择键盘/时区(默认/shanghai--选择分区xfs抹除全盘可选全盘加密--选择桌面环境Gnome或KDE--确认安装。</code></p>
<h2 id="an-zhuang-ruan-jian">安装软件</h2>
<p>随后安装常用开源软件(KDE环境省略file和wayland)</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span># gui
</span><span>
</span><span>paru -S floorp-bin keepassxc qemu-full virt-manager materialgram-bin legcord-bin onlyoffice-bin localsend-bin kazumi-bin foliate vlc krita qtscrcpy strawberry oculante obs-studio
</span><span>
</span><span># tui
</span><span>
</span><span>paru -S neovim yazi lazygit btop zellij termshark
</span><span>
</span><span># cli
</span><span>
</span><span>paru -S alacritty fish fastfetch tealdeer expac fish-autopair fish-pure-prompt fisher onefetch starship atuin bat fzf fd ripgrep eza tree android-tools payload-dumper-go-bin nexttrace-bin syncthing aria2
</span><span>
</span><span>
</span><span># file
</span><span>
</span><span>paru -S gvfs gvfs-mtp gvfs-afc gvfs-nfs nemo
</span><span>
</span><span># zip
</span><span>
</span><span>paru -S peazip
</span><span>
</span><span># Type
</span><span>
</span><span>paru -S fcitx5-configtool fcitx5-chinese-addons fcitx5-skin-material fcitx5-im fcitx5-rime
</span><span>
</span><span># Blog
</span><span>
</span><span>paru -S zola npm pnpm just go
</span><span>
</span><span># ttf
</span><span>
</span><span>paru -S ttf-jetbrains-mono-nerd
</span><span>
</span><span># Wayland
</span><span>
</span><span>paru -S hyprland waybar wofi network-manager-applet swww wl-gammarelay-rs brightnessctl easyeffects wireplumber pipewire blueman wl-clipboard-rs swaync swayosd swappy grim wlogout hyprlock hyprpolkitagent
</span></code></pre>
<table><thead><tr><th>分类</th><th>软件列表</th></tr></thead><tbody>
<tr><td><strong>窗口管理器</strong></td><td>hyprland</td></tr>
<tr><td><strong>状态栏</strong></td><td>waybar</td></tr>
<tr><td><strong>启动器</strong></td><td>wofi</td></tr>
<tr><td><strong>网络</strong></td><td>network-manager-applet</td></tr>
<tr><td><strong>蓝牙</strong></td><td>blueman</td></tr>
<tr><td><strong>音频</strong></td><td>pipewire, wireplumber</td></tr>
<tr><td><strong>亮度</strong></td><td>brightnessctl, wl-gammarelay-rs</td></tr>
<tr><td><strong>剪贴板</strong></td><td>wl-clipboard-rs,wl-clip-persist</td></tr>
<tr><td><strong>通知</strong></td><td>swaync,swayosd</td></tr>
<tr><td><strong>截图</strong></td><td>grim, swappy</td></tr>
<tr><td><strong>壁纸管理</strong></td><td>swww</td></tr>
<tr><td><strong>Polkit 授权代理</strong></td><td>hyprpolkitagent</td></tr>
<tr><td><strong>锁屏/开始菜单</strong></td><td>hyprlock, wlogout</td></tr>
<tr><td><strong>文件管理</strong></td><td>gvfs, gvfs-mtp, gvfs-afc, gvfs-nfs, nemo</td></tr>
</tbody></table>
<p>安装完毕后我们开始配置输入法与字体:</p>
<p>输入法我们采用雾凇拼音即前面我们安装的fcitx5系列软件包的一个输入方案这里我们使用<a href="https://github.com/Mark24Code/rime-auto-deploy">自动部署脚本</a></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span># step1: 克隆/下载 latest 最新的稳定版到本地
</span><span>git clone --depth=1 https://github.com/Mark24Code/rime-auto-deploy.git --branch latest
</span><span># step2: 进入项目目录
</span><span>cd rime-auto-deploy
</span><span># step3: 执行部署脚本
</span><span>./installer.rb
</span></code></pre>
<p>选择部署fcitx5即可随后在设置的Input Method中Add Input Method 选择Rime随后默认按Ctrl+Space即可切换中文。</p>
<p>字体的配置在<a href="https://blog.dich.bid/learn-linux-for-pc-7/">Linux之旅(七):系统与终端字体设置</a>这一期说过这里不再赘述。缺少的字体可以通过paru下载或者到<a href="https://www.miao3.cn/">喵闪字库</a>下载ttf并安装。</p>
<h2 id="tu-xing-mei-hua">图形美化</h2>
<p>安装完毕后可以看到KDE的界面较为简陋这里给出笔者的美化配置</p>
<ul>
<li>在设置中找到Colors&amp;Themes分别设置为</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>- ColorBreeze Dark
</span><span>- Application StyleBreeze
</span><span>- Plasma StyleSweet
</span><span>- Window DecorationsEdna
</span><span>- IconsBeautySolar
</span><span>- CursorsAfterglow Cursors
</span><span>- Splash ScreenNone
</span></code></pre>
<ul>
<li>
<p>随后设置壁纸,这里给出了笔者收藏的<a href="https://github.com/Dichgrem/wallpaper.git">壁纸</a></p>
</li>
<li>
<p>设置完成后将Dock栏的Status全部隐藏删除间隔与空隙删除时间更改Memu图标随后固定常用软件到其上。</p>
</li>
<li>
<p>随后在Dock栏下新建一个空白栏结构为数字时钟加两个空白字体为JetBrains Mono24小时ISO格式。最终效果如下</p>
</li>
</ul>
<p><img src="/images/desktop.png" alt="desktop" /></p>
<h2 id="qian-yi-shu-ju">迁移数据</h2>
<p>将需要的数据迁移到Home目录下对笔者来说是用来同步的Data文件夹以及Git工作文件夹。随后Add to Places将其固定到侧边栏开启隐藏文件可见将View mode改为Detail。最终效果如下</p>
<p><img src="/images/file.png" alt="file" /></p>
<h2 id="she-zhi-ruan-jian">设置软件</h2>
<ul>
<li>配置fastfetch显示效果</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>创建配置目录mkdir -p ~/.config/fastfetch
</span><span>创建配置文件touch ~/.config/fastfetch/config.jsonc
</span><span>编辑该文件以添加你的自定义选项
</span></code></pre>
<ul>
<li>
<p>设置GFS参考<a href="https://blog.dich.bid/about-gfs/">乱七八糟:GFS项目考量笔记 </a></p>
</li>
<li>
<p>设置Keepassxc/Vscodium/Electerm导入备份好的配置文件。</p>
</li>
<li>
<p>设置Matrix/Telegram登录并在另一台设备上验证。</p>
</li>
<li>
<p>设置浏览器:导入书签备份文件(有图标);定制工具栏,下载扩展插件,包括:</p>
</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>Dark Reader暗黑模式
</span><span>kiss-translator翻译工具
</span><span>uBlock Origin广告拦截
</span><span>ClearURLs去跟踪链接
</span><span>KeePassXC-Browser链接Keepass
</span><span>BookmarkHub书签同步
</span><span>BewlyBewlyB站美化
</span><span>V2EX PolishV站美化
</span></code></pre>
<h2 id="shuang-xi-tong-tian-jia-windowsyin-dao">双系统添加Windows引导</h2>
<p>如果Grub引导菜单中没有windows选项可以通过以下方法添加</p>
<ul>
<li>安装 os-prober首先确保系统中安装了 os-prober这是一个用于检测其他操作系统的工具。</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo pacman -S os-prober
</span><span>sudo os-prober
</span></code></pre>
<ul>
<li>打开 /etc/default/grub 文件进行编辑:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo nano /etc/default/grub
</span><span># 确保 GRUB_DISABLE_OS_PROBER 设置为 false
</span></code></pre>
<ul>
<li>保存文件并退出编辑器后,运行以下命令更新 GRUB 配置:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo grub-mkconfig -o /boot/grub/grub.cfg
</span></code></pre>
<p>或者<code>手动添加</code></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>nano /etc/grub.d/40_custom
</span></code></pre>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>#!/bin/sh
</span><span>exec tail -n +3 $0
</span><span># This file provides an easy way to add custom menu entries. Simply type the
</span><span># menu entries you want to add after this comment. Be careful not to change
</span><span># the &#39;exec tail&#39; line above.
</span><span>menuentry &quot;Windows 11 (Manual)&quot; {
</span><span> insmod part_gpt
</span><span> insmod fat
</span><span> insmod chain
</span><span> set root=&#39;hd0,gpt1&#39;
</span><span> chainloader /EFI/Microsoft/Boot/bootmgfw.efi
</span><span>}
</span></code></pre>
<h2 id="archzhong-an-zhuang-qemuxu-ni-ji">Arch中安装QEMU虚拟机</h2>
<p>前面我们已经安装了Qemu高性能虚拟机平台和virt-manager用来管理虚拟机的图形界面随后配置virt-manager并安装Ubuntu-server</p>
<p>如果virt-manager报错无法找到Qemu</p>
<ul>
<li>​如果 libvirtd 服务未运行virt-manager 将无法连接到虚拟化环境。​</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl start libvirtd
</span><span>sudo systemctl enable libvirtd
</span></code></pre>
<ul>
<li>用户权限问题:​​将当前用户添加到 libvirt 组,以获得必要的权限。​</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo usermod -aG libvirt $(whoami)
</span></code></pre>
<ul>
<li>虚拟网络未激活virt-manager 可能无法连接到默认的虚拟网络。​</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo virsh net-start default
</span></code></pre>
<p>默认网络在系统启动时自动启动,可以执行:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo virsh net-autostart default
</span></code></pre>
<ul>
<li>配置文件权限问题:​配置文件的权限设置可能导致访问问题。</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo chown $(whoami):libvirt /var/run/libvirt/libvirt-sock
</span></code></pre>
<p>随后安装虚拟机,流程大概为<code>选择镜像和系统类型--设置CPU/内存--设置空间大小--编辑配置项--开启UEFI引导和3D加速</code>.</p>
<p><strong>开启3D加速</strong></p>
<ul>
<li>NIC</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>&lt;graphics type=&quot;spice&quot;&gt;
</span><span> &lt;listen type=&quot;none&quot;/&gt;
</span><span> &lt;image compression=&quot;off&quot;/&gt;
</span><span> &lt;gl enable=&quot;yes&quot; rendernode=&quot;/dev/dri/by-path/pci-0000:05:00.0-render&quot;/&gt;
</span><span>&lt;/graphics&gt;
</span><span>
</span></code></pre>
<ul>
<li>video virtio</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>&lt;video&gt;
</span><span> &lt;model type=&quot;virtio&quot; heads=&quot;1&quot; primary=&quot;yes&quot;&gt;
</span><span> &lt;acceleration accel3d=&quot;yes&quot;/&gt;
</span><span> &lt;/model&gt;
</span><span> &lt;alias name=&quot;video0&quot;/&gt;
</span><span> &lt;address type=&quot;pci&quot; domain=&quot;0x0000&quot; bus=&quot;0x00&quot; slot=&quot;0x01&quot; function=&quot;0x0&quot;/&gt;
</span><span>&lt;/video&gt;
</span></code></pre>
<p>安装完成后即可使用electerm进行SSH连接如果无法连接可以将Tun模式开启的"strict_route"关闭。</p>
<h2 id="geng-gai-qi-dong-nei-he-shun-xu">更改启动内核顺序</h2>
<p>如果安装了多个linux内核可以使用以下方法调整启动顺序</p>
<ul>
<li>使用以下命令查看内核名称:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>ls /boot/vmlinuz*
</span></code></pre>
<ul>
<li>在 /etc/default/grub 中添加或修改如下行:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>GRUB_TOP_LEVEL=&quot;/boot/vmlinuz-linux-cachyos&quot;
</span></code></pre>
<p>需要注意,这种方法会关闭 GRUB 的“记住上次启动项”的功能。</p>
<ul>
<li>修改完 /etc/default/grub 后,记得重新生成 GRUB 配置文件:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo grub-mkconfig -o /boot/grub/grub.cfg
</span></code></pre>
<p><strong>图形界面更改方法:</strong></p>
<p>可以使用grub-customizer来修改Grub这里以ubuntu为例子</p>
<ul>
<li>添加PPA源并更新软件列表</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo add-apt-repository ppa:danielrichter2007/grub-customizer
</span><span>sudo apt update
</span></code></pre>
<ul>
<li>安装GRUB Customizer</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo apt install grub-customizer
</span></code></pre>
<p>随后在grub-customizer中将要默认启动的选项放在首位即可。</p>
<h2 id="kai-ji-zi-qi-dong">开机自启动</h2>
<p><strong>设置Syncthing开机自启动</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl enable --now syncthing@&lt;username&gt;.service
</span></code></pre>
<p><strong>设置Aria2开机自启动</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>[Unit]
</span><span>Description=Aria2c - lightweight multi-protocol &amp; multi-source command-line download utility
</span><span>After=network.target
</span><span>
</span><span>[Service]
</span><span>User=dich
</span><span>Group=dich
</span><span>WorkingDirectory=/home/dich
</span><span>Environment=HOME=/home/dich
</span><span>Environment=USER=dich
</span><span>ExecStart=/usr/bin/aria2c --conf-path=/home/dich/.config/aria2/aria2.conf
</span><span>Restart=always
</span><span>NoNewPrivileges=true
</span><span>PrivateTmp=true
</span><span>
</span><span>[Install]
</span><span>WantedBy=multi-user.target
</span></code></pre>
<h2 id="kai-qi-bbr">开启BBR</h2>
<ul>
<li>确保你的内核版本 &gt;= 4.9</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>uname -r
</span></code></pre>
<ul>
<li>启用 BBR</li>
</ul>
<p>你只需要设置两个 sysctl 参数即可:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo sysctl -w net.core.default_qdisc=fq
</span><span>sudo sysctl -w net.ipv4.tcp_congestion_control=bbr
</span></code></pre>
<p>要让它们永久生效,把它们写入配置文件:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo nano /etc/sysctl.d/99-bbr.conf
</span></code></pre>
<p>加入以下内容:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>net.core.default_qdisc = fq
</span><span>net.ipv4.tcp_congestion_control = bbr
</span></code></pre>
<p>然后重新加载配置:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo sysctl --system
</span></code></pre>
<ul>
<li>验证 BBR 是否启用</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sysctl net.ipv4.tcp_congestion_control
</span></code></pre>
<p>应该输出:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>net.ipv4.tcp_congestion_control = bbr
</span></code></pre>
<h2 id="xing-neng-mo-shi-qie-huan">性能模式切换</h2>
<p>需要安装<code>power-profiles-daemon</code></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span># 查看可用的电源配置文件profiles
</span><span>powerprofilesctl list
</span><span>
</span><span># 查看当前正在使用的 profile
</span><span>powerprofilesctl get
</span><span>
</span><span># 切换到“性能”模式
</span><span>sudo powerprofilesctl set performance
</span><span>
</span><span># 切换到“平衡”模式
</span><span>sudo powerprofilesctl set balanced
</span><span>
</span><span># 切换到“省电”模式
</span><span>sudo powerprofilesctl set power-saver
</span></code></pre>
<h2 id="qi-ta-xing-neng-you-hua">其他性能优化</h2>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>Profilesyncdaemon
</span><span>将浏览器配置文件和缓存挂载到内存,退出时再写回磁盘:
</span><span>
</span><span>sudo pacman -S profile-sync-daemon
</span><span>systemctl --user enable --now psd.service
</span><span>
</span><span>Systemdoomd
</span><span>启用 systemd 自带的内存超载保护守护进程:
</span><span>
</span><span>sudo pacman -S systemd-oomd
</span><span>sudo systemctl enable --now systemd-oomd
</span><span>
</span><span>Bpftune
</span><span>加载 BPF 性能调优脚本网络、I/O、调度等
</span><span>
</span><span>sudo pacman -S bpftune
</span><span>sudo systemctl enable --now bpftune
</span><span>
</span><span>AnanicyCpp
</span><span>根据预设规则给游戏、多媒体和后台任务打优先级标签:
</span><span>
</span><span>sudo pacman -S ananicy-cpp
</span><span>sudo systemctl enable --now ananicy-cpp
</span></code></pre>
<h2 id="chang-yong-ming-ling">常用命令</h2>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>更新系统sudo pacman -Syu
</span><span>
</span><span>重新安装所有软件包sudo pacman -Qq | sudo pacman -S -
</span><span>
</span><span>Reset keyrings
</span><span>
</span><span>sudo rm -rf /etc/pacman.d/gnupg
</span><span>sudo pacman-key --init
</span><span>sudo pacman-key --populate archlinux
</span><span>
</span><span>移除数据库锁sudo rm -f /var/lib/pacman/db.lck
</span><span>
</span><span>清理软件包缓存sudo pacman -Sc (或 -Scc 完全清空)
</span><span>
</span><span>删除孤立软件包sudo pacman -Rns $(pacman -Qtdq)
</span><span>
</span><span>Install Gaming packagessudo pacman -S steam wine lutris dxvk
</span><span>
</span><span>排序镜像:
</span><span>
</span><span>sudo pacman -S reflector
</span><span>sudo reflector --latest 10 --sort rate --save /etc/pacman.d/mirrorlist
</span><span>
</span><span>更改 DNS 服务器:编辑 /etc/systemd/resolved.conf 中的 DNS=1.1.1.1 8.8.8.8,然后 sudo systemctl restart systemd-resolved
</span></code></pre>
<h2 id="zai-arch-linuxshang-an-zhuang-docker">在Arch Linux上安装Docker</h2>
<p>一般推荐在qemu虚拟机中安装这里仅做示例</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo pacman -S docker
</span></code></pre>
<p>安装完成后需要启动Docker服务并设置为开机自启</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl start docker
</span><span>sudo systemctl enable docker
</span></code></pre>
<p>运行以下命令来验证Docker是否正常工作</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo docker run hello-world
</span></code></pre>
<p>默认情况下只有root用户才能运行Docker命令。为了避免每次运行Docker命令时都需要使用sudo可以将当前用户添加到docker组</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo usermod -aG docker $USER
</span></code></pre>
<p>之后,需要注销并重新登录,或者重启系统以使更改生效。</p>
<p>安装Docker Compose</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo pacman -S docker-compose
</span></code></pre>
<hr />
<p><strong>Done.</strong></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/awesome-android-tv/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">综合工程:Android-TV 折腾小记</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/about-calling-cards/">
<span class="button__text">乱七八糟:流量卡购买与套路</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,717 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/awesome-openwrt/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/awesome-openwrt/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li class="active"><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/awesome-openwrt/">综合工程:OpenWrt路由部署与软件编译</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2023-08-12
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/zong-he-gong-cheng/">#综合工程</a></span>
<div class="post-content">
<p>前言 openwrt 是一个自由的、兼容性好的嵌入式 linux 发行版。作为软路由玩家必备的一款神器可以实现诸如去广告多拨和科学上网等多种功能。本文介绍openwrt在各种平台上的部署流程。</p>
<span id="continue-reading"></span><h2 id="yao-shi-xian-de-mu-biao"><strong>要实现的目标</strong></h2>
<ul>
<li>1.IPv6 分配到每个设备;</li>
<li>2.NAT类型为NAT1全锥形</li>
<li>3.可控的流量记录与IP控制/QOS</li>
<li>4.可靠的硬件加速;</li>
<li>5.多线多播/宽带提速;</li>
<li>6.PPPoE拨号替代一部分光猫功能</li>
<li>7.智能DNS配置与去广告</li>
<li>8.VPN配置回家</li>
<li>9.实现透明代理。</li>
</ul>
<h2 id="da-zhi-si-lu">大致思路</h2>
<ul>
<li>使用高性能的X86主机管理拨号和 DHCP 内网的工作其他无线路由器桥接做APMesh组网</li>
<li>使用绕过中国流量模式,国内流量不经过代理内核直接直连,加快国内网站访问。保持尽可能高的 NAT 等级;</li>
<li>不使用旁路由,所有流量过主路由;由于第二点代理挂了也不影响国内正常上网;</li>
<li>国内外域名分流查询,国内域名查运营商 DNS ,国外域名经代理查国外 DoH ,直接返回真实 IP</li>
<li>良好的国内 IPv6 支持,只对国内域名返回 IPv6 AAAA 结果,国外域名只用 IPv4</li>
<li>兼容 Adguard Home ,方便管理域名黑白名单;</li>
<li>对能直连的国外服务能返回最优的节点,而不是绕路其他地方;</li>
</ul>
<h2 id="xuan-ze-he-gua-de-she-bei"><strong>选择合适的设备</strong></h2>
<p>无论是传统的无线路由器还是小主机都有成为openwrt路由的潜力。截止到今天已经有20多个品牌小米华硕锐捷华三等30多种架构x86,ipq,bcm,mtd等支持刷入openwrt你可以在这个<a href="https://mao.fan/select">网站</a>找到符合你预算和其他要求的,能刷机的路由器。
传统家用无线路由器由于主频低,内存小,并不适合作为软路由;而 NAS-软路由一体式 又有 all in boom 的风险因此推荐X86平台作为物理机。当然也可以采用 armbian 平台或是开发板例如网心云老母鸡、树莓派等设备。截至本文撰写时间二手平台上的价格不太利好一台J1900平台的售价往往在200左右而专门的多网口工控机价格在200到1000不等树莓派更是成为了理财产品需要慎重选择。</p>
<h2 id="xuan-ze-he-gua-de-xi-tong"><strong>选择合适的系统</strong></h2>
<p>除了openwrt主线外还可以选择</p>
<ul>
<li>
<p><a href="https://github.com/coolsnowwolf/lede">LEDE</a> 高质量更新快速具有新特性的openwrt分支。</p>
</li>
<li>
<p><a href="https://github.com/istoreos">iStoreOS</a> iStoreOS是openwrt的一个分支iStoreOS 提供了软件中心iStore以及较美观的界面和docker支持对新手体验较好。</p>
</li>
<li>
<p><a href="https://firmware-selector.immortalwrt.org/">ImmortalWrt</a> 是一个原版openwrt的分支中文优化好更新也勤快内置镜像源可以直连下载&amp;更新。</p>
</li>
</ul>
<h2 id="ru-he-de-dao-yi-ge-openwrtxi-tong"><strong>如何得到一个openwrt系统</strong></h2>
<ol>
<li>使用编译好的现成的镜像:</li>
</ol>
<ul>
<li>恩山论坛上的"高大全","精品小包"等等,但存在一定风险;</li>
<li>使用<a href="https://downloads.openwrt.org">官方固件</a>下载得到一个最小化的系统再一步步添加自己要用的包注意需要根据你的uboot来选择注意固件名称是否带了uboot_mod!</li>
</ul>
<ol start="2">
<li>自行编译:</li>
</ol>
<ul>
<li><a href="https://openwrt.ai/?target=x86%2F64&amp;id=generic">Openwrt.ai</a>在线编译
一个固件;</li>
<li>可以使用GitHub action 云编译一个固件;</li>
<li>可以在本地linux环境中进行编译。</li>
</ul>
<ol start="3">
<li>ImageBuilder</li>
</ol>
<ul>
<li>使用<a href="https://firmware-selector.openwrt.org/">Openwrt 官方ImageBuilder编译</a></li>
<li>自行下载对应的ImageBuilder包并构建.</li>
</ul>
<h2 id="toolchain-sdk-imagebuilder">Toolchain/SDK/ImageBuilder</h2>
<table><thead><tr><th>特性</th><th><strong>Toolchain</strong></th><th><strong>SDK</strong></th><th><strong>Image Builder</strong></th></tr></thead><tbody>
<tr><td>包含内容</td><td>仅交叉编译工具链(二进制版 GCC、ld、musl、binutils</td><td>完整交叉编译环境 + feeds 脚本 + package 目录,用于 <code>.ipk</code> 包开发</td><td>预编译的根文件系统 + opkg 包(无需源码编译),用于快速定制固件映像</td></tr>
<tr><td>典型用途</td><td>用于编译第三方程序或 CI如 hello-world 示例</td><td>编写和编译 <code>.ipk</code> 包,本地或自动化环境中离线开发</td><td>快速生成可刷写的固件镜像,集成所需包且无需完整源码树</td></tr>
<tr><td>解压即用</td><td></td><td></td><td></td></tr>
<tr><td>在源码树中的作用</td><td><code>make toolchain/install</code> 自动识别并使用跳过编译流程</td><td>源码树中不会触发 SDK 安装,需要手动解压并进入其目录使用</td><td>不使用源码树,直接在 Image Builder 根目录下运行 <code>make image</code> 等命令</td></tr>
<tr><td>大小</td><td>较小(几十 MB</td><td>较大(上百 MB</td><td>中等(约数百 MB因包含预编译包</td></tr>
<tr><td>构建时间</td><td>几秒到几分钟</td><td>几分钟到十几分钟(取决于 feeds 大小)</td><td>极快,可在几十秒到几分钟内完成定制镜像</td></tr>
<tr><td>兼容性</td><td>与对应 Release 完全匹配</td><td>与对应 Release 完全匹配</td><td>与对应 Release 完全匹配</td></tr>
<tr><td>使用难度</td><td>简单,只需解压并设置 PATH</td><td>适中,需要理解 feeds 机制及包管理</td><td>最简单,适合终端用户或快速测试环境</td></tr>
</tbody></table>
<h2 id="x86ping-tai-an-zhuang-liu-cheng"><strong>X86平台安装流程</strong></h2>
<ol start="0">
<li>安装准备:</li>
</ol>
<ul>
<li>
<p>一个U盘与一台双网口物理机</p>
</li>
<li>
<p>openwrt 的编译包,官方网站:<a href="https://firmware-selector.openwrt.org/?version=24.10.0-rc2&amp;target=ipq40xx%2Fgeneric&amp;id=glinet_gl-a1300">OpenWrt Firmware Selector</a></p>
</li>
<li>
<p>或者用由 eSir 大佬编译的<a href="https://drive.google.com/drive/folders/1uRXg_krKHPrQneI3F2GNcSVRoCgkqESr">懒人包</a></p>
</li>
<li>
<p>PE 启动盘,这里推荐<a href="https://github.com/VirtualHotBar/HotPEToolBox">HotPE</a></p>
</li>
<li>
<p><a href="https://www.roadkil.net/program.php?ProgramID=12#google_vignette">img 写盘工具</a></p>
</li>
</ul>
<ol>
<li>进入PE环境</li>
</ol>
<ul>
<li>打开微PE将其安装进U盘中安装完成后将 img 工具和 openwrt 包一起放进去;</li>
<li>将U盘插入目标主机进入 BIOS-boot 设置U盘优先启动各主板进入 BIOS 的按键不同,不确定的话建议都试一遍。</li>
</ul>
<ol start="2">
<li>格式化硬盘并写盘</li>
</ol>
<ul>
<li>进入PE环境中可以看到存在名为“分区助手”的软件打开它并将目标主机硬盘格式化注意不要分区不要分区不要设置文件系统否则后续可能无法编译点击左上角提交并执行</li>
<li>打开img写盘工具将openwrt包写入硬盘注意不要写进U盘里。</li>
</ul>
<ol start="3">
<li>进入配置界面</li>
</ol>
<ul>
<li>重启系统并快速拔出U盘避免重新进入PE这时系统开始运行了。注意Esir固件是不跑码的无需担心。- 一个U盘与一台双网口物理机</li>
<li>当看到 <code>please press Enter to activate this console</code>这个提示的时候系统就安装完毕了。可使用 passwd 命令设置密码。软路由将自动获取IP地址随后我们在浏览器中打开该地址即可看到 Lucl 界面。</li>
</ul>
<ol start="4">
<li>如果你使用官方固件,注意:</li>
</ol>
<ul>
<li>硬盘空间有一部分没有被格式化可以手动格式化为ext4并挂载。</li>
<li>注意初始IP往往是192.168.1.1,如果和光猫冲突需要在网络-接口中更改。</li>
<li>基本系统主题比较简陋可以使用luci-theme-argon。</li>
<li>刷错主题无法打开luci通过 SSH 登录路由器,切换到另一个已知正常的主题(例如 Bootstrap
<code>uci set luci.main.mediaurlbase='/luci-static/bootstrap' uci commit luci /etc/init.d/uhttpd restart</code>
然后重新访问 Web 界面,查看是否恢复正常。</li>
</ul>
<h2 id="x86ping-tai-ben-di-bian-yi-wan-zheng-openwrt"><strong>X86平台本地编译完整openwrt</strong></h2>
<ul>
<li>
<p><strong>系统版本Debian 11 或者 Ubuntu LTS</strong></p>
</li>
<li>
<p><strong>网络要求:科学上网环境,配置推荐 2H4G 以上</strong></p>
</li>
<li>
<p><strong>编译依赖</strong></p>
</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo apt update
</span><span>sudo apt install -y \
</span><span> ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \
</span><span> bzip2 ccache clang cmake cpio curl device-tree-compiler diffutils diffstat findutils flex gawk \
</span><span> gcc-multilib g++-multilib git gettext gperf grep haveged help2man intltool \
</span><span> libelf-dev libfuse-dev libgmp3-dev libgl1-mesa-dev libgraphene-1.0-dev libglib2.0-dev \
</span><span> libltdl-dev libmpc-dev libmpfr-dev libncurses-dev libpython3-dev libreadline-dev libssl-dev \
</span><span> libtool lrzsz make mesa-common-dev msmtp ninja-build p7zip p7zip-full patch pkgconf \
</span><span> perl python-is-python3 python3 python3-dev python3-distutils-extra python3-pip python3-pyelftools \
</span><span> python3-setuptools qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs \
</span><span> upx-ucl unzip vim wget gnu-which xmlto xxd zlib1g-dev genisoimage llvm llvm-runtime docutils-common \
</span><span> ecj fastjar java-wrappers libeclipse-jdt-core-java libgnutls-dane0t64 \
</span><span> libgnutls-openssl27t64 libgnutls28-dev libidn2-dev libp11-kit-dev libtasn1-6-dev libtasn1-doc \
</span><span> libunbound8 libyaml-dev lld lld-18 nettle-dev python3-docutils python3-ply python3-roman re2c
</span></code></pre>
<ul>
<li><strong>清理</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo apt autoremove --purge
</span><span>sudo apt clean
</span></code></pre>
<ul>
<li><strong>新建一个用户,用于编译固件(可选)</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>useradd -m openwrt # 新建一个名为 openwrt 的用户
</span></code></pre>
<blockquote>
<p>不可以使用Root用户进行编译!!!</p>
</blockquote>
<ul>
<li><strong>修改用户默认的 Shell</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>apt install -y sudo
</span><span>usermod -s /bin/bash openwrt
</span></code></pre>
<ul>
<li><strong>切换用户</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>su openwrt
</span><span>cd ~
</span></code></pre>
<ul>
<li><strong>拉取源码,这里用的是 ImmortalWrt 24.10 分支源码:</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git clone https://github.com/immortalwrt/immortalwrt.git
</span><span>cd immortalwrt
</span></code></pre>
<ul>
<li><strong>选择分支</strong></li>
</ul>
<p>如果你想要编译稳定版(stable),使用</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git checkout xxx #例如git checkout v24.10.2
</span></code></pre>
<p>如果你想要编译最新版(snapshot),使用</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git switch xxx #例如git switch openwrt-24.10
</span></code></pre>
<h3 id="mu-lu-shuo-ming">目录说明</h3>
<table><thead><tr><th>名称</th><th>作用</th></tr></thead><tbody>
<tr><td><code>Makefile</code></td><td><strong>整个 OpenWrt 构建系统的总入口点</strong>(顶层 Makefile运行 <code>make menuconfig</code><code>make</code> 都依赖它</td></tr>
<tr><td><code>Config.in</code></td><td>Kconfig 系统的入口配置文件,决定 <code>make menuconfig</code> 菜单显示什么选项</td></tr>
<tr><td><code>config/</code></td><td>构建系统的默认配置模板、菜单逻辑,和 <code>menuconfig</code> 相关</td></tr>
<tr><td><code>include/</code></td><td>包含通用 makefile 片段的目录(比如编译选项、函数定义)</td></tr>
<tr><td><code>rules.mk</code></td><td>所有包编译通用规则都写在这里,<code>include $(TOPDIR)/rules.mk</code> 是常见语句</td></tr>
<tr><td><code>feeds.conf.default</code></td><td>定义 Feed 源(即可选的软件源),可用于管理外部包,比如 <code>luci</code><code>packages</code></td></tr>
<tr><td><code>feeds/</code> <em>(克隆后还没出现)</em></td><td><code>./scripts/feeds update -a</code> 后才会出现,用来保存外部 feed 的代码</td></tr>
<tr><td><code>package/</code></td><td>OpenWrt 自带的核心包和第三方包(除 feeds 外的)都在这,结构是 <code>package/&lt;分类&gt;/&lt;包名&gt;</code></td></tr>
<tr><td><code>target/</code></td><td>支持的平台架构,比如 <code>x86</code><code>ramips</code><code>ath79</code><code>mediatek</code> 等都在里面</td></tr>
<tr><td><code>toolchain/</code></td><td>编译器链、glibc/musl、binutils、gcc 都在这里构建</td></tr>
<tr><td><code>tools/</code></td><td>构建工具目录,编译前工具如 <code>m4</code><code>autoconf</code><code>xz</code><code>patch</code> 等放在这</td></tr>
<tr><td><code>scripts/</code></td><td>脚本工具目录,如 <code>feeds</code> 管理、镜像合并、menuconfig 支持等</td></tr>
<tr><td><code>LICENSES/</code></td><td>所有包/组件的许可证归档</td></tr>
<tr><td><code>COPYING</code></td><td>OpenWrt 的主许可证GPLv2</td></tr>
<tr><td><code>README.md</code></td><td>简要介绍如何开始使用 OpenWrt 的说明文档</td></tr>
<tr><td><code>BSDmakefile</code></td><td>为 BSD 系统一些兼容 makefileLinux 用户用不到</td></tr>
</tbody></table>
<ul>
<li><strong>添加软件源,可自行添加软件源至 feeds.conf.default 文件</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>vim feeds.conf.default
</span></code></pre>
<p><strong>常用源</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>src-git kenzo https://github.com/kenzok8/openwrt-packages
</span><span>src-git small https://github.com/kenzok8/small
</span><span>src-git haibo https://github.com/haiibo/openwrt-packages
</span><span>src-git liuran001 https://github.com/liuran001/openwrt-packages
</span></code></pre>
<p><strong>常用仓库</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>src/gz kwrt_core https://dl.openwrt.ai/releases/24.10/targets/x86/64/6.6.83
</span><span>src/gz kwrt_base https://dl.openwrt.ai/releases/24.10/packages/x86_64/base
</span><span>src/gz kwrt_packages https://dl.openwrt.ai/releases/24.10/packages/x86_64/packages
</span><span>src/gz kwrt_luci https://dl.openwrt.ai/releases/24.10/packages/x86_64/luci
</span><span>src/gz kwrt_routing https://dl.openwrt.ai/releases/24.10/packages/x86_64/routing
</span><span>src/gz kwrt_kiddin9 https://dl.openwrt.ai/releases/24.10/packages/x86_64/kiddin9
</span></code></pre>
<ul>
<li><strong>单独添加</strong>(在更新并安装插件之前执行)例如:</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git clone https://github.com/chenmozhijin/turboacc.git
</span></code></pre>
<ul>
<li><strong>更新并安装插件</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>./scripts/feeds clean
</span><span>./scripts/feeds update -a
</span><span>./scripts/feeds install -a
</span></code></pre>
<table><thead><tr><th><code>./scripts/feeds update -a</code></th><th>同步/更新 <strong>外部 feed</strong>packages、luci、routing 等)的 Git 仓库到本地 <code>feeds/</code> 目录</th></tr></thead><tbody>
<tr><td><code>./scripts/feeds install -a</code></td><td>把你在 feeds 里选要用的包 <strong>链接</strong> 到源码树的 <code>package/feeds/</code>,让它们参与编译</td></tr>
</tbody></table>
<ul>
<li><strong>自定义配置</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>#!/usr/bin/env bash
</span><span># diy-part2.sh — 在镜像生成时注入默认设置和定制 SSH 横幅及模型修复
</span><span>
</span><span># 1. 默认 hostname可选
</span><span>sed -i &#39;s/=ImmortalWrt/=my-device/&#39; package/base-files/files/bin/config_generate
</span><span>
</span><span># 2. 默认 IP 地址(可选)
</span><span>sed -i &#39;s/192.168.1.1/192.168.5.1/&#39; package/base-files/files/bin/config_generate
</span><span>
</span><span># 3. 默认 root 密码(请换成安全密码)
</span><span>HASH=$(openssl passwd -1 &#39;yourpassword&#39;)
</span><span>sed -i &quot;s|root::0:0:99999|root:${HASH}:0:0:99999|&quot; package/base-files/files/etc/shadow
</span><span>
</span><span># 4. 设置默认 LuCI 主题为 argon内置在 luci feeds
</span><span>cat &gt;&gt;package/base-files/files/etc/uci-defaults/99_set_theme &lt;&lt;&#39;EOF&#39;
</span><span>uci set luci.main.mediaurlbase=/luci-static/argon
</span><span>uci commit luci
</span><span>EOF
</span><span>chmod +x package/base-files/files/etc/uci-defaults/99_set_theme
</span><span>
</span><span># 5. 默认加载 BBR 拥塞控制算法
</span><span>mkdir -p package/base-files/files/etc/sysctl.d
</span><span>cat &gt;&gt;package/base-files/files/etc/sysctl.d/99-bbr.conf &lt;&lt;&#39;EOF&#39;
</span><span>net.core.default_qdisc=fq_codel
</span><span>net.ipv4.tcp_congestion_control=bbr
</span><span>EOF
</span><span>
</span><span># 检查BBR: sysctl net.ipv4.tcp_congestion_control
</span><span>
</span><span># 6. 将默认 shell 修改为 bash
</span><span>sed -i &quot;s|/bin/ash|/bin/bash|g&quot; package/base-files/files/etc/passwd
</span><span># 请在 .config 中添加 TARGET_PACKAGES += bash
</span><span>
</span><span># 7. 自定义 SSH 登录横幅banner
</span><span>mkdir -p package/base-files/files/etc
</span><span>if [ -f &quot;scripts/custom-files/banner.txt&quot; ]; then
</span><span> cp scripts/custom-files/banner.txt package/base-files/files/etc/banner
</span><span>else
</span><span> cat &gt;package/base-files/files/etc/banner &lt;&lt;&#39;EOF&#39;
</span><span>Welcome to MyDevice (ImmortalWrt)\n
</span><span>EOF
</span><span>fi
</span><span>
</span><span># 8. 自定义 LuCI 概览设备型号 🛠
</span><span># 通过 uci-defaults 脚本写入 /tmp/sysinfo/model
</span><span>cat &gt;&gt;package/base-files/files/etc/uci-defaults/99-model-fix &lt;&lt;&#39;EOF&#39;
</span><span>#!/bin/sh
</span><span># 设置自定义设备型号
</span><span>mkdir -p /tmp/sysinfo
</span><span>echo &quot;Your Router Model&quot; &gt; /tmp/sysinfo/model
</span><span>exit 0
</span><span>EOF
</span><span>chmod +x package/base-files/files/etc/uci-defaults/99-model-fix
</span></code></pre>
<ul>
<li>执行 <strong>make menuconfig</strong> 命令进入编译菜单。</li>
</ul>
<table><thead><tr><th>命令</th><th>功能描述</th><th>优点</th><th>适用场景</th></tr></thead><tbody>
<tr><td><code>make menuconfig</code></td><td>以 ncurses 界面交互式地浏览、修改当前 <code>.config</code> 与最新 Kconfig 中的所有选项</td><td>界面友好,支持搜索和分类;可直观调整</td><td>想手动挑选/调整配置时</td></tr>
<tr><td><code>make oldconfig</code></td><td>在命令行逐项对比 <code>.config</code> 与最新 Kconfig保留原值、提示新增项、删除废弃项</td><td>快速同步,只对新增选项发出提示;无需界面</td><td>自动化脚本或快速同步配置时</td></tr>
<tr><td><code>make defconfig</code></td><td>忽略当前 <code>.config</code>,直接加载架构/板级目录下的默认配置(<code>defconfig</code></td><td>一键生成官方/平台推荐的「干净」配置</td><td>想重置到官方默认或重新开始时</td></tr>
</tbody></table>
<h3 id="bian-yi-pei-zhi-cai-dan-shuo-ming-bu-fen"><strong>编译配置菜单说明(部分)</strong></h3>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>Target System (x86) # 选择目标平台
</span><span>└── Subtarget (x86_64) # 选择 64-bit 子架构
</span><span> └── Target Profile (Generic) # “Generic” 表示通用 x86_64 设备
</span><span> └── Target Images # 固件镜像设置
</span><span> ├── ramdisk # 可选内存盘镜像
</span><span> │ ├── Compression # 压缩类型(如 none 表示无压缩)
</span><span> │ ├── Root filesystem archives # 压缩存档cpio.gz 或 tar.gz
</span><span> │ └── Root filesystem images # 文件系统镜像ext4、squashfs、Gzip
</span><span> └── Image Options # 镜像选项
</span><span> ├── Kernel partition size # 内核分配分区大小
</span><span> ├── Root filesystem partition size # 根文件系统分区大小
</span><span> └── Make /var persistent # 是否保留 /var 持久化
</span><span>
</span><span>Global build settings # 全局构建设置
</span><span>Advanced configuration options (for developers) # 开发者高级选项
</span><span>Build the OpenWrt Image Builder # 编译镜像构建器
</span><span>Build the OpenWrt SDK # 构建交叉编译 SDK
</span><span>Package the OpenWrtbased Toolchain # 打包 OpenWrt 工具链
</span><span>Image configuration # 镜像总体配置页面
</span><span>
</span><span>Base system # 系统基础组件
</span><span>Administration # 管理工具(如 ssh、管理员脚本
</span><span>Boot Loaders # 引导程序(如 grub、syslinux
</span><span>Development # 编译/调试辅助工具
</span><span>Extra packages # 附加应用(如 wget、curl
</span><span>Firmware # 固件工具
</span><span>Fonts # 字体支持
</span><span>Kernel modules # x86 内核模块驱动
</span><span>Languages # 编程语言包(如 Python3、Node.js
</span><span>Libraries # 系统库依赖
</span><span>LuCI # Web UI 前端
</span><span>└── Collections
</span><span>└── Modules
</span><span>└── Applications
</span><span>└── Themes
</span><span>└── Protocols
</span><span>└── Libraries
</span><span>└── defaultsettings
</span><span>
</span><span>Mail # 邮件客户端
</span><span>Multimedia # 媒体工具(如 ffmpeg
</span><span>Network # 网络功能(如 openvpn、wireguard
</span><span>Sound # 音频相关软件
</span><span>Utilities # 常用实用程序(如 vim、htop
</span><span>Xorg # 桌面环境支持X11 图形系统)
</span><span>
</span></code></pre>
<ul>
<li><strong>预下载编译所需的软件包</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>make download -j8
</span></code></pre>
<ul>
<li><strong>检查文件完整性</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>find dl -size -1024c -exec ls -l {} \;
</span></code></pre>
<p>检查文件完整性命令可以列出下载不完整的文件小于1k的文件属于下载不完整如果存在则用下面的命令删除然后重新下载编译所需的软件包再次检查.确认所有文件完整可大大提高编译成功率,避免浪费时间</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>find dl -size -1024c -exec rm -f {} \;
</span></code></pre>
<ul>
<li><strong>最后编译固件(-j 后面是线程数首次编译推荐用单线程编译完成后输出路径是bin/targets.</strong></li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>make V=s -j1
</span><span>
</span><span>或者使用 make world -j1 V=s 2&gt;&amp;1 | tee world_debug.log
</span><span>
</span><span>如果报错可查看 grep -E &quot;(error|fatal|Cannot install package)&quot; world_debug.log -n
</span></code></pre>
<table><thead><tr><th>make层级</th><th>目录示例</th><th>说明</th></tr></thead><tbody>
<tr><td>make[1]</td><td>顶层 Makefile</td><td>解析依赖,调度模块</td></tr>
<tr><td>make[2]</td><td><code>tools/</code></td><td>编译辅助工具</td></tr>
<tr><td>make[2]</td><td><code>toolchain/</code></td><td>编译交叉编译工具链</td></tr>
<tr><td>make[2]</td><td><code>target/linux/</code></td><td>编译内核及设备树</td></tr>
<tr><td>make[2]</td><td><code>package/</code></td><td>进入包管理,调度包构建</td></tr>
<tr><td>make[3]</td><td><code>package/libs/libc</code></td><td>单个包的 Makefile</td></tr>
<tr><td>make[3]</td><td><code>package/utils/busybox</code></td><td>单个包的 Makefile</td></tr>
<tr><td>make[4]</td><td><code>build_dir/target-...</code></td><td>包源码目录,运行源码的 make</td></tr>
<tr><td>make[4]</td><td><code>build_dir/target-linux-...</code></td><td>内核源码目录</td></tr>
</tbody></table>
<h2 id="er-ci-bian-yi">二次编译</h2>
<table><thead><tr><th>命令</th><th>清除内容</th><th>保留内容</th><th>适用场景</th></tr></thead><tbody>
<tr><td><code>make clean</code></td><td>删除 <code>bin/</code> 镜像、<code>build_dir/</code> 编译产物</td><td><code>.config</code><code>staging_dir/</code><code>toolchain/</code></td><td>小修改后重建镜像,速度快,常用于增量编译。</td></tr>
<tr><td><code>make dirclean</code></td><td><code>make clean</code> 一样,还删除 <code>staging_dir/</code><code>toolchain/</code><code>logs</code></td><td><code>.config</code></td><td>彻底重建交叉编译环境,适合更改编译配置如 <code>.config</code>、feeds 等。</td></tr>
<tr><td><code>make distclean</code></td><td>删除 <code>make dirclean</code> 的所有内容 + feeds 下载文件 + <code>.config</code>、patch 等所有状态</td><td>只有源码目录保持不变</td><td>专用于回到一个“零配置、重做一切”的状态,完全从头开始构建。</td></tr>
</tbody></table>
<p>恢复所有修改(包括未跟踪文件):</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>git clean -fd
</span><span>git restore --source=v24.10.2 --staged --worktree .
</span></code></pre>
<h2 id="dwrt-fang-an">Dwrt 方案</h2>
<table><thead><tr><th>作用</th><th>组件</th></tr></thead><tbody>
<tr><td>主题</td><td>argon</td></tr>
<tr><td>Shell</td><td>bash</td></tr>
<tr><td>SSH 服务器</td><td>dropbear</td></tr>
<tr><td>Web 服务器</td><td>uhttpd</td></tr>
<tr><td>DNS/DHCP 服务</td><td>dnsmasqfull</td></tr>
<tr><td>加密库</td><td>openssl</td></tr>
<tr><td>压缩算法</td><td>zram+zstd</td></tr>
<tr><td>拥塞控制</td><td>bbr</td></tr>
<tr><td>防火墙</td><td>nftables + iptables</td></tr>
<tr><td>调度模块</td><td>BPF + kmod-sched-xxx</td></tr>
<tr><td>时间同步</td><td>ntpd-full</td></tr>
<tr><td>文本编辑</td><td>vim-fullvim-runtime</td></tr>
<tr><td>编译优化</td><td>LTO + O3</td></tr>
</tbody></table>
<p>要启用的软件包:</p>
<p><strong>base</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>autocore base-files bash block-mount ca-bundle coremark curl dnsmasq-full dropbear ds-lite e2fsprogs fdisk firewall4 fstools grub2-bios-setup htop kmod-8139cp kmod-8139too kmod-amazon-ena kmod-amd-xgbe kmod-atlantic kmod-bnx2 kmod-bnx2x kmod-button-hotplug kmod-drm-amdgpu kmod-drm-i915 kmod-dwmac-intel kmod-e1000 kmod-e1000e kmod-forcedeth kmod-fs-f2fs kmod-fs-vfat kmod-i40e kmod-iavf kmod-igb kmod-igbvf kmod-igc kmod-ixgbe kmod-ixgbevf kmod-lib-zstd kmod-mlx4-core kmod-mlx5-core kmod-mmc kmod-pcnet32 kmod-phy-broadcom kmod-r8101 kmod-r8125 kmod-r8126 kmod-r8168 kmod-sdhci kmod-tcp-bbr kmod-tg3 kmod-tulip kmod-usb-hid kmod-vmxnet3 libc libgcc libustream-mbedtls lm-sensors-detect logd lsblk luci-app-fan luci-app-filemanager luci-app-firewall luci-app-log-viewer luci-app-package-manager luci-app-syscontrol luci-app-upnp luci-base luci-compat luci-lib-fs luci-lib-ipkg mkf2fs mtd nano netifd odhcp6c odhcpd-ipv6only openssh-sftp-server opkg partx-utils pciutils ppp ppp-mod-pppoe resolveip swconfig uci uclient-fetch urandom-seed urngd usbutils wget-ssl zram-swap
</span></code></pre>
<p><strong>cli</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>btop iperf3 tcpdump
</span></code></pre>
<p><strong>luci</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>luci-app-argon luci-app-upnp luci-app-ttyd luci-app-eqosplus luci-app-timecontrol luci-app-parentcontrol luci-app-homeproxy luci-app-daed
</span></code></pre>
<p><strong>lib</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>kmod-ipt-conntrack kmod-ipt-nat kmod-nft-compat kmod-ipt-fullconenat kmod-ip6tables ca-certificates
</span></code></pre>
<h2 id="shi-yong-sdkkuai-su-bian-yi-bao">使用SDK快速编译包</h2>
<p>首先新建一个文件夹并将SDK克隆下来</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>mkdir imwrt-sdk
</span><span>cd ./imwrt-sdk
</span><span>wget https://downloads.immortalwrt.org/snapshots/targets/mediatek/filogic/immortalwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64.tar.zst
</span></code></pre>
<p>新版本的SDK使用ZSTD压缩因此解压的命令为</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>tar -I zstd -xvf ./immortalwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64.tar.zst
</span></code></pre>
<p>随后进入该目录并和一般流程一样更新Feeds</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>cd ./immortalwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/
</span><span>./scripts/feeds update -a
</span><span>./scripts/feeds install -a
</span></code></pre>
<p>更新完成后克隆你要编译的包的源码到package下</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>cd ./package/
</span><span>git clone https://github.com/Dichgrem/luci-app-nyn.git
</span><span>cp ./luci-app-nyn/luci-app-zzz ./
</span><span>cp ./luci-app-nyn/zzz ./
</span><span>rm -rf ./luci-app-nyn
</span><span>cd ../
</span></code></pre>
<p>随后开始编译编译结果在对应架构的base目录下</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>make package/luci-app-zzz/compile V=s
</span><span>
</span><span>~/imwrt-sdk/immortalwrt-sdk-24.10.3-x86-64_gcc-13.3.0_musl.Linux-x86_64 dich@uos
</span><span> find ./ -name &quot;zzz*.ipk&quot;
</span><span>./bin/packages/x86_64/base/zzz_0.1.1-r1_x86_64.ipk
</span></code></pre>
<h2 id="chang-yong-ming-ling">常用命令:</h2>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span># 更新软件列表
</span><span>opkg update
</span><span>
</span><span># 更新所有 LUCI 插件
</span><span>opkg list-upgradable | grep luci- | cut -f 1 -d &#39; &#39; | xargs opkg upgrade
</span><span>
</span><span># 如果要更新所有软件,包括 OpenWRT 内核、固件等
</span><span>opkg list-upgradable | cut -f 1 -d &#39; &#39; | xargs opkg upgrade
</span><span>
</span><span># 固件版本号
</span><span>vim /etc/os-release
</span><span>
</span><span># 脚本&amp;脚注
</span><span>vim /etc/openwrt_release
</span><span>
</span><span># ASCII字符画
</span><span>vim /etc/banner
</span><span>
</span><span># 登录脚本显示
</span><span>vim /etc/profile
</span></code></pre>
<h2 id="chang-yong-ke-xue-cha-jian">常用科学插件</h2>
<table><thead><tr><th>特性</th><th>HomeProxy</th><th>OpenClash</th><th>Passwall</th><th>ShellClash</th></tr></thead><tbody>
<tr><td><strong>核心</strong></td><td>Sing-box、Xray</td><td>Clash</td><td>Xray、Sing-box</td><td>Clash、Xray、Sing-box</td></tr>
<tr><td><strong>UI 管理</strong></td><td>Web UI、桌面端 GUI</td><td>OpenClash Web UI</td><td>Luci Web UI</td><td>Shell 终端管理)</td></tr>
<tr><td><strong>适用场景</strong></td><td>性能较好,但分流设置复杂</td><td>适用于clash系,机场首选</td><td>操作简单,分流完善,但对路由器性能要求较高</td><td>没有UI界面性能最好支持完善可以通过clashapi安装UI</td></tr>
</tbody></table>
<h2 id="xiao-yuan-wang-duo-she-bei-fang-jian-ce">校园网多设备防检测</h2>
<p><strong>常见检测方法</strong></p>
<ul>
<li>TTL检测法 解法插件统一修复或使用桥接使用kmod-iptables-ipot模块</li>
<li>User-Agent 解法统一经过singbox代理或使用UA2F/UA3F</li>
<li>时间戳检测法 解法统一NTP服务器</li>
</ul>
<p><strong>高性能开销检测方法</strong></p>
<ul>
<li>IP-ID检测法 解法UDP over TCP或rkp-IPid</li>
<li>Flash cookie 解法:内置防火墙组件;</li>
<li>DPI检测法 深度包检测特征值 解法:代理协议;</li>
</ul>
<blockquote>
<p>高性能开销的检测方法会浪费大量性能一般很少有学校这么做。IP-ID和Flash检测法如今已经不多见。</p>
</blockquote>
<p><strong>TTL修复</strong>:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>依赖包
</span><span>opkg install kmod-nft-core kmod-nft-bridge kmod-nft-net kmod-nft-offload kmod-nft-nat
</span><span>
</span><span>首先检查 mangle 表是否存在
</span><span>nft list tables
</span><span>
</span><span>创建 mangle 表(如果不存在)
</span><span>nft add table ip mangle
</span><span>
</span><span>创建 POSTROUTING 链(如果不存在)
</span><span>nft add chain ip mangle POSTROUTING { type nat hook postrouting priority 0 \; }
</span><span>
</span><span>
</span><span>添加 TTL 规则
</span><span>nft add rule ip mangle POSTROUTING ip ttl set 64
</span><span>
</span><span>检查规则是否生效
</span><span>nft list table ip mangle
</span></code></pre>
<h2 id="openwrtgai-apmo-shi">Openwrt改AP模式</h2>
<p>有时候我们使用X86做主路由想让无线路由器只起到发射信号的作用就可以将其改为AP模式一般步骤为</p>
<ul>
<li>更改lan地址将lan口地址改到主路由下的一个IP;</li>
<li>关闭DHCP服务</li>
<li>关闭WAN口</li>
<li>关闭防火墙的禁止转发规则,全部允许;</li>
<li>将X86主路由的网线插到AP的任意一个LAN口。</li>
</ul>
<h2 id="link">🔗</h2>
<ul>
<li><a href="https://openwrt.org/zh/docs/start">Openwrt wiki</a></li>
<li><a href="https://openwrt.ai/?target=ipq807x%2Fgeneric&amp;id=xiaomi_ax3600">OpenWrt在线定制编译</a></li>
<li><a href="https://www.cnblogs.com/tfel-ypoc/p/17226064.html">openwrt luci 页面无法访问 问题排查</a></li>
<li><a href="https://post.smzdm.com/p/axz6369w/">超详细多图简单OpenWRT 设置IPV6配置</a></li>
<li><a href="https://blog.csdn.net/weixin_44548582/article/details/121064734">保姆级-光猫改桥接-路由拨号-openwrt端口转发</a></li>
</ul>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/awesome-pve-mcsm/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">综合工程:PVE安装与MC服务器搭建</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/awesome-android-root/">
<span class="button__text">综合工程:安卓刷机与root教程</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,299 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/awesome-pve-mcsm/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/awesome-pve-mcsm/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li class="active"><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/awesome-pve-mcsm/">综合工程:PVE安装与MC服务器搭建</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2023-08-11
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/zong-he-gong-cheng/">#综合工程</a></span>
<div class="post-content">
<p>前言 假期将至不少家里有闲置设备的小伙伴想尝试开设一个我的世界Minecraft服务器却不知从何下手。本文以 PVE-Debian-MCSM 为主线介绍其部署流程。</p>
<span id="continue-reading"></span><h2 id="shen-me-shi-pve">什么是PVE</h2>
<p>PVE (全称 Proxmox Virtual Environment) 是一款开源免费的虚拟化环境平台同时支持KVM 虚拟机和 LXC 容器。它基于 Debian 和 KVM 技术开发,可在一台 PC 或服务器上同时运行Linux、OpenWRT、Windows 等实现计算、网络、存储一体化解决方案即所谓的“all in one”。类似的平台还有ESXi、Unraid等。</p>
<h2 id="shen-me-shi-mcsm">什么是MCSM</h2>
<p>MCSManager 面板简称MCSM 面板)是一款全中文,轻量级,开箱即用,多实例和支持 Docker 的 Minecraft 服务端管理面板。</p>
<p>此软件在 Minecraft 和其他游戏社区内中已有一定的流行程度,它可以帮助你集中管理多个物理服务器,动态在任何主机上创建游戏服务端,并且提供安全可靠的多用户权限系统,可以很轻松的帮助你管理多个服务器。
具体步骤安装PVE并优化开设虚拟机并安装Debian安装mscm界面并开设实例配置网络服务。</p>
<h2 id="zhun-bei-gong-zuo">准备工作</h2>
<ul>
<li>
<p>1.<a href="https://www.proxmox.com/en/downloads">PVE镜像推荐使用7.4版本</a></p>
</li>
<li>
<p>2.<a href="https://mirrors.tuna.tsinghua.edu.cn/debian/dists/">Debian镜像</a>不建议使用DVD版会出现奇怪的问题。</p>
</li>
<li>
<p>3.<a href="https://www.423down.com/10080.html">我们的老伙计Rufus</a></p>
</li>
<li>
<p>4.<a href="https://purpurmc.org/">Purpur1.19 服务端</a></p>
</li>
<li>
<p>5.<a href="https://hmcl.huangyuhui.net/">MC启动器HMCL</a></p>
</li>
<li>
<p>6.<a href="https://www.zerotier.com/download/">Zerotier客户端</a></p>
</li>
</ul>
<h2 id="yi-an-zhuang-pvebing-you-hua">一.安装PVE并优化</h2>
<p>1.将下载好的镜像用Rufus写入U盘。</p>
<p>2.将U盘插到目标主机上面进入BIOS-boot设置启动顺序。这里我使用二手浪潮服务器X99主板矿龙电源以及一块128G的SSD固态。注意大部分服务器主板有机箱入侵检测机制需要在说明书中找到特定针脚并用导电帽盖上否则无法开机。</p>
<p>3.进入安装界面选择install
随后跑码,进入如下界面,同意协议:
设置硬盘与文件类型可以选择ext4或者btrfs;
选择国家与地区这里需要手打出China
随后设置密码与邮件,邮件可以随便填:
然后设置网络连接这里插网线就有地址设置主机名并记下内网IP地址
检查无误后开始安装:
安装完成后 reboot。</p>
<p>4.浏览器打开 PVE 地址进入系统后我们需要给PVE换源。</p>
<h2 id="huan-yuan">换源</h2>
<p><strong>禁用 Ceph 企业仓库:</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>nano /etc/apt/sources.list.d/ceph.list
</span></code></pre>
<p>将文件内容注释掉或删除。</p>
<p><strong>编辑仓库源文件:</strong></p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>nano /etc/apt/sources.list.d/pve-enterprise.list
</span></code></pre>
<p>将文件内容注释掉或删除;</p>
<p><strong>启用社区仓库:</strong></p>
<p>确保社区仓库已启用。编辑社区仓库文件:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>nano /etc/apt/sources.list.d/pve-no-subscription.list
</span></code></pre>
<p>确保文件内容如下:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>deb http://download.proxmox.com/debian/pve bookworm pve-no-subscription
</span></code></pre>
<h2 id="er-xin-jian-xu-ni-ji-bing-an-zhuang-debian">二.新建虚拟机并安装Debian</h2>
<p>1.找到 local-btrfs(pve),在其中的 ISO 中上传下载好的 Debian 镜像;</p>
<p>2.随后创建虚拟机,选择 Debian 镜像并设置 CPU 核数与硬盘、内存大小;</p>
<p>3.一路确认后开机进入命令行界面即可开始Debian安装。我们选择graphical install</p>
<p>4.选择国家和语言,随后自动配置网络;</p>
<p>5.设置主机名,跳过域名设置;设置 root 账户名和密码、普通用户账户名与密码;</p>
<p>6.对磁盘进行分区,由于是虚拟机我们选择使用整个磁盘;</p>
<p>7.安装基本系统,随后将进入包管理器和大组件安装;</p>
<p>我们选择清华源速度较快。注意Debian 安装时默认开启安全源,这个源是国外的所以下载速度极慢,因此还需要修改配置文件。</p>
<p>在安装步骤进入到选择安装的桌面环境和软件时, 键入 Ctrl+Alt+F2 可以看到从图形界面转到了tty命令终端, 键入 Enter
这里修改软件源配置文件</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>nano /target/etc/apt/sources.list
</span></code></pre>
<p>修改debian-security源地址  <code>http://mirrors.ustc.edu.cn </code> 目测最快</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>deb http://mirrors.ustc.edu.cn/debian-security bullseye-security main
</span></code></pre>
<p>修改后 Ctrl+X 退出保存,然后退出终端重新进入界面继续安装,键入 Ctrl+Alt+F5。</p>
<p>下载需要一些时间,此时可以饮口茶先,随后看到如下界面:</p>
<p>由于是服务器所以不需要桌面环境:</p>
<p>安装 grub 引导:</p>
<p>随后安装完成reboot后进入mscm的安装。</p>
<h2 id="san-an-zhuang-mcsmbing-kai-she-shi-li">三.安装MCSM并开设实例</h2>
<p><strong>1.开机进入tty1界面</strong></p>
<p><strong>2.安装JAVA环境</strong>,不同版本的游戏的 Java 版本也不同。这里我们使用1.19版,需要安装 Java18。</p>
<p>安装 wget 和 下载 Java18</p>
<p><code>apt install wget &amp;&amp; wget http://img.zeruns.tech/down/Java/OpenJDK18U-jre_x64_linux_hotspot_18.0.1_10.tar.gz</code></p>
<p>创建安装目录</p>
<p><code>mkdir /usr/local/java/</code></p>
<p>解压当前目录下的 JDK 压缩文件</p>
<p><code>tar -zxvf OpenJDK18U-jre_x64_linux_hotspot_18.0.1_10.tar.gz -C /usr/local/java/</code></p>
<p>软链接程序到环境变量中</p>
<p><code>ln -sf /usr/local/java/jdk-18.0.1+10-jre/bin/java /usr/bin/java</code></p>
<p>测试是否安装正常,显示 <code>openjdk version "18.0.1" 2022-04-19</code> 则为正常</p>
<p><code>java -version</code></p>
<p><strong>3.端口开发</strong>,面板需要 23333和24444 端口,游戏服务器默认端口是 25565。</p>
<p>在 PVE-防火墙中打开它们。如果还是不行,执行如下命令:</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>systemctl stop firewalld
</span><span>
</span><span>systemctl disable firewalld
</span><span>
</span><span>service iptables stop
</span></code></pre>
<p>从而关闭防火墙。</p>
<p><strong>4.安装面板</strong>,这里使用一键安装命令(注意该脚本仅适用于 AMD64 架构)</p>
<p><code>wget -qO- https://gitee.com/mcsmanager/script/raw/master/setup.sh | bash</code></p>
<p>执行完成后,使用 <code>systemctl start mcsm-{web,daemon} </code>即可启动面板服务。使用 <code>systemctl enable mcsm-{daemon,web}.service </code>实现开机自启。</p>
<p><strong>5.在浏览器中打开该地址</strong>加上23333端口后缀即可看到面板账户为root密码为123456。</p>
<p><strong>6.新建实例</strong>,上传 Purpur1.19 服务端,设置名称随后开启实例</p>
<p><strong>7.随后我们可以在</strong> 配置文件中设置游戏的相关选项,如关闭正版验证等。</p>
<p><strong>8.大功告成</strong>,此时打开 HMCL 启动器,即可加入游戏。</p>
<h2 id="si-pei-zhi-lian-ji-wang-luo">四.配置联机网络</h2>
<p>1.此时不要忘记需要和小伙伴们一起玩耍。如果你家里有公网固定 IPv4 或者 IPv6直接输入联机即可如果没有公网IP此时就需要进行内网穿透或者DDNS。</p>
<p>这里介绍一种名为 zerotier 的工具。</p>
<p>2.首先在 https://www.zerotier.com/ 注册并创建一个私有网络;</p>
<p>3.首先在虚拟机中安装 curl 命令支持</p>
<p><code>apt-get install curl</code></p>
<p>4.安装gnupg非对称信息加密系统通讯所需必备软件</p>
<p><code>apt-get install gnupg</code></p>
<p>5.安装 ZeroTier</p>
<p><code>curl -s https://install.zerotier.com/ | bash</code></p>
<p>安装成功后提示如下:</p>
<p><code>Success! You are ZeroTier address [ xxxxxxxxx ].</code></p>
<p>方括号内地址为类似于MAC地址。</p>
<p>6.设定开机自启动(分别执行如下命令)</p>
<p><code>systemctl start zerotier-one.service</code></p>
<p><code>systemctl enable zerotier-one.service</code></p>
<p>7.加入自己的私有网络</p>
<p><code>zerotier-cli join xxxxxxxxx</code></p>
<p>8.大功告成!此时只要让小伙伴们下载 zerotier 客户端并加入相同的私有网络,即可一起快乐联机!</p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/awesome-vm-android/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">综合工程:linux搭建安卓虚拟机</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/awesome-openwrt/">
<span class="button__text">综合工程:OpenWrt路由部署与软件编译</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,460 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dich&#x27;s Blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noodp"/>
<!-- 字体预加载 - 减少布局偏移 CLS -->
<link rel="preload" href="https://blog.dich.bid/fonts/hack-regular.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bold.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-italic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://blog.dich.bid/fonts/hack-bolditalic.woff2?sha=3114f1256" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="Dich's Blog">
<meta property="og:type" content="article">
<meta property="og:url" content="https://blog.dich.bid/awesome-vm-android/">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="">
<meta name="twitter:title" content="Dich's Blog">
<meta property="twitter:domain" content="blog.dich.bid">
<meta property="twitter:url" content="https://blog.dich.bid/awesome-vm-android/">
<link rel="alternate" type="application/atom+xml" title="Dich&#x27;s Blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
<link rel="shortcut icon" type="image/webp" href="/dich.webp">
<!-- ✅ Added center alignment styles -->
<style>
.footer {
text-align: center;
padding: 1rem 0;
}
.footer__inner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.copyright {
text-align: center;
}
</style>
</head>
<body class="">
<div class="container">
<header class="header">
<div class="header__inner">
<div class="header__logo">
<a href="https://blog.dich.bid" style="text-decoration: none;">
<div class="logo">
Dich&#x27;s Blog
</div>
</a>
</div>
</div>
<nav class="menu">
<ul class="menu__inner">
<li class="active"><a href="https://blog.dich.bid">Blog</a></li>
<li><a href="https://blog.dich.bid/archive">Archive</a></li>
<li><a href="https://blog.dich.bid/weekly">Weekly</a></li>
<li><a href="https://blog.dich.bid/tags">Tags</a></li>
<li><a href="https://blog.dich.bid/search">Search</a></li>
<li><a href="https://blog.dich.bid/links">Links</a></li>
<li><a href="https://blog.dich.bid/atom.xml">Rss</a></li>
<li><a href="https://blog.dich.bid/about">About me</a></li>
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">My github</a></li>
<li><a href="https://github.com/getzola/zola" target="_blank" rel="noopener noreferrer">Zola frame</a></li>
</ul>
</nav>
</header>
<div class="content">
<div class="post" data-pagefind-body>
<h1 class="post-title"><a href="https://blog.dich.bid/awesome-vm-android/">综合工程:linux搭建安卓虚拟机</a></h1>
<div class="post-meta-inline">
<span class="post-date">
2023-08-10
</span>
</div>
<span class="post-tags-inline">
:: tags:&nbsp;
<a class="post-tag" href="https://blog.dich.bid/tags/zong-he-gong-cheng/">#综合工程</a></span>
<div class="post-content">
<p>前言 linux搭建安卓虚拟机有WaydroidQEMU和Docker三种方案各有不同。</p>
<span id="continue-reading"></span><h1 id="waydroid">Waydroid</h1>
<p>Waydroid是Anbox配合Halium技术开发的LXC Android容器可在GNU/Linux系统执行Android APP。以下是Waydroid的特色功能</p>
<ul>
<li>开源</li>
<li>支持x86与ARM架构</li>
<li>与宿主机共用剪切板</li>
<li>直接使用电脑显卡硬件加速</li>
<li>內建GAPPS可以使用Google Play</li>
<li>支持Magisk</li>
</ul>
<blockquote>
<p>Waydroid执行时的Android系统资料放在<code>~/.local/share/waydroid/data/</code>,系统映像档位于<code>/var/lib/waydroid</code>APP图示位于<code>~/.local/share/applications/</code></p>
</blockquote>
<h2 id="an-zhuang-qian-zhun-bei">安装前准备</h2>
<p>目前Waydroid只支持Intel和AMD的显卡对于 NVIDIA 显卡(除 Tegra 系列外Waydroid 不支持硬件加速推荐使用软件渲染或QEMU方案。</p>
<ul>
<li>Waydroid必须使用Wayland用此命令检查当前系统是否为Wayland</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>echo $XDG_SESSION_TYPE
</span></code></pre>
<p>若显示X11代表不是Wayland。GNOME和KDE可在登入画面切换至Wayland工作阶段。</p>
<ul>
<li>Waydroid要求Linux核心支持binder核心模组但Arch Linux预设的linux核心並无开启此选项因此需要从AUR安装binder_linux-dkms补齐。</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>paru -S binder_linux-dkms
</span></code></pre>
<ul>
<li>安装后载入binder核心模组</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo modprobe binder-linux devices=binder,hwbinder,vndbinder
</span></code></pre>
<ul>
<li>设定开机自动载入核心模组</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>echo &quot;binder_linux&quot; | sudo tee -a /etc/modules-load.d/binder_linux.conf
</span><span>
</span><span>echo &quot;options binder_linux devices=binder,hwbinder,vndbinder&quot; | sudo tee -a /etc/modprobe.d/binder_linux.conf
</span></code></pre>
<h2 id="an-zhuang-waydroid">安装Waydroid</h2>
<ul>
<li>安装以下软件包让Linux与Waydroid共享剪切板</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>paru -S wl-clipboard xclip
</span><span>paru -S python-pyclip
</span></code></pre>
<ul>
<li>安装Waydroid</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>paru -S waydroid
</span></code></pre>
<ul>
<li>初始化Waydroid下载含有GAPPS的Android系统映像档</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo waydroid init -s GAPPS -f
</span></code></pre>
<ul>
<li>启动Waydroid容器服务</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl start waydroid-container
</span></code></pre>
<h2 id="chang-yong-ming-ling">常用命令</h2>
<ul>
<li>开机自动启动</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl enable waydroid-container
</span></code></pre>
<ul>
<li>点选应用列表的「Waydroid」图示开启主画面或者使用命令</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>waydroid show-full-ui
</span></code></pre>
<ul>
<li>若Waydroid无法连上网路开放UFW防火墙</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo ufw allow 53
</span><span>sudo ufw allow 67
</span><span>sudo ufw default allow FORWARD
</span><span>sudo ufw reload
</span><span>sudo systemctl restart waydroid-container
</span></code></pre>
<ul>
<li>重启Waydroid</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl restart waydroid-container
</span></code></pre>
<ul>
<li>启动/停止Waydroid容器服务</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl start waydroid-container
</span><span>sudo systemctl stop waydroid-container
</span></code></pre>
<ul>
<li>用命令开启Waydroid主画面</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>waydroid show-full-ui
</span></code></pre>
<ul>
<li>查看系统错误讯息</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>waydroid log
</span><span>sudo waydroid logcat
</span></code></pre>
<ul>
<li>强制屏幕旋转</li>
</ul>
<p>安装Rotation Control这类APP即可强制调整Waydroid屏幕方向.</p>
<ul>
<li>模拟Wifi</li>
</ul>
<p>安装Package Manager用於查看APP的软件包名称。</p>
<p>部份APP会要求开启Wifi才能上网那么就如它所愿开启fake wifi</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>waydroid prop set persist.waydroid.fake_wifi &quot;软件包名称&quot;
</span></code></pre>
<p>例如给Fate/Go游戏开启模拟Wifi</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>waydroid prop set persist.waydroid.fake_wifi &quot;com.aniplex.fategrandorder&quot;
</span></code></pre>
<ul>
<li>模拟触控功能</li>
</ul>
<p>安装Package Manager用於查看APP的软件包名称。有些APP认不到鼠标点击需要启用模拟触控(fake touch)</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>waydroid prop set persist.waydroid.fake_touch &quot;软件包名称&quot;
</span></code></pre>
<p>例如给Fate/Go游戏开启模拟触控</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>waydroid prop set persist.waydroid.fake_touch &quot;com.aniplex.fategrandorder&quot;
</span></code></pre>
<ul>
<li>用命令安装APK</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>waydroid app install &lt;APK档案路径&gt;.apk
</span></code></pre>
<ul>
<li>进入ADB Shell</li>
</ul>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo waydroid shell
</span></code></pre>
<ul>
<li>开启多视窗模式</li>
</ul>
<p>Waydroid的多视窗模式看起来像Linux的原生应用。启动后按F11改回来。</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>waydroid prop set persist.waydroid.multi_windows true
</span><span>sudo systemctl restart waydroid-container
</span></code></pre>
<h2 id="jiang-waydroidzhu-ce-wei-googlezhuang-zhi">将Waydroid注册为Google装置</h2>
<p>Waydroid第一次开机可能会收到<code>Device is not Play Protect certified</code>的通知无法登入Google账号。</p>
<p>用以下命令取得Waydroid的装置ID。该命令会印出一长串数字。</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo waydroid shell
</span><span>
</span><span>ANDROID_RUNTIME_ROOT=/apex/com.android.runtime ANDROID_DATA=/data ANDROID_TZDATA_ROOT=/apex/com.android.tzdata ANDROID_I18N_ROOT=/apex/com.android.i18n sqlite3 /data/data/com.google.android.gsf/databases/gservices.db &quot;select * from main where name = \&quot;android_id\&quot;;&quot;
</span></code></pre>
<p>开启装置注册页面登入Google账号输入装置ID注册等个半小时应该就能登入Google账号了。如果还是不行就重新启动Waydroid容器服务</p>
<pre style="background-color:#151515;color:#e8e8d3;"><code><span>sudo systemctl restart waydroid-container
</span></code></pre>
<p>现在可以安装APP了Google Play和F-Droid会自动筛出適合x86架构的APP。</p>
<h1 id="qemu-kvm">QEMU/KVM</h1>
<h2 id="gai-shu">概述</h2>
<p>Bliss OS 是基于 Android-x86 的开源系统,已更新至 Android 13并内建 Google Play 商店,可直接运行 64 位 APK无需额外转译器在 Linux 上通过 QEMU/KVM + virglrenderer 实现 GPU 加速,使得在虚拟机中也能流畅体验手游。</p>
<h2 id="wei-shen-me-xuan-ze-bliss-os">为什么选择 Bliss OS</h2>
<ul>
<li><strong>版本更新快</strong>Bliss OS 最新测试版基于 Android 13而 Android-x86 官方仅更新至 Android 9。</li>
<li><strong>更完善的 ARM 转译</strong>:采用 Google libndk可兼容 64 位 ARM-v8a APK相比仅支持 32 位 ARM-v7 的 liboudini兼容性大幅提升。</li>
<li><strong>丰富实用功能</strong>预装强制旋转、按键映射、游戏模式、模拟触控点击、KernelSU难以检测的 root 权限)和 Gearlock 恢复环境等增强工具,提升桌面化体验。</li>
</ul>
<h2 id="huan-jing-zhun-bei">环境准备</h2>
<ul>
<li><strong>硬件要求</strong>CPU 要开启 <code>VT-x/AMD-V</code>,并加载 KVM 内核模块Intel 10 代及更新集成 GPU 可用AMD 同理;闭源 Nvidia 驱动下 virglrenderer 不稳定,不建议使用硬件加速。</li>
<li><strong>软件安装</strong>:在宿主机上安装 QEMU (≥8.1.1)、Libvirt、Virt-Manager并部署 virglrenderer (≥0.10.4) 以获得半虚拟化 3D 加速Ubuntu 与 Arch 安装方法分别见官方文档。</li>
<li><strong>性能调优</strong>:可参考 Red Hat 虚拟化性能调优指南,启用 IOMMU、调整 CPU 调度与内存缓存策略,以提升 KVM 性能。</li>
</ul>
<h2 id="an-zhuang-liu-cheng-yu-fen-qu">安装流程与分区</h2>
<ol>
<li>从官方站点下载带 GApps 的 Bliss OS 15.x ISO 镜像,并在 Virt-Manager 中新建虚拟机,选择 <code>Q35 芯片组、UEFI (OVMF)</code></li>
<li>推荐分配 ≥8 GB RAM、4 核 CPU 及 ≥64 GB 虚拟硬盘,并勾选 OpenGL、VirtIO 显示卡 + 3D 加速。</li>
<li>进入 Bliss OS 安装器,使用 GPT 分区表:
<ul>
<li>首分区 512 MB类型 EFI (<code>ef00</code>),挂载点 <code>/mnt/efi</code></li>
<li>次分区 全盘剩余空间格式化为 Ext4用于系统安装。</li>
</ul>
</li>
<li>安装 GRUB、格式化分区后强制关机移除 ISO 并重启,即可启动已启用 virglrenderer 加速的系统。</li>
</ol>
<h2 id="fen-bian-lu-diao-zheng">分辨率调整</h2>
<ul>
<li>启动时选择 “Debug QEMU/KVM VirGL” 进入 shell通过 <code>blkid</code> 找到 EFI 分区(如 <code>/dev/sda1</code>),挂载后编辑 <code>/mnt/efi/boot/android.cfg</code>
<ul>
<li><code>linux $kd/kernel</code> 行末添加 <code>video=1920x1080</code></li>
<li>修改 <code>set gfxmode=</code> 为相应分辨率,保存并重启即可生效。</li>
</ul>
</li>
<li>如需更灵活调整,可在系统内安装 SecondScreen 等第三方工具强制改分辨率。</li>
</ul>
<h2 id="xi-tong-shi-yong-ji-qiao">系统使用技巧</h2>
<ul>
<li>默认启用 Boringdroid 桌面模式,底部常驻任务栏;可在设置里为特定应用强制全屏运行。</li>
<li>强制旋转:内置 Set Orientation 或使用更佳的 OHMAE Ryosuke 工具;屏幕录制推荐宿主机通过 OBS 采集 VM 窗口。</li>
<li>多窗口开发者选项启用“自由形式窗口”Root 需在 KernelSU 中对指定应用授权Termux 可提供终端环境。</li>
<li>ADB 调试:可通过无线 ADB 连接,并在 shell 中为 <code>com.android.shell</code> 授予 Root 权限。</li>
</ul>
<h2 id="shou-you-shi-ce">手游实测</h2>
<ul>
<li>优先安装原生 x86 版游戏,减少 ARM 转译开销多游戏如《水果忍者》、《Temple Run 2》均能流畅运行。</li>
<li>部分大型游戏(如《原神》)因 virglrenderer 不稳定在着色器编译时易崩溃;《幻塔》可正常进入并游玩。</li>
<li>若触控事件不响应,可启用 “Force Mouse Click as touch” 强制映射鼠标点击,但会导致滚轮失效;开启“游戏模式”可屏蔽通知并悬浮截屏。</li>
</ul>
<h1 id="docker">Docker</h1>
<h2 id="gai-shu-1">概述</h2>
<p>ReDroidRemote-Android是一款开源的容器化 Android 解决方案,支持在 x86 主机通过 Docker、Podman 或 Kubernetes 启动多实例 Android 系统,并提供 GPU 加速与多架构arm64/amd64支持适用于云端游戏、自动化测试、虚拟手机等场景。本文从环境准备、部署配置、日常使用及进阶定制等方面逐步讲解如何在 Linux 主机上用 Docker 容器运行并优化 ReDroid使其能够流畅运行 ARM 架构的手游。</p>
<h2 id="shen-me-shi-redroid">什么是 ReDroid</h2>
<ul>
<li><strong>项目简介</strong>ReDroid 即 Remote-Android是一个多架构、GPU 加速的“Android In Cloud”AIC方案可在任何具备必要内核特性如 binderfs的 Linux 主机上部署 Android 容器。</li>
<li><strong>版本支持</strong>:活跃维护 Android 1115 多个版本的镜像,并提供丰富的文档与社区支持。</li>
<li><strong>应用场景</strong>:适用于云游戏、自动化测试、连续集成中的 UI 测试、远程开发等多种场景。</li>
</ul>
<h2 id="huan-jing-yu-yi-lai">环境与依赖</h2>
<ul>
<li><strong>内核模块</strong>:宿主机需开启 <code>binderfs</code><code>ashmem</code> 等内核模块,部分发行版可能需安装 <code>redroid-modules</code></li>
<li><strong>GPU 加速</strong>:推荐使用 Intel/AMD 集成 GPU避免闭源 NVIDIA 驱动下的不稳定性;也可在云端 GPU 实例上部署。</li>
<li><strong>软件需求</strong>:安装 Docker / Docker Compose或 Podman、ADBAndroid Debug Bridge和 Scrcpy用于容器管理与远程调试、画面传输。</li>
<li><strong>硬件配置</strong>8 GB 及以上内存、四核及以上 CPU、至少 20 GB 存储;若运行高负载游戏,推荐更高配置并开启 GPU 硬件加速。</li>
</ul>
<h2 id="bu-shu-yu-pei-zhi">部署与配置</h2>
<ol>
<li><strong>创建目录与编写 Compose 文件</strong><pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">mkdir ~</span><span>/redroid &amp;&amp; cd </span><span style="color:#ffb964;">~</span><span>/redroid
</span><span style="color:#ffb964;">vim</span><span> docker-compose.yml
</span></code></pre>
</li>
<li><strong>示例 <code>docker-compose.yml</code></strong><pre data-lang="yaml" style="background-color:#151515;color:#e8e8d3;" class="language-yaml "><code class="language-yaml" data-lang="yaml"><span style="color:#ffb964;">version</span><span>: </span><span style="color:#556633;">&#39;</span><span style="color:#99ad6a;">3.8</span><span style="color:#556633;">&#39;
</span><span style="color:#ffb964;">services</span><span>:
</span><span> </span><span style="color:#ffb964;">redroid</span><span>:
</span><span> </span><span style="color:#ffb964;">image</span><span>: </span><span style="color:#99ad6a;">redroid/redroid:11.0.0_gapps
</span><span> </span><span style="color:#ffb964;">stdin_open</span><span>: true
</span><span> </span><span style="color:#ffb964;">tty</span><span>: true
</span><span> </span><span style="color:#ffb964;">privileged</span><span>: true
</span><span> </span><span style="color:#ffb964;">ports</span><span>:
</span><span> - </span><span style="color:#556633;">&quot;</span><span style="color:#99ad6a;">127.0.0.1:5555:5555</span><span style="color:#556633;">&quot;
</span><span> </span><span style="color:#ffb964;">volumes</span><span>:
</span><span> - </span><span style="color:#99ad6a;">./redroid-11-data:/data
</span><span> </span><span style="color:#ffb964;">command</span><span>:
</span><span> - </span><span style="color:#99ad6a;">androidboot.redroid_width=720
</span><span> - </span><span style="color:#99ad6a;">androidboot.redroid_height=1280
</span><span> - </span><span style="color:#99ad6a;">androidboot.redroid_dpi=320
</span><span> - </span><span style="color:#99ad6a;">androidboot.redroid_fps=60
</span><span> - </span><span style="color:#99ad6a;">androidboot.redroid_gpu_mode=host
</span><span> - </span><span style="color:#99ad6a;">ro.product.cpu.abilist0=x86_64,arm64-v8a,x86,armeabi-v7a,armeabi
</span><span> - </span><span style="color:#99ad6a;">ro.enable.native.bridge.exec=1
</span><span> - </span><span style="color:#99ad6a;">ro.dalvik.vm.native.bridge=libndk_translation.so
</span></code></pre>
</li>
<li><strong>启动容器</strong><pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">sudo</span><span> docker compose up</span><span style="color:#ffb964;"> -d
</span></code></pre>
</li>
</ol>
<h2 id="ri-chang-shi-yong">日常使用</h2>
<ul>
<li><strong>ADB 连接与屏幕镜像</strong><pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">adb</span><span> connect localhost:5555
</span><span style="color:#ffb964;">scrcpy -s</span><span> localhost:5555</span><span style="color:#ffb964;"> --audio-codec</span><span>=aac
</span></code></pre>
</li>
<li><strong>安装 APK</strong>
<ul>
<li>使用 <code>adb install your_app.apk</code></li>
<li>或在 Scrcpy 界面中拖拽 APK 文件进行安装</li>
</ul>
</li>
<li><strong>停止与重启</strong><pre data-lang="bash" style="background-color:#151515;color:#e8e8d3;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#ffb964;">sudo</span><span> docker compose down
</span><span style="color:#ffb964;">sudo</span><span> docker compose up</span><span style="color:#ffb964;"> -d
</span></code></pre>
</li>
<li><strong>数据持久化</strong>:所有数据保存在 <code>~/redroid/redroid-11-data</code>,可备份或运行多实例。</li>
</ul>
<h2 id="gao-ji-cao-zuo-yu-an-quan-jian-yi">高级操作与安全建议</h2>
<ul>
<li><strong>Google Play 验证</strong>:首次登录 Play Store 需获取设备 ID 并在 Google 控制台注册后重启容器。</li>
<li><strong>3D 加速检测</strong>:通过 AIDA64 等应用验证 GPU 加速是否生效。</li>
<li><strong>网络安全</strong>:只绑定本地回环地址监听 ADB 端口;如需外网访问,务必配置防火墙规则,避免安全风险。</li>
</ul>
<h2 id="ding-zhi-jing-xiang-yu-gapps">定制镜像与 GApps</h2>
<ul>
<li><strong>安装 GApps</strong>:下载 OpenGApps x86_64 Android 11 Pico 包,将其中 APK 拷贝到自建镜像的 <code>system</code> 目录,再在容器内推送并授权。</li>
<li><strong>自定义 libndk</strong>:从 Android Studio 模拟器提取 Google 官方 ARM 翻译库libndk在 Dockerfile 中加入到基于 <code>redroid:13.0.0-latest</code> 的自定义镜像,提升兼容性与性能。</li>
</ul>
<hr />
<p>🔗</p>
<p><a href="https://ivonblog.com/posts/install-bliss-os-on-msi-modern-15-a10/">如何在Linux安裝Bliss OS</a></p>
<hr />
<p><strong>Done.</strong></p>
</div>
<div class="pagination">
<div class="pagination__title">
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
<hr />
</div>
<div class="pagination__buttons">
<span class="button previous">
<a href="https://blog.dich.bid/linux-1-command/">
<span class="button__icon"></span>&nbsp;
<span class="button__text">Linux-命令行操控</span>
</a>
</span>
<span class="button next">
<a href="https://blog.dich.bid/awesome-pve-mcsm/">
<span class="button__text">综合工程:PVE安装与MC服务器搭建</span>&nbsp;
<span class="button__icon"></span>
</a>
</span>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer__inner">
<div class="copyright">
<span>©
2025
Dichgrem</span>
<span class="copyright-theme">
<span class="copyright-theme-sep"> :: CC BY-SA 4.0 :: A friend comes from distant lands</span>
</a>
</span>
</div>
</div>
</footer>
</div>
</body>
</html>

1
public/buttons.css Normal file
View File

@@ -0,0 +1 @@
.button-container{display:table;margin-left:auto;margin-right:auto}button,.button,a.button{position:relative;display:flex;align-items:center;justify-content:center;padding:8px 18px;margin-bottom:5px;text-align:center;border-radius:8px;border:1px solid rgba(0,0,0,0);appearance:none;cursor:pointer;outline:none;}button.outline,.button.outline,a.button.outline{background:rgba(0,0,0,0);box-shadow:none;padding:8px 18px}button.outline :hover,.button.outline :hover,a.button.outline :hover{transform:none;box-shadow:none}button.primary,.button.primary,a.button.primary{box-shadow:0 4px 6px rgba(50,50,93,.11),0 1px 3px rgba(0,0,0,.08)}button.primary:hover,.button.primary:hover,a.button.primary:hover{box-shadow:0 2px 6px rgba(50,50,93,.21),0 1px 3px rgba(0,0,0,.08)}button.link,.button.link,a.button.link{background:none;font-size:1rem}button.small,.button.small,a.button.small{font-size:.8rem}button.wide,.button.wide,a.button.wide{min-width:200px;padding:14px 24px}a.read-more,a.read-more:hover,a.read-more:active{display:inline-flex;background:none;box-shadow:none;padding:0;margin:20px 0;max-width:100%}.code-toolbar{margin-bottom:20px}.code-toolbar .toolbar-item a{position:relative;display:inline-flex;align-items:center;justify-content:center;padding:3px 8px;margin-bottom:5px;text-align:center;font-size:13px;font-weight:500;border-radius:8px;border:1px solid rgba(0,0,0,0);appearance:none;cursor:pointer;outline:none}

View File

@@ -0,0 +1 @@
@media (prefers-color-scheme: light){:root{--background: white;--color: #101010}}@media (prefers-color-scheme: dark){:root{--background: #101010;--color: #A9B7C6}}

View File

@@ -0,0 +1 @@
:root{--background: #1D212C}

View File

@@ -0,0 +1 @@
:root{--background: #101010;--color: #A9B7C6}

View File

@@ -0,0 +1 @@
:root{--background: #1F222A}

View File

@@ -0,0 +1 @@
:root{--background: #f0f0f0}

View File

@@ -0,0 +1 @@
:root{--background: #222129}

View File

@@ -0,0 +1 @@
:root{--background: #21202C}

View File

@@ -0,0 +1 @@
:root{--background: #221F29}

View File

@@ -0,0 +1 @@
@media (prefers-color-scheme: dark){:root{--accent: rgb(35,176,255);--accent-alpha-70: rgba(35,176,255,.7);--accent-alpha-20: rgba(35,176,255,.2);--background: #101010;--color: #f0f0f0;--border-color: rgba(255,240,224,.125)}:root div.logo{color:#000}}@media (prefers-color-scheme: light){:root{--accent: rgb(32,128,192);--accent-alpha-70: rgba(32,128,192,.7);--accent-alpha-20: rgba(32,128,192,.2);--background: white;--color: #201030;--border-color: rgba(0,0,16,.125)}:root div.logo{color:#fff}}

View File

@@ -0,0 +1 @@
:root{--accent: rgb(32,128,192);--accent-alpha-70: rgba(32,128,192,.7);--accent-alpha-20: rgba(32,128,192,.2);--background: white;--color: #1D212C;--border-color: rgba(0, 0, 0, .1)}:root div.logo{color:#fff}

1
public/color/blue.css Normal file
View File

@@ -0,0 +1 @@
:root{--accent: rgb(50, 200, 255);--accent-alpha-70: rgba(50,200,255,0.7);--accent-alpha-20: rgba(50,200,255,0.35);--background: #1D212C;--color: #E0E6F0;--border-color: rgba(255, 255, 255, .1)}

View File

@@ -0,0 +1 @@
@media (prefers-color-scheme: dark){:root{--accent: rgb(120,226,160);--accent-alpha-70: rgba(120,226,160,.7);--accent-alpha-20: rgba(120,226,160,.2);--background: #101010;--color: #f0f0f0;--border-color: rgba(255,240,224,.125)}:root div.logo{color:#000}}@media (prefers-color-scheme: light){:root{--accent: rgb(24, 192, 128);--accent-alpha-70: rgba(24, 192, 128,.7);--accent-alpha-20: rgba(24, 192, 128,.2);--background: white;--color: #201030;--border-color: rgba(0,0,16,.125)}:root div.logo{color:#fff}}

View File

@@ -0,0 +1 @@
:root{--accent: rgb(24, 192, 128);--accent-alpha-70: rgba(24, 192, 128,.7);--accent-alpha-20: rgba(24, 192, 128,.2);--background: white;--color: #1D212C;--border-color: rgba(0, 0, 0, .1)}:root div.logo{color:#fff}

1
public/color/green.css Normal file
View File

@@ -0,0 +1 @@
:root{--accent: rgb(120,226,160);--accent-alpha-70: rgba(120,226,160,.7);--accent-alpha-20: rgba(120,226,160,.2);--background: #1F222A;--color: white;--border-color: rgba(255, 255, 255, .1)}

View File

@@ -0,0 +1 @@
@media (prefers-color-scheme: dark){:root{--accent: rgb(255,168,106);--accent-alpha-70: rgba(255,168,106,.7);--accent-alpha-20: rgba(255,168,106,.2);--background: #101010;--color: #f0f0f0;--border-color: rgba(255,240,224,.125)}:root div.logo{color:#000}}@media (prefers-color-scheme: light){:root{--accent: rgb(240,128,48);--accent-alpha-70: rgba(240,128,48,.7);--accent-alpha-20: rgba(240,128,48,.2);--background: white;--color: #201030;--border-color: rgba(0,0,16,.125)}:root div.logo{color:#fff}}

View File

@@ -0,0 +1 @@
:root{--accent: rgb(240,128,48);--accent-alpha-70: rgba(240,128,48,.7);--accent-alpha-20: rgba(240,128,48,.2);--background: white;--color: #1D212C;--border-color: rgba(0, 0, 0, .1)}:root div.logo{color:#fff}

1
public/color/orange.css Normal file
View File

@@ -0,0 +1 @@
:root{--accent: rgb(255,168,106);--accent-alpha-70: rgba(255,168,106,.7);--accent-alpha-20: rgba(255,168,106,.2);--background: #222129;--color: white;--border-color: rgba(255, 255, 255, .1)}

View File

@@ -0,0 +1 @@
@media (prefers-color-scheme: dark){:root{--accent: rgb(224,64,192);--accent-alpha-70: rgba(224,64,192);--accent-alpha-20: rgba(224,64,192,.2);--background: #101010;--color: #f0f0f0;--border-color: rgba(255,240,224,.125)}:root div.logo{color:#000}}@media (prefers-color-scheme: light){:root{--accent: rgb(238,114,241);--accent-alpha-70: rgba(238,114,241,.7);--accent-alpha-20: rgba(238,114,241,.2);--background: white;--color: #201030;--border-color: rgba(0,0,16,.125)}:root div.logo{color:#fff}}

View File

@@ -0,0 +1 @@
:root{--accent: rgb(224,64,192);--accent-alpha-70: rgba(224,64,192);--accent-alpha-20: rgba(224,64,192,.2);--background: white;--color: #1D212C;--border-color: rgba(0, 0, 0, .1)}:root div.logo{color:#fff}

1
public/color/pink.css Normal file
View File

@@ -0,0 +1 @@
:root{--accent: rgb(238,114,241);--accent-alpha-70: rgba(238,114,241,.7);--accent-alpha-20: rgba(238,114,241,.2);--background: #21202C;--color: white;--border-color: rgba(255, 255, 255, .1)}

View File

@@ -0,0 +1 @@
@media (prefers-color-scheme: dark){:root{--accent: rgb(255,98,102);--accent-alpha-70: rgba(255,98,102,.7);--accent-alpha-20: rgba(255,98,102,.2);--background: #101010;--color: #f0f0f0;--border-color: rgba(255,240,224,.125)}:root div.logo{color:#000}}@media (prefers-color-scheme: light){:root{--accent: rgb(240,48,64);--accent-alpha-70: rgba(240,48,64,.7);--accent-alpha-20: rgba(240,48,64,.2);--background: white;--color: #201030;--border-color: rgba(0,0,16,.125)}:root div.logo{color:#fff}}

View File

@@ -0,0 +1 @@
:root{--accent: rgb(240,48,64);--accent-alpha-70: rgba(240,48,64,.7);--accent-alpha-20: rgba(240,48,64,.2);--background: white;--color: #1D212C;--border-color: rgba(0, 0, 0, .1)}:root div.logo{color:#fff}

1
public/color/red.css Normal file
View File

@@ -0,0 +1 @@
:root{--accent: rgb(255,98,102);--accent-alpha-70: rgba(255,98,102,.7);--accent-alpha-20: rgba(255,98,102,.2);--background: #221F29;--color: white;--border-color: rgba(255, 255, 255, .1)}

1
public/css/water.min.css vendored Normal file

File diff suppressed because one or more lines are too long

BIN
public/dich.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -0,0 +1,4 @@
/*!
* Hack typeface https://github.com/source-foundry/Hack
* License: https://github.com/source-foundry/Hack/blob/master/LICENSE.md
*/@font-face{font-family:"Hack";src:url("fonts/hack-regular.woff2?sha=3114f1256") format("woff2"),url("fonts/hack-regular.woff?sha=3114f1256") format("woff");font-weight:400;font-style:normal;font-display:swap}@font-face{font-family:"Hack";src:url("fonts/hack-bold-subset.woff2?sha=3114f1256") format("woff2"),url("fonts/hack-bold-subset.woff?sha=3114f1256") format("woff");font-weight:700;font-style:normal;font-display:swap}@font-face{font-family:"Hack";src:url("fonts/hack-italic-subset.woff2?sha=3114f1256") format("woff2"),url("fonts/hack-italic-webfont.woff?sha=3114f1256") format("woff");font-weight:400;font-style:italic;font-display:swap}@font-face{font-family:"Hack";src:url("fonts/hack-bolditalic-subset.woff2?sha=3114f1256") format("woff2"),url("fonts/hack-bolditalic-subset.woff?sha=3114f1256") format("woff");font-weight:700;font-style:italic;font-display:swap}

4
public/font-hack.css Normal file
View File

@@ -0,0 +1,4 @@
/*!
* Hack typeface https://github.com/source-foundry/Hack
* License: https://github.com/source-foundry/Hack/blob/master/LICENSE.md
*/@font-face{font-family:"Hack";src:url("fonts/hack-regular.woff2?sha=3114f1256") format("woff2"),url("fonts/hack-regular.woff?sha=3114f1256") format("woff");font-weight:400;font-style:normal;font-display:swap}@font-face{font-family:"Hack";src:url("fonts/hack-bold.woff2?sha=3114f1256") format("woff2"),url("fonts/hack-bold.woff?sha=3114f1256") format("woff");font-weight:700;font-style:normal;font-display:swap}@font-face{font-family:"Hack";src:url("fonts/hack-italic.woff2?sha=3114f1256") format("woff2"),url("fonts/hack-italic.woff?sha=3114f1256") format("woff");font-weight:400;font-style:italic;font-display:swap}@font-face{font-family:"Hack";src:url("fonts/hack-bolditalic.woff2?sha=3114f1256") format("woff2"),url("fonts/hack-bolditalic.woff?sha=3114f1256") format("woff");font-weight:700;font-style:italic;font-display:swap}

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More