Compare commits

..

62 Commits

Author SHA1 Message Date
dichgrem
266bf40880 clean:backup 2025-11-21 14:05:49 +08:00
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
324 changed files with 36911 additions and 1814 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@0.21.0
- 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

2
.gitignore vendored
View File

@@ -1,2 +0,0 @@
.idea/
public

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2026 Dichgrem Copyright (c) 2025 Dichgrem
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

428
Terminimal.md Normal file
View File

@@ -0,0 +1,428 @@
# Terminimal
[![Build Status](https://github.com/pawroman/zola-theme-terminimal/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/pawroman/zola-theme-terminimal/actions/workflows/pages/pages-build-deployment)
![No JavaScript](https://img.shields.io/badge/JavaScript-none-brightgreen.svg)
![Screenshot](../master/screenshot.png?raw=true)
See the live demo (of the default configuration) here:
https://pawroman.github.io/zola-theme-terminimal/
Tested with Zola v0.17.2. Please note that earlier versions might not work because of breaking changes across Zola versions.
#### Fork disclaimer
This theme is a fork (not a port) of "Terminal" Hugo theme
by Radosław Kozieł (aka. panr):
https://github.com/panr/hugo-theme-terminal
Many thanks for that outstanding original theme, Radek!
For more information about this fork and the differences to the original theme, please see:
[Changes compared to the original theme](#changes-compared-to-the-original-theme) below.
## Versioning
This theme used to be non-versioned, e.g. you'd pull the master branch, and occasionally new features or fixes would
be released.
Starting from version v1.0.0, the project adopted [Semantic Versioning](https://semver.org/).
Please check the [GitHub releases](https://github.com/pawroman/zola-theme-terminimal/releases) to see a change log
and work out if there's any breaking changes.
## How to start
Option A: clone the theme directly into your Zola site folder:
```
$ git clone https://github.com/pawroman/zola-theme-terminimal.git themes/terminimal
```
Option B: include it as a git submodule (it's better if you plan to use CI builders):
```
$ git submodule add https://github.com/pawroman/zola-theme-terminimal.git themes/terminimal
```
Then in your `config.toml` set:
```toml
theme = "terminimal"
# Sass compilation is required
compile_sass = true
```
Also see the Zola documentation on using themes:
https://www.getzola.org/documentation/themes/installing-and-using-themes/
## Shortcodes
The theme adds two custom shortcodes related to image handling.
### `image`
Used to show images.
Required arguments:
- **`src`**
Optional arguments:
- **`alt`**
- **`position`** (center \[default\] | left | right)
- **`style`**
Example:
```
{{ image(src="/img/hello.png", alt="Hello Friend",
position="left", style="border-radius: 8px;") }}
```
### `figure`
Same as `image`, but with a few extra optional arguments:
- **`caption`** (supports markdown)
- **`caption_position`** (center \[default\] | left | right)
- **`caption_style`**
Example:
```
{{ figure(src="http://rustacean.net/assets/rustacean-flat-gesture.png",
style="width: 25%;",
position="right",
caption_position="left",
caption="**Ferris**, the (unofficial) Rust mascot",
caption_style="font-style: italic;") }}
```
## OpenGraph
To add an image to a post, set the `og_image` extra option to the desired image
in the same directory of the markdown file:
```toml
[extra]
og_image = "colocated_image.png"
```
Additionally, for the section pages and for posts to have a fallback image, add
`default_og_image` to the `[extra]` section:
```toml
[extra]
default_og_image = "static/ocean.jpg"
```
## Configuration
### Only show the post's description
On each post you can specify the following:
```toml
description = "test description"
[extra]
show_only_description = true
```
This will render `test description` under this
particular post on the homepage instead of a summary.
### Colors
Both the accent colors and background colors are
configurable.
By default, both accent and background are set
to `blue`.
To configure menu, add this in `[extra]` section
of your `config.toml`:
```toml
[extra]
# One of: blue, green, orange, pink, red.
# Defaults to blue.
# Append -light for light themes, e.g. blue-light
# Or append -auto, e.g. blue-auto
accent_color = "green"
# One of: blue, dark, green, orange, pink, red, light, auto
# Enabling dark background will also modify primary font color to be darker.
# Defaults to accent color (or, if not accent color specified, to blue).
background_color = "dark"
```
### Logo text and link
You can set the "logo" text and what it links to,
by modifying `config.toml` like so:
```toml
[extra]
# The logo text - defaults to "Terminimal theme"
logo_text = "My blog"
# The logo link - defaults to base_url.
logo_home_link = "/take/me/away!"
```
### Author and copyright
You can set the footer's copyright author name like this:
```toml
[extra]
# Author name: when specified, modifies the default
# copyright text. Apart from author, it will
# contain current year and a link to the theme.
author = "My Name"
```
If you don't like the default copyright text,
you can set it to completely custom HTML:
```toml
[extra]
# Copyright text in HTML format. If specified,
# entirely replaces default copyright and author.
copyright_html = "My custom&nbsp;<b>copyright</b>"
```
### Menu
The menu is optional, static (all items are always shown,
no matter what the screen size) and fully user-configurable.
To configure menu, add this in `[extra]` section
of your `config.toml`:
```toml
[extra]
# menu is enabled by adding menu_items (optional)
menu_items = [
# each of these is optional, name and url are required
# $BASE_URL is going to be substituted by base_url from configuration
{name = "blog", url = "$BASE_URL"},
# tags should only be enabled if you have "tags" taxonomy
# see documentation below for more details
{name = "tags", url = "$BASE_URL/tags"},
{name = "archive", url = "$BASE_URL/archive"},
{name = "about me", url = "$BASE_URL/about"},
# set newtab to true to make the link open in new tab
{name = "github", url = "url-to-your-github", newtab = true},
]
```
### Tags
The theme optionally supports tags. To enable them, create
a "tags" taxonomy in your `config.toml`:
```toml
taxonomies = [
{name = "tags"},
]
```
Enabling tags will create a new `/tags` page, and
cause them to show up in `archive` section. Note
that you still need to create a menu link to the tags
page manually.
### Pagination
Pagination is fully supported for post list (main site)
and intra-post (you can navigate to earlier and later posts).
To make sure pagination works properly, you must first configure
it in `content/_index.md`:
```
+++
# number of pages to paginate by
paginate_by = 2
# sorting order for pagination
sort_by = "date"
+++
```
Then, tweak the theme's pagination config in `config.toml`:
```toml
[extra]
# Whether to show links to earlier and later posts
# on each post page (defaults to true).
enable_post_view_navigation = true
# The text shown at the bottom of a post,
# before earlier/later post links.
# Defaults to "Thanks for reading! Read other posts?"
post_view_navigation_prompt = "Read more"
```
### Language code
Internationalization / translation is not supported
but you can set the HTML language code for your
site:
```toml
default_language = "en"
```
### Hack font subset
By default, the theme uses a mixed subset of the Hack font.
Normal weight font uses full character set
(for Unicode icons and special symbols), but all others
(bold, italic etc) use a limited subset.
This results in much smaller transfer sizes, but the subset
might not contain all the Unicode characters you need.
You can enable full unicode support in `config.toml`:
```toml
[extra]
# Use full Hack character set, not just a subset.
# Switch this to true if you need full unicode support.
# Defaults to false.
use_full_hack_font = true
```
Also see [Hack's docs](https://github.com/source-foundry/Hack/blob/master/docs/WEBFONT_USAGE.md).
### Favicon
The theme supports adding a global favicon (applies to
all pages) to the site:
```toml
# Optional: Global favicon URL and mimetype.
# Mimetype defaults to "image/x-icon".
# The URL should point at a file located
# in your site's "static" directory.
favicon = "/favicon.png"
favicon_mimetype = "image/png"
```
### Page titles
The theme allows you to configure how the page titles (the `<title>` elements) are rendered.
Use `"combined"` to render titles as `"Page title | Main title"`.
```toml
# Optional: Set how <title> elements are rendered.
# Values:
# - "main_only" -- only the main title (`config.title`) is rendered.
# - "page_only" -- only the page title (if defined) is rendered,
# falling back to `config.title` if not defined or empty.
# - "combined" -- combine like so: "page_title | main_title",
# or if page_title is not defined or empty, fall back to `main_title`
#
# Note that the main (index) page only has the main title.
page_titles = "combined"
```
All the configuration options are also described in
[`config.toml`](../master/config.toml).
## Extending
Each of the templates defines named blocks, so
it should be quite easy to customize the most common things.
For example, if you want to add extra `<meta>` tags to the
base template, `index.html`, create file like this in `templates/index.html`:
```html
{% extends "terminimal/templates/index.html" %}
{% block extra_head %}
<meta name="description" content="My awesome website"/>
<meta name="keywords" content="Hacking,Programming,Ranting"/>
{% endblock %}
```
## How to contribute
If you spot any bugs or wish to contribute new features, please create a new
[Pull Request](https://github.com/pawroman/zola-theme-terminimal/pulls).
## Changes compared to the original theme
This theme has been forked from https://github.com/panr/hugo-theme-terminal
- Slight changes in the layout and styling.
- Content has been centered (instead of left-aligned).
- The header stripes have been spaced out.
- Tweaks to pagination, especially on mobile (small screens).
- The post title underline is dashed instead of doubly-dotted.
- All links are underlined, as per
[Brutalist Web Design Guidelines](https://www.brutalist-web.design/).
- Tweaks to header font sizes.
- Minor footer tweaks.
- Absolutely **no JavaScript**.
- No JavaScript needed to pre-process anything.
Zola with its Sass pre-processor is the only dependency.
- There's no menu trigger.
- Things load crazy fast, as it's all static content.
- Prism.js syntax highlighting is not supported (you can use
[Zola's](https://www.getzola.org/documentation/content/syntax-highlighting/)).
- All references to social media (e.g. Twitter) have been removed.
- All references to external URLs (e.g. Google CDN) have been removed.
This theme's static assets are meant to be served from where it's hosted.
- [Hack](https://github.com/source-foundry/Hack) is the default font.
- The default color theme is blue (original uses orange).
### New features
- You can pick the accent color as well as background color.
There's a new `dark` background. See [Configuration](#configuration)
below for details.
- Active "section" links will change color indicating the
active section. This is all static, done at template level.
### Features retained from the original
- 5 color themes, depending on your preference:
blue (default), green, orange, pink, red.
- The shortcodes `image` and `figure` (See [Shortcodes](#shortcodes)).
- Fully responsive.
## License
Copyright © 2019 Paweł Romanowski (pawroman)
Original theme: Copyright © 2019 Radosław Kozieł ([@panr](https://twitter.com/panr))
The theme is released under the MIT License.
Check the [license file](../master/LICENSE.md)
for more information.
The license for Hack fonts used is included in
[LICENSE-Hack.md](../master/LICENSE-Hack.md).

View File

@@ -22,22 +22,6 @@ taxonomies = [
[markdown] [markdown]
highlight_code = true highlight_code = true
highlight_theme = "boron" highlight_theme = "boron"
render_emoji = false
external_links_target_blank = true
external_links_no_follow = true
external_links_no_referrer = true
smart_punctuation = false
bottom_footnotes = true
table_of_contents = { start_level = 2, end_level = 4 }
[markdown.highlight_themes]
light = "boron"
dark = "dracula"
[slugify]
paths = "on"
taxonomies = "on"
anchors = "on"
[extra] [extra]
@@ -77,13 +61,13 @@ menu_items = [
# see documentation below for more details # see documentation below for more details
{name = "Archive", url = "$BASE_URL/archive"}, {name = "Archive", url = "$BASE_URL/archive"},
{name = "Weekly", url = "$BASE_URL/weekly"}, {name = "Weekly", url = "$BASE_URL/weekly"},
{name = "Tags", url = "$BASE_URL/tags"}, {name = "Tags", url = "$BASE_URL/tags"},
{name = "Search", url = "$BASE_URL/search"}, {name = "Search", url = "$BASE_URL/search"},
{name = "Links", url = "$BASE_URL/links"}, {name = "Links", url = "$BASE_URL/links"},
{name = "Rss", url = "$BASE_URL/atom.xml"}, {name = "Rss", url = "$BASE_URL/atom.xml"},
{name = "About me", url = "$BASE_URL/about"}, {name = "About me", url = "$BASE_URL/about"},
# set newtab to true to make the link open in new tab # set newtab to true to make the link open in new tab
{name = "My github", url = "https://github.com/Dichgrem", newtab = true}, {name = "My github", url = "https://github.com/Dichgrem", newtab = true},

View File

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

View File

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

View File

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

View File

@@ -33,13 +33,12 @@ Aria2 有以下几个特点:
### Windows ### Windows
首先在Github下载aria2[aria2-1.37.0-win-64bit-build1.zip](https://github.com/aria2/aria2/releases/tag/release-1.37.0),将下载好的文件解压并放到你喜欢的目录下,这里放到``D:\Software\aria2\aria2c.exe`` 首先下载[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 。
然后在同一个目录下创建一个配置文件``aria2.conf``,内容如下: 然后创建一个配置文件``C:\Users\<你>\.aria2\aria2.conf``,内容如下:
```
```conf
# 下载目录 # 下载目录
dir=C:/Users/<你的用户名>/Downloads dir=C:/Users/<你>/Downloads
# 断点续传 # 断点续传
continue=true continue=true
@@ -50,31 +49,20 @@ enable-rpc=true
rpc-listen-all=true rpc-listen-all=true
rpc-allow-origin-all=true rpc-allow-origin-all=true
rpc-listen-port=6800 rpc-listen-port=6800
rpc-secret=<设置一个密码> rpc-secret=<你的密码>
``` ```
随后在这个项目中[winsw](https://github.com/winsw/winsw)下载 WinSW-x64.exe到一个目录并重命名为 aria2-service.exe并在同目录下创建``aria2-service.xml``,内容如下:
随后使用winfet安装servyservy是一个将任何应用变成原生 Windows 服务的软件可以让aria2服务开机自启动类似linux上的systemctl.
``` ```
winget install servy <service>
<id>aria2</id>
<name>Aria2 Service</name>
<description>Aria2 Download Manager</description>
<executable>C:\Users\<你>\scoop\apps\aria2\current\aria2c.exe</executable>
<arguments>--conf-path=C:\Users\<你>\.aria2\aria2.conf</arguments>
</service>
``` ```
安装完成后打开管理员权限的powershell运行以下命令注意路径要和你实际的路径相同 随后使用``.\aria2-service.exe install``安装服务,并使用``.\aria2-service.exe start``启动服务类似linux上的systemctl.
```bash
servy-cli install `
--name aria2 `
--displayName "aria2 download service" `
--description "aria2 background download daemon" `
--path D:\Software\aria2\aria2c.exe `
--params="--conf-path=D:\Software\aria2\aria2.conf" `
--startupDir D:\Software\aria2 `
--startupType Automatic `
--recoveryAction RestartProcess `
--stdout D:\Software\aria2\stdout.log `
--stderr D:\Software\aria2\stderr.log
```
随后使用``servy-cli start --name aria2``开启服务,并使用``servy-cli status --name aria2``查看服务在running中则一切正常现在可以到本文的末尾安装浏览器插件并连接使用。
> 注意修改用户名! > 注意修改用户名!
@@ -83,16 +71,16 @@ servy-cli install `
Arch linux 和大部分常规发行版可以适用此方法。 Arch linux 和大部分常规发行版可以适用此方法。
首先安装aria2本体: 首先安装aria2本体:
```bash ```
paru -S aria2 paru -S aria2
``` ```
随后创建配置文件 随后创建配置文件
```bash ```
nano /home/<you-username>/.config/aria2/aria2.conf nano /home/<you-username>/.config/aria2/aria2.conf
``` ```
内容为 内容为
```conf ```
enable-rpc=true enable-rpc=true
rpc-listen-all=true rpc-listen-all=true
rpc-allow-origin-all=true rpc-allow-origin-all=true
@@ -104,11 +92,11 @@ save-session=/home/<you-username>/.config/aria2/aria2.session
save-session-interval=60 save-session-interval=60
``` ```
保存退出;随后创建守护进程以便开机自启动: 保存退出;随后创建守护进程以便开机自启动:
```bash ```
nano ~/.config/systemd/user/aria2.service nano ~/.config/systemd/user/aria2.service
``` ```
写入: 写入:
```conf ```
[Unit] [Unit]
Description=Aria2 Daemon Description=Aria2 Daemon
After=network.target After=network.target
@@ -122,20 +110,18 @@ WantedBy=default.target
``` ```
在更新配置文件和服务文件后,执行以下命令以重启服务: 在更新配置文件和服务文件后,执行以下命令以重启服务:
```bash ```
systemctl --user daemon-reload systemctl --user daemon-reload
systemctl --user enable aria2.service systemctl --user enable aria2.service
systemctl --user start aria2.service systemctl --user start aria2.service
``` ```
使用以下命令检查服务状态: 使用以下命令检查服务状态:
```bash ```
systemctl --user status aria2.service systemctl --user status aria2.service
``` ```
现在可以到本文的末尾安装浏览器插件并连接使用。
### Nixos ### Nixos
```nix ```
{ lib, pkgs, username, ... }: { lib, pkgs, username, ... }:
{ {
services.aria2.enable = false; services.aria2.enable = false;
@@ -165,8 +151,6 @@ systemctl --user status aria2.service
}; };
} }
``` ```
现在可以到本文的末尾安装浏览器插件并连接使用。
## 命令行用法 ## 命令行用法
如果你不想用浏览器插件或者面板,也可以直接使用命令行操作: 如果你不想用浏览器插件或者面板,也可以直接使用命令行操作:

255
content/Network-cdn.md Normal file
View File

@@ -0,0 +1,255 @@
+++
title = "网络艺术:CDN技术与应用"
date = 2024-02-16
[taxonomies]
tags = ["Network"]
+++
前言 内容分发网络CDN是一组分布在不同地理位置的服务器网络,使用户能够就近获取内容,从而降低延迟并缓解源站压力​.
<!-- more -->
## 什么是CDN
内容分发网络CDN是一组分布在不同地理位置的服务器网络旨在将网站或应用的静态资源如HTML、图片、视频等缓存到距离用户更近的节点以缩短传输路径、降低带宽成本并提高访问速度.CDN通过“缓存”机制在全球多个数据中心临时存储内容副本用户发起请求时无需回源到主服务器就能从最近的缓存节点获取数据从而显著改善页面加载时间和整体用户体验.相比传统的单点源站访问CDN在用户和源站之间增加了分层缓存通过负载均衡技术和智能路由将访问请求定向到最优节点既减轻了源站压力又提升了网络抗拥塞能力和可用性.
在现代互联网中内容分发网络CDN和域名系统DNS相互配合共同提升了网页和多媒体内容的访问速度与可靠性.CDN通过在全球分布的缓存节点上存储静态资源使用户能够就近获取内容从而降低延迟并缓解源站压力.而DNS则负责将用户的域名请求导向适当的CDN节点通过CNAME重定向、全局负载均衡GSLB、Anycast及EDNS扩展等技术实现智能化的流量调度和最优路径选择.
**CDN的核心功能与优势**
- 加速访问:将内容存储于距离用户更近的节点,减少传输延迟,常见于视频点播、大文件下载等场景​.
- 减轻源站压力缓存请求可直接由CDN节点响应降低源站带宽和计算资源消耗有助于应对突发流量和DDoS攻击.
- 高可用与弹性扩展:全球分布的节点架构,使内容分发具备冗余能力,单点故障不会影响整体服务,且可动态扩容以应对业务增长.
## CDN与DNS的结合方式
1. **通过CNAME实现权威DNS指向CDN**
当用户在浏览器中输入域名发起请求时首先触发本地DNS解析过程如果该域名已开通CDN服务其DNS解析记录通常配置为一条CNAME别名记录指向CDN运营商提供的专用域名本地DNS服务器再将解析权交给CDN的权威DNS服务器从而实现对CDN网络的接入.
CDN的权威DNS服务器根据用户请求的域名返回一个“全局负载均衡设备”的IP地址该IP并非最终缓存节点而是GSLB层用于智能调度的入口地址浏览器接收到该IP后向GSLB层发起实际内容请求.
2. **全局负载均衡GSLB与智能DNS**
GSLBGlobal Server Load Balancing是CDN架构中最核心的部分负责根据多种因素用户IP地理位置、节点健康状态、节点负载情况等动态选择最优区域负载均衡节点或缓存服务器向用户提供最低延迟和最佳性能的服务.
这一过程通常也基于DNS解析完成当GSLB层接到DNS查询请求时智能DNS服务器会返回针对该用户最优的缓存节点IP从而实现“DNS级”的流量调度和负载均衡.
3. **Anycast与EDNS扩展**
Anycast路由部分CDN运营商在全球部署相同IP的多个节点利用BGP Anycast技术使得用户请求自动路由到网络拓扑上“最近”的节点增强访问的网络路径效率与容灾能力.
EDNS Client SubnetEDNS-CS传统DNS仅看到发起查询的递归DNS服务器IP难以准确判断终端用户位置EDNS-CS协议在DNS请求中携带部分客户端IP前缀使权威DNS能更细粒度地进行地理定位与节点选取大幅提升了基于DNS的智能调度精度.
## 为什么加了CDN之后网站的自签名证书也被信任了
> 在启用 CDN 后终端用户看到的并不是您在源站origin上配置的自签名证书而是 CDN 边缘节点edge所出示的、由受信任 CA 签发的“边缘证书”.也就是说,浏览器与 CDN 边缘之间的 TLS 握手完全独立于您源站和自签名证书的存在,源站的自签名证书仅用于 CDN 与源站之间的“后端”加密连接,不会暴露给最终用户浏览器​.
**CDN 模式下的 TLS 终止**
- **DNS/CNAME 指向**
当您为域名启用 CDN 后,通常会在 DNS 中将该域名的 CNAME 记录指向 CDN 运营商提供的专用域名,本地递归 DNS 随后会将解析权交给 CDN 供应商的权威 DNS实现请求切入 CDN 网络​.
- **边缘节点出示证书**
用户发起 HTTPS 请求时,浏览器直接与就近的 CDN 边缘节点建立 TLS 连接,边缘节点会出示由受信任 CA如 Let's Encrypt、DigiCert 等)签发的“边缘证书”,而非您源站的自签名证书​.
- **源站连接加密**
在边缘节点接收并缓存用户流量后CDN 再以 HTTPS或 HTTP根据配置向源站发起请求.此时,您可以在源站使用自签名证书(或 Cloudflare Origin CA 自签名证书),仅保证 CDN 与源站之间的加密传输,且该证书对终端用户浏览器不可见​.
### SSL/TLS 加密模式对自签名证书的影响
以 Cloudflare 为例,常见的四种 SSL/TLS 模式对自签名证书的处理策略如下:
- **Flexible**:浏览器 ↔ CDN 边缘 使用 HTTPSCDN 边缘 ↔ 源站 使用 HTTP不接触证书验证.
- **Full**:浏览器 ↔ CDN 边缘 使用 HTTPSCDN 边缘 ↔ 源站 使用 HTTPS但不验证源站证书的 CA 链和域名匹配,可使用自签名证书​.
Cloudflare Docs
- **Full (strict)**:浏览器 ↔ CDN 边缘 使用 HTTPSCDN 边缘 ↔ 源站 使用 HTTPS严格验证源站证书是否由受信任 CA 签发且域名匹配,不支持自签名证书​.
Cloudflare Docs
- **Off**:关闭 HTTPS加密支持完全关闭.
若您选择 Full 或 Flexible 模式即使源站使用自签名证书CDN 也不会在边缘层对其进行验证,仍会正常转发和缓存内容;而用户浏览器只会看到 CDN 边缘提供的受信任证书,因此不会出现“不受信任”警告​.
> 为什么浏览器会信任? 浏览器内置了受信任的根证书列表CDN 边缘出示的证书链会完整地链接到某个系统信任根,而您的自签名证书则不在此列表内,因而只有源站连接可被 CDN 信任,而非终端浏览器​.CDN 则作为“可信中间人”,它信任自签名证书以加密与源站的通信,而浏览器仅信任 CDN 边缘的 CA 签发证书,二者互不干扰,有效隔离了自签名的风险.
### 如何开启Full (Strict)模式?
​要在 Cloudflare 上启用 Full (Strict) 模式,以确保 CDN 与源站之间的通信既加密又验证证书的有效性,请按照以下步骤操作:​
✅ 步骤 1确保源站配置了有效的 SSL/TLS 证书
在启用 Full (Strict) 模式之前,您的源站必须安装一个有效且受信任的 SSL/TLS 证书.​您可以选择以下方式之一:​
使用公共 CA 颁发的证书:如 Let's Encrypt、DigiCert、GlobalSign 等.
使用 Cloudflare Origin CA 证书:这是 Cloudflare 提供的免费证书,专为与其边缘节点通信设计.
确保证书未过期,且域名匹配正确.如果使用 Cloudflare Origin CA 证书,请在源站服务器上正确安装,并配置服务器(如 Nginx、Apache以使用该证书.
✅ 步骤 2在 Cloudflare 仪表板中启用 Full (Strict) 模式
```
登录到您的 Cloudflare 仪表板.
选择您要配置的站点.
在左侧菜单中,点击 “SSL/TLS”.
在 “概览Overview” 标签下,找到 “SSL/TLS 加密模式SSL/TLS encryption mode”.
选择 “Full (Strict)” 模式.
```
更改后Cloudflare 会立即应用此设置.​建议等待几分钟,然后通过浏览器访问您的网站,确保一切正常运行.
🔗 注意事项
如果源站使用的是自签名证书或过期的证书,启用 Full (Strict) 模式后Cloudflare 将无法建立连接,用户可能会看到 526 错误.
确保源站服务器的时间设置正确,以避免因时间不一致导致的证书验证失败.
## DNSSEC是什么
DNSSECDomain Name System Security Extensions域名系统安全扩展是一组为 DNS 协议设计的安全机制,旨在通过数字签名验证 DNS 数据的真实性和完整性,防止域名解析过程中的数据篡改和伪造.
1. DNSSEC 的工作原理
DNSSEC 通过引入以下关键机制来增强 DNS 的安全性:​
- 数字签名RRSIG 记录):​每个 DNS 记录集(如 A、MX、CNAME 等)都会生成一个对应的数字签名,确保记录在传输过程中未被篡改.
- 公钥发布DNSKEY 记录):​用于存储验证数字签名所需的公钥.​这些公钥本身也通过上级域的签名进行验证,形成信任链.
- 委派签名者DS 记录):上级域使用 DS 记录存储下级域的 DNSKEY 记录的摘要,确保公钥的真实性.
- 不存在性证明NSEC/NSEC3 记录):用于明确指示某个 DNS 记录不存在,防止攻击者伪造不存在的记录.
通过这些机制DNSSEC 建立了一条从根域开始的信任链,逐级验证每个域的 DNS 数据,确保其未被篡改且来源可信.
2. DNSSEC 的局限性
- 不加密数据内容DNSSEC 仅对 DNS 数据进行签名验证,并不加密查询和响应内容,因此无法防止数据被监听.
- 部署复杂性:​实施 DNSSEC 需要域名注册商、DNS 服务提供商和客户端解析器的共同支持,部署和维护相对复杂.
- 性能影响由于引入了额外的签名验证过程DNSSEC 可能会增加 DNS 查询的响应时间和系统资源消耗.
3. DNSSEC 的优势
- 防止 DNS 欺骗和缓存投毒:​通过验证 DNS 数据的真实性DNSSEC 能有效防止攻击者伪造 DNS 响应,将用户引导至恶意网站.
- 增强互联网基础设施安全性作为互联网信任体系的一部分DNSSEC 为其他安全协议(如 DANE提供基础支持.
## CDN的位置选择
Netlify在考虑到CDN成本以及可用性的情况下选择了以下这些地区以保证全球大部分访客访问他们的服务都能有不错的连接性和访问速度。
```
欧洲中部(德国法兰克福)
南美(巴西圣保罗)
美东(美国弗吉尼亚)
美西(美国旧金山)
亚洲(新加坡)
大洋洲(澳大利亚悉尼)
```
那么Netlify为什么会选择把CDN节点放到这些地区呢
1.弗吉尼亚,美东的弗吉尼亚被誉为“全球数据中心之都",美国政府对这个地区的网络投入非常大,使得弗吉尼亚的全球互联(美国本土、欧洲以及到南美洲)优秀。
2.旧金山,面向亚太和美西的访客。需要注意的是美西对亚太的网络连接比较优秀,但是到南美不太理想,甚至还有丢包的情况。
3.法兰克福,面向欧洲用户,德国法兰克福或者荷兰阿姆斯特丹都是不错的选择。
4.新加坡,亚太地区数据中心的枢纽,到印度、日本、越南、香港、中国移动的联通性都不错。
5.悉尼,土澳出了名的国际互联不太好,悉尼节点主要是服务本地和周边。
6.圣保罗,南美市场。
## 常见CDN的IP列表
> 需要注意的是有些CDN的回源IP并不用作节点IP比如Cloudflare的回源IP仅作回源IP使用如果要获取Cloudflare的节点IP可前往https://bgp.tools/as/13335#prefixes。而有些CDN的回源IP同时被用作CDN节点比如BunnyCDN和Gcore CDN。
Cloudflare
```
# https://www.cloudflare.com/ips-v4
103.21.244.0/22
103.22.200.0/22
103.31.4.0/22
104.16.0.0/13
104.24.0.0/14
108.162.192.0/18
131.0.72.0/22
141.101.64.0/18
162.158.0.0/15
172.64.0.0/13
173.245.48.0/20
188.114.96.0/20
190.93.240.0/20
197.234.240.0/22
198.41.128.0/17
# https://www.cloudflare.com/ips-v6
2400:cb00::/32
2405:8100::/32
2405:b500::/32
2606:4700::/32
2803:f800::/32
2a06:98c0::/29
2c0f:f248::/32
```
Gcore
```
https://api.gcore.com/cdn/public-ip-list
```
BunnyCDN
```
https://api.bunny.net/system/edgeserverlist
https://api.bunny.net/system/edgeserverlist/plain
```
Cloudfront
```
https://d7uri8nf7uskq.cloudfront.net/tools/list-cloudfront-ips
https://files.imunify360.com/static/whitelist/v2/cloudfront-cdn.txt
```
CDN77
```
https://files.imunify360.com/static/whitelist/v2/cdn77.txt
```
Fastly
```
https://api.fastly.com/public-ip-list
```
Keycdn
```
https://www.keycdn.com/shield-prefixes.json
```
quic.cloud
```
https://quic.cloud/ips
```
Google CDN
```
https://files.imunify360.com/static/whitelist/v2/google-cdn.txt
```
CacheFly
```
https://cachefly.cachefly.net/ips/cdn.txt
```
Akaima
```
https://techdocs.akamai.com/origin-ip-acl/docs/update-your-origin-server
```
---
**Done.**

View File

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

View File

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

103
content/Network-ssl.md Normal file
View File

@@ -0,0 +1,103 @@
+++
title = "网络艺术:SSL/TLS证书"
date = 2024-02-15
[taxonomies]
tags = ["Network"]
+++
前言 什么是SSL/TLS证书它有什么作用如何部署
<!-- more -->
## 什么是SSL/TLS证书
SSL 的全称是 ``Secure Sockets Layer``(安全套接字层),而 TLS 的全称是 ``Transport Layer Security``(传输层安全协议)。最初由 Netscape 开发的 SSL 协议用于保护网络通信,但由于其存在的安全漏洞,后来被更新、更安全的 TLS 协议所取代。
如今当我们谈论“SSL 证书”时,实际上指的是支持 TLS 协议的数字证书,``两者在功能上没有本质区别,只是在命名上沿用了历史传统``。该证书是由受信任的数字证书颁发机构 CA在验证服务器身份后颁发且具有服务器身份验证和数据传输加密功能。简单来说就是``HTTP+SSL/TLS证书=HTTPS.``
## SSL证书是如何工作的
- 当我们点击一个超链接HTTP浏览器帮我们跳转到新标签页
- 通过DNSDomain name system查询找到该域名地址栏中的如www.xxx.com之类的字符对应的IP地址可能是某个CDN的地址
- 服务器上已经配置好certificate.crt公钥和private.key私钥
- CDN随后与真正的服务器建立连接服务器上的反向代理可能是nginx或者caddy检测连接并用配置好的证书将连接升级为HTTPS
- HTTPS握手并将内容显示在浏览器上。
## SSL/TLS证书的握手过程
- 客户端发送"ClientHello"消息包含支持的加密算法和TLS版本
- 服务器回应"ServerHello"消息选择加密算法并发送SSL/TLS证书
- 客户端验证证书的有效性(通过内置的CA根证书)
- 客户端使用服务器公钥加密一个"预主密钥"并发送给服务器;
- 双方根据预主密钥生成会话密钥;
- 使用会话密钥进行加密通信;
- 加密通信:握手完成后,所有数据传输都使用协商好的对称密钥加密。
> 使用公钥加密的数据只能用对应的私钥解密,使用私钥加密(签名)的数据可以用对应的公钥验证。
> 客户端和服务器都支持非常多的密码套件比如“ECDHE-RSA-AES256-GCM-SHA384”。格式是“密钥交换算法 + 签名算法 + 对称加密算法 + 摘要算法”,这个密码套件的意思就是:“握手时使用 ECDHE 算法进行密钥交换,用 RSA 签名和身份认证,握手后的通信使用 AES 对称算法,密钥长度 256 位,分组模式是 GCM摘要算法 SHA384 用于消息认证和产生随机数。”
## CA证书
可以看到验证证书的有效性需要通过CA证书由CA机构如DigiCert
Let's Encrypt等颁布CA证书的层级结构如下
- 根CA证书最高级别的证书自签名是整个信任链的起点.
- 中间CA证书由根CA签发可以签发终端实体证书或其他中间CA证书.
- 终端实体证书由根CA或中间CA签发给网站、服务器等实体使用.
操作系统和浏览器``内置了受信任的根CA证书列表``,当验证网站证书时系统会沿着证书链向上追溯至根CA;如果能找到一个受信任的根CA且证书链上所有签名有效则验证通过.这就是保护我们上网安全的``信任链``的基础。
当我们访问网页时,往往会看到左上角的``锁``图标,里面是``Google Trust Services``或者``DigiCert Inc``等等代表证书的颁发来源。如果锁提示不安全可能是证书过期或者找不到CA证书即有可能是自签名证书。``什么是自签名证书?``
## 证书颁发
我们先来看证书颁发的流程。
- 证书申请:网站所有者向证书颁发机构(CA)申请SSL/TLS证书提供域名和组织信息。
- 身份验证CA验证申请者的身份和域名所有权。验证方式包括域名验证(DV)、组织验证(OV)或扩展验证(EV)。
- 证书签发验证通过后CA使用其私钥为申请者签发数字证书包含公钥、域名信息、颁发者信息和有效期等。
- 安装部署网站管理员将证书安装到Web服务器上。
可以看到过程有点麻烦,个人建站的话往往使用自签名证书,即``ssh-keygen``生成的公钥和私钥由于没有CA所以会显示不安全。
## 申请证书
- [sslforfree](https://www.sslforfree.com/)由 ZeroSSL 支持颁发的免费SSL证书.
- 通过[AMH](https://amh.sh/ssl.htm)提供的自助在线申请服务申请SSL通配符证书.需要注册AMH账号.
- [letsencrypt](https://letsencrypt.osfipin.com/)支持申请多渠道SSL证书.
- 借助[Punchsalad](https://punchsalad.com/ssl-certificate-generator/)提供的在线服务申请SSL证书无需登录仅需邮箱即可完成SSL通配符证书申请和签发.
## DV/OV/EV SSL证书的区别
以下是三种主要SSL证书验证类型的对比
| 特性 | 域名型SSL (DV SSL) | 企业型SSL (OV SSL) | 增强型SSL (EV SSL) |
|------|-------------------|-------------------|-------------------|
| **验证级别** | 最低 | 中等 | 最高 |
| **验证内容** | 仅验证域名所有权 | 验证域名所有权和组织信息 | 最严格的验证,包括法律、物理和运营存在的全面验证 |
| **验证流程** | 自动化验证邮件、DNS记录等 | 半自动验证 | 人工审核为主 |
| **签发时间** | 几分钟到数小时 | 1-3个工作日 | 5-7个工作日 |
| **浏览器显示** | 普通锁图标 | 普通锁图标 | 地址栏绿色显示(部分浏览器已取消) |
| **适用场景** | 个人博客、信息网站 | 企业网站、电子商务 | 银行、金融机构、大型电商 |
| **成本** | 低 | 中等 | 高 |
| **信任度** | 基本 | 中等 | 最高 |
| **证书信息** | 只包含域名信息 | 包含组织名称和域名 | 包含完整的组织详细信息 |
| **安全加密强度** | 相同 | 相同 | 相同 |
## 证书类型
有时候可以购买如``*.xxx.com``的通配符证书即一个证书通用与所有子域名。以及还有其他如多域名证书和上面提到的DV/OV/EV证书的类型。
| 证书类型 | 覆盖范围 | 安全级别 | 验证过程 | 适用场景 | 价格范围 |
|---------|---------|---------|---------|---------|---------|
| 单域名证书 | 仅一个特定域名 | 基本到高 | DV/OV/EV | 个人网站或小型企业 | 低到高 |
| 通配符证书 | 主域名及其所有一级子域名 | 基本到中等 | DV/OV | 拥有多个子域名的网站 | 中等到高 |
| 多域名证书(SAN) | 多个不同域名 | 基本到高 | DV/OV/EV | 管理多个不相关域名的企业 | 中等到高 |
| 自签名证书 | 任意 | 低 | 无需验证 | 测试环境、内部网络 | 免费 |
---
**Done.**

View File

@@ -1,112 +0,0 @@
+++
title = "网络艺术:Syncthing 使用指南"
date = 2025-04-17
[taxonomies]
tags = ["Network"]
+++
前言 在多设备使用的时代我们常常需要在电脑、服务器、笔记本之间同步文件。常见方案包括网盘、WebDAV、rsync 等,但这些方案要么依赖中心服务器、要么配置复杂、要么对实时性不友好。
<!-- more -->
## 介绍
**Syncthing** 是一款开源、去中心化、点对点P2P的文件同步工具主打 **安全、私有、实时同步**。与传统网盘不同Syncthing 不依赖任何中心服务器,所有数据直接在你的设备之间传输。
Syncthing 具有以下特点:
- ``去中心化``:设备之间点对点同步,不依赖第三方服务器;
- ``安全``:所有通信均使用 TLS 加密,并基于设备 ID 认证;
- ``跨平台``:支持 Windows、Linux、macOS、Android 等;
- ``实时同步``:文件变化可实时同步到其他设备;
- ``Web 管理界面``:通过浏览器即可完成绝大多数配置;
- ``开源``:代码完全开源,社区活跃。
## Windows
Windows 下推荐直接使用[SyncthingWindowsSetup](https://github.com/Bill-Stewart/SyncthingWindowsSetup)安装,会自动下载最新的syncthing二进制并设置系统服务。
- Web UI 默认地址:
```bash
http://127.0.0.1:8384
```
## Arch Linux
- 使用paru包管理器安装
```bash
paru -S syncthing
```
- 创建 systemd 用户服务
```bash
sudo systemctl enable --now syncthing@<你的用户名>.service
```
- 查看状态:
```bash
systemctl --user status syncthing.service
```
- Web UI 默认地址:
```bash
http://127.0.0.1:8384
```
## NixOS
NixOS 自带 Syncthing 模块,配置非常优雅。
```nix
{ lib, pkgs, username, ... }:
{
services.syncthing = {
enable = true;
user = username;
dataDir = "/home/${username}/Sync";
configDir = "/home/${username}/.config/syncthing";
guiAddress = "127.0.0.1:8384";
};
}
```
- 服务状态查看:
```bash
systemctl status syncthing.service
```
## 基本使用
Syncthing 的所有核心操作都可以通过 Web UI 完成,进入 Web UI 后先设置用户名和密码:
```bash
http://127.0.0.1:8384
```
### 添加设备
- 在本机和另一台设备上启动 Syncthing
- 分别设置同步文件夹注意ID要相同
- 复制对方的 **设备 ID**
- 在 Web UI 中点击「添加远程设备」;
- 双方确认后即可开始同步。
### 文件夹同步模式
Syncthing 支持多种同步模式:
* **Send & Receive**:双向同步(默认)
* **Send Only**:只向外同步
* **Receive Only**:只接收更改
---
**Done.**

View File

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

63
content/about-2024.md Normal file
View File

@@ -0,0 +1,63 @@
+++
title = "乱七八糟:2024年度总结"
date = 2025-01-04
[taxonomies]
tags = ["乱七八糟"]
+++
前言 又是新的一年,时间流速感觉越来越快了。
<!-- more -->
## 大事记
- 六月份暑假将家里大翻新,包括水晶头,吊灯,门锁,水龙头等等;
- 买了新柜子,房间更有序了;
- 和朋友们聚餐;
- 采用Mesh进行家庭组网
- 安装了一盏太阳能路灯,院子里更明亮了;
- 和父母看电影;
- 将博客迁移到新平台用上亚马逊CDN
- 更换域名,不再续费 .ink;
- 使用国家补贴更换电脑,换掉了故障百出的机械革命;
- 办理校园网套餐并注销掉旧的电话卡;
- 买了一台AX3000路由器并刷成openwrt绕过校园网检测
- 开了azure虚拟机并研究
- 卖掉了chromebook
- 配置了Qemu虚拟机
- 给父母加装了流量包;
- 更换了鼠标,并买了显示器和沙发椅;
- 家里更换新热水器;
- 修理亲戚家的网络问题;
- 在学校和家里两处配备常用药箱;
- 将所有设备更换为typec接口
- 整理并精简了RSS订阅源
- 重构了书签结构,增加用途分类;
- 用上了Android 15并使用多种开源软件
- 研究不同的root方案并完美隐藏环境
- 自制养生茶,咖啡和燕麦粥;
- 养成跑步习惯;
- 使用Deepl api进行翻译学习
- 看Netflix并研究浏览器环境检测
- 搭建Syncthing同步服务器实现三端同步
- 定时备份重要数据;
- 学习英语纪录片,每天背单词;
## 成长与反思
- 谋定而后动,不要冲动消费;
- 实践出真知,不要轻易下定论;
- 适合自己的才是最好的;
- 锻炼自身,早点睡觉,饮食规律是最好的养生;
## 新的一年的目标
- 在各大SRC平台挖点漏洞
- 封装一个完美的windows系统用于对外使用
- 研究并总结各大代理技术;
- 重构家庭数据中心;
- 学习一门新的语言并熟悉一种业务;
- 控制体重并研究低成本健身;

View File

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

View File

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

View File

@@ -0,0 +1,78 @@
+++
title = "乱七八糟:常见发音错误术语集合"
date = 2023-08-25
[taxonomies]
tags = ["乱七八糟"]
+++
前言 中文和英语发音习惯不同,容易引起误解。本文旨在帮助您准确发音常见的科技术语,欢迎随时补充。
<!-- more -->
**常见发音错误指南:公司/产品名**
- Youtube: 正确念法是 "You-tube" [tju:b],而不是 "优吐毙",应该是 "优tiu啵"。
- Skype: 应该念为 [ˈskaɪp],而不是 "死盖屁",应该是 "死盖破"。
- Adobe: 正确的发音是 [əˈdəʊbi],不是 "阿斗伯",而是 "阿兜笔"。
- C#: 应该念为 "C Sharp",即"C煞破"。
- GNU: 正确的发音是 [(g)nuː] 即"哥怒"。
- GUI: 应该念为 [ˈɡui],即"故意"。
- JAVA: 正确的发音是 [ˈɑːvə],而不是 "夹蛙",应该是 "扎蛙"。
- AJAX: 应该念为 [ˈeɪdʒæks],而不是 "阿贾克斯",应该是 "诶(ei) 贾克斯"。
- Ubuntu: 正确的发音是 [uˈbuntuː],而不是 "友邦兔",应该是 "巫不恩兔"。
- Debian: 应该念为 [ˈdɛbiən],即"得(dei)变"。
- Linux: 正确的发音有两种,[ˈlɪnəks] 或 [ˈlɪnʊks]"丽娜克斯" 或 "李扭克斯"都可以。
- LaTeX: 正确的发音是 [ˈleɪtɛk] 或 [ˈleɪtɛx] 或 [ˈlɑːtɛx] 或 [ˈlɑːtɛk],即"雷泰克" 或 "拉泰克"。
- GNOME: 念法可以是 [ɡˈnoʊm] 或 [noʊm],即"格弄姆" 或 "弄姆"。
- App: 应该念为 [ˈæp],即 "阿破"。
- null: 正确的发音是 [nʌl],即"闹"。
- jpg: 应该念为 [ˈdʒeɪɡ],而不是 "勾屁记",应该是 "zhei派个"。
- WiFi: 正确的发音是 [ˈwaɪfaɪ],即"歪fai"。
- mobile: 念法可以是 [moˈbil] 或 [ˈmoˌbil] 或 [ˈməubail],即"膜拜哦" 或 "牟bou"。
- integer: 正确的发音是 [ˈɪntɪdʒə],而不是 "阴太阁儿",应该是 "音剃摺儿"。
- cache: 应该念为 [kæʃ],而不是 "卡尺",即"喀什"。
- @: 应该念为 "at"。
- Tumblr: 应该念为 "Tumbler",而不是 "贪不勒"。
- nginx: 正确的发音是 "Engine X",应该是 "恩静 爱克斯"。
- Apache: 应该念为 [əˈpætʃiː],即"阿趴气"。
- Lucene: 正确的发音是 [ˈluːsin],即"鲁信"。
- MySQL: 应该念为 [maɪ ˌɛskjuːˈɛl] 或 [maɪ ˈsiːkwəl],可以是 "买S奎儿" 或 "买 吸扣"。
- Exposé: 念法可以是 [ɛksˈpəʊzeɪ]重音在Z上。
- RFID: 官方念法是四个字母分开读 "R F I D"。
- JSON: 应该念为 "jason",即"zhei森"。
- Processing: 重音在 "Pro" 上。
- avatar: 正确的发音是 [ˌævə'tɑr],即"艾瓦塌儿"。
## 后记
虽然许多的词汇常常被错误发音但在中国遵守拼音原则是入乡随俗的一种表现且往往并没有所谓的官方读法不必太过于纠结100%纯正的读法。

View File

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

View File

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

View File

@@ -173,31 +173,6 @@ tags = ["乱七八糟"]
- [离散数学-东北大学](https://www.bilibili.com/video/BV1d7411v7zu/?spm_id_from=333.999.0.0&vd_source=cc4bfbaa0f8c6c363ff9afecce036d91) - [离散数学-东北大学](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) - [统计学-个人 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) - [中国人民大学:西方哲学史-张志伟](https://www.bilibili.com/video/BV1y64y1r7Mt/?spm_id_from=333.337.search-card.all.click&vd_source=cc4bfbaa0f8c6c363ff9afecce036d91)
@@ -231,4 +206,4 @@ tags = ["乱七八糟"]
- [每个程序员都应该知道的内存知识 (带你走读 Ulrich Drepper 的经典论文)](https://www.bilibili.com/video/BV1Xy4y1b7SK/) - [每个程序员都应该知道的内存知识 (带你走读 Ulrich Drepper 的经典论文)](https://www.bilibili.com/video/BV1Xy4y1b7SK/)
## 后记 ## 后记
待续... 待续...

View File

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

View File

@@ -6,203 +6,451 @@ date = 2023-12-15
tags = ["乱七八糟"] tags = ["乱七八糟"]
+++ +++
前言 Git作为现代软件开发中不可或缺的版本控制工具常常让初学者感到困惑。本文旨在介绍 Git 的全流程安装和基本使用,希望能够帮助新手更轻松地理解和掌握 Git 的基本概念和操作。 前言 Git作为现代软件开发中不可或缺的版本控制工具常常让初学者感到困惑。本文旨在介绍 Git 的全流程安装和基本使用,希望能够帮助新手更轻松地理解和掌握 Git 的基本概念和操作。
<!-- more --> <!-- 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 github.com
HostName github.com
User git
IdentityFile ~/.ssh/github
# Gitee
Host gitee gitee.com
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仓库的目录里面包括``工作目录``(即我们要追踪的代码)以及``.git``目录Git 在这里存储自己的数据。Git 维护了三棵“树”:第一个是你的 `工作目录`,它持有实际文件;第二个是 `暂存区Index`,它像个缓存区域,临时保存你的改动;最后是 `HEAD`,它指向你最后一次提交的结果。
![git-tree](http://marklodato.github.io/visual-git-guide/basic-usage.svg.png) ![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/ .git/
├── HEAD ├── HEAD
├── config ├── config
@@ -223,113 +471,95 @@ feat:add_highlight
│ └── tags/ │ └── 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 * **logs/**:记录了引用(如分支、标签)的更新历史,有助于追踪操作记录。
sudo pacman -S gnupg //安装 GPG
gpg --full-generate-key //生成 GPG 密钥 * **objects/**:存储 Git 的所有对象,包括:
gpg --list-secret-keys --keyid-format=long //查看你生成的密钥 ID
git config --global user.signingkey ABCDEF1234567890 //让 Git 使用该密钥签名 * **blob**:文件内容。
git config --global commit.gpgsign true //启用自动签名所有提交 * **tree**:目录结构。
gpg --armor --export ABCDEF1234567890 //导出公钥并添加到 GitHub * **commit**:提交对象,记录提交信息和指向的树对象。
* **tag**:标签对象。
这些对象以 SHA-1 哈希命名,前两位作为子目录,其余作为文件名。
* **refs/**:存储所有引用,包括:
* **heads/**:本地分支。
* **remotes/**:远程分支。
* **tags/**:标签。
## Commit规范
### 提交信息的基本格式
- Header头部
格式:
``` ```
然后前往``GitHub → Settings → SSH and GPG keys → New GPG key``粘贴并保存。 <type>[可选的 scope]: <简短描述>
- 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 表示提交类型feat新功能、fix修复bug等。
scope 是可选的,用于指出变更影响的模块或范围。
简短描述 用于概述本次提交的核心内容,通常使用祈使语气。
比如你修改了项目中的``fs/proc/base.c``,然后 - Body正文
用于详细说明变更的动机、方法以及可能的影响,建议每行不超过 72 个字符。
```bash - Footer脚注
git add fs/proc/base.c 可选部分,用来引用相关 issue、任务或说明破坏性变更例如BREAKING CHANGE: ...)。例如:
git commit -m "fix:base"
git format-patch origin/16.0
```
即可在目录下生成补丁``0001-fix-base.patch``.
### 删除前一个提交记录
有时候手滑或者不想使用一个commit说明可以用以下命令撤销上一个 commit
```bash
git reset --soft HEAD~1
```
这个命令会撤销上一个 commit但保留文件修改代码仍然在工作区。适用于 想要重新提交amend或调整 commit 的情况。
如果你想彻底删除更改(不保留代码修改),可以使用:
```bash
git reset --hard HEAD~1
```
### 教学复习
``` ```
0. 如何配置Git Fixes #123
1. 为什么Git协作的时候往往是fork别人的仓库能不能直接在原仓库里面修改
2. fork完如何修改并提交更改
3. git clone 的 http 链接和 git 链接有什么不同?
4. 如何将修改合并到原仓库?
5. 如何合并发PR
6. 如何查看状态和日志
``` ```
这可以在提交后自动关闭相关问题。
### 常见的 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.** **Done.**

View File

@@ -1,124 +0,0 @@
+++
title = "乱七八糟:Github的使用"
date = 2025-08-24
[taxonomies]
tags = ["乱七八糟"]
+++
前言 对于GitHub相信我们都不陌生。本文介绍GitHub上许多好用的服务和资源。
<!-- more -->
## Github Gist
GitHub Gist 是 GitHub 提供的代码片段服务,用来``存放单个或少量文件的代码/文本``(如示例代码、配置片段、日志、临时笔记等)。
官方说明是
```
Instantly share code, notes, and snippets.
```
和 repo 相同的是gist 也分为``public``和``private``
我们可以从一个简单的书签同步服务来实践:
1. 创建一个gist权限为 private; 随后可以看到类似``Dichgrem / gist:37f2ebad89923d49d8854c368d7f5c91``gist后面这一串就是GistID
2. 在这个[界面](https://github.com/settings/tokens)创建一个token选择开启gist权限
3. 安装这个书签同步[浏览器扩展](https://www.github.com/dudor/BookmarkHub)
3. 将tokens 和 前面的 GistID 复制到这个浏览器扩展中;
4. 随后可以使用这个插件进行书签同步。
> 原理使用浏览器api提取出书签向 gist 仓库进行上传gist仓库验证 tokens 后保存,在另一个浏览器中用同样的插件进行下载,即可同步.
## GitHub Pages
GitHub Pages 是 GitHub 提供的静态托管服务,常常用于快速部署纯前端网站。
比如你有一个 Vue 写的网站仓库,在该仓库的``设置-Build and deployment``下选择source选择分支并将public目录部署到GitHub Pages随后会得到一个类似dichgrem.github.io 的域名,即可看到网站。
当然你也可以绑定自己的域名在custom dommain下添加并在你的dns解析处添加对应的CNAME记录。
> 具体流程可以参考Hexo的[文档](https://hexo.io/zh-cn/docs/github-pages)
> GitHub Pages 的限制
- 不能运行后端代码
- 站点大小有限制
- 构建和发布有时间限制
- 私有仓库 Pages 需要付费计划
## Github actions
GitHub Actions 是 GitHub 提供的 CI/CD 与自动化平台,用于``在代码仓库中自动执行任务,比如测试、构建、发布、部署``等。
听起来有点抽象实际上就是在仓库的这个位置放入一个yml文件 ``.github/workflows/*.yml``,比如
```bash
name: C Build
on:
push:
pull_request:
workflow_dispatch:
jobs:
build-and-run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Show compiler version
run: gcc --version
- name: Build
run: gcc -O2 -Wall -Wextra -std=c11 -o app main.c
- name: Run
run: ./app
```
这个文件的意思就是
- 触发条件push / pull_request / 手动触发
- actions/checkout@v4:拉取仓库代码
- gcc ... main.c将main.c编译成产物 app
- ./app运行确保编译出来的程序能执行
把本地的环境迁移到github的runner中这样做有几个好处
- 统一了编译环境,不用考虑开发成员之间的环境区别;
- 将构建自动化,开发者可以专注于代码,新人也可以快速上手;
- 自动发布到release极大方便了项目管理;
- GitHub Actions提供许多现有的steps类似乐高积木的体验;
> GitHub Actions的限制
- public仓库通常没有限制
- privat仓库为2,000 分钟500 MB
## GitHub Copilot
从11月起GitHub首页增加了AI对话功能调用的就是 [GitHub Copilot](https://github.com/features/copilot)。
GitHub Copilot 是一个 AI 驱动的 智能编码助手,由 GitHub 和 OpenAI 联合开发。可以调用GPT/gemini/Claude等多家模型.
你可以在vscode中下载copilot插件并使用它会给你带来自动补全以及按照上下文生成整段代码的功能.
> 现在copilot已经开源并且在vscode中自带直接登录就可以使用无须手动下载.
> GitHub Copilot的限制
- 免费版本约 2,000 次代码自动完成completions —— 即 Copilot 在 IDE 里根据你的输入生成代码的次数。
- 约 50 次 Copilot Chat 消息 / 会话请求 —— 即和 Copilot Chat 对话或高级问答次数。
---
**Done.**

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,29 +1,95 @@
+++ +++
title = "乱七八糟:VScode那些事" title = "乱七八糟:常用实用快捷键"
date = 2024-05-23 date = 2024-05-23
[taxonomies] [taxonomies]
tags = ["乱七八糟"] tags = ["乱七八糟"]
+++ +++
前言 VScode 素有世界最强IDE之称有着丰富的插件系统优秀的图形界面和极快的响应速度本文介绍VSCode的一些使用技巧 前言 在日常使用浏览器时,掌握一些快捷键和技巧可以节省大量时间,提高工作和学习效率。通过学习和实践,能够更加轻松地应对各种网页浏览场景,让浏览器成为工作和学习的得力助手
<!-- more --> <!-- more -->
## AI 插件 ## 浏览器快捷键
| 插件名 | 免费 | 付费 | 单模型 | 多模型 | 说明 | ### 常用
| ---------------------------------------------------------------------------------------- | :-----------: | :--------: | :-: | :-: | ------------------------------------------------------- |
| **[GitHub Copilot](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot)** | ✔️(试用 / 学生优惠) | ✔️ | | ✔️ | 主流 AI 编码助手,支持代码补全和聊天建议。([Visual Studio Marketplace][1]) | | 快捷键 | 描述 |
| **[GPT (ChatGPT)](https://open-vsx.org/extension/openai/chatgpt)** | ✔️ | ✔API 模型) | ❌ | ✔️ | 基于 OpenAI 的 ChatGPT可做代码解释/对话生成 | |----------------------|------------------|
| **[Gemini Code Assist](https://open-vsx.org/extension/Google/geminicodeassist)** | ✔️ | | ❌ | ✔️ | Google Gemini 驱动的智能编码助手 | | Ctrl + A | 全选 |
| **[Claude Code](https://open-vsx.org/extension/Anthropic/claude-code)** | ❓(账户权限) | ✔️ | ❌ | ✔️ | Anthropic Claude 驱动的编码助手 | | Ctrl + C | 复制 |
| **[Cline (claude-dev)](https://open-vsx.org/extension/saoudrizwan/claude-dev)** | ✔️ | | ❌ | ✔️ | 社区版 Claude 型 AI 编码插件 | | Ctrl + X | 剪切 |
| **[CodeGeeX](https://open-vsx.org/extension/AMiner/codegeex)** | ✔️ | ❌ | ❌ | ✔️ | 开源多模型 AI код助手 | | Ctrl + V | 粘贴 |
| **[OpenCode](https://open-vsx.org/extension/sst-dev/opencode)** | ✔️ | ❌ | ❌ | ✔️ | 多模型聚合,可接多种后端 | | Ctrl + F | 查找 |
| **[Windsurf (Codeium)](https://open-vsx.org/extension/Codeium/codeium)** | ✔️ | ❌ | ❌ | ✔️ | 轻量级 AI 代码补全助手Codeium 改名) | | Ctrl + Q | 退出 |
| Ctrl + T | 新建标签页 |
| Ctrl + W | 关闭标签页 |
| Ctrl + N | 新建窗口 |
| Ctrl + Shift + P | 新建隐私浏览窗口 |
### 历史
| 快捷键 | 描述 |
|-------------------------|----------------------------|
| Ctrl + H | 历史侧栏 |
| Ctrl + Shift + H | 我的足迹窗口(历史) |
| Ctrl + Shift + Del | 清除最近历史记录 |
### 书签
| 快捷键 | 描述 |
|-------------------------------|------------------------------------|
| Ctrl + D | 将此页加为书签 |
| Ctrl + I | 页面信息 |
| Ctrl + Shift + O | 显示全部书签(我的足迹窗口) |
| Ctrl + B / Ctrl + Shift + B | 书签侧栏 / 顶栏 |
### 下载与插件
| 快捷键 | 描述 |
|----------------------|----------------|
| Ctrl + Shift + Y | 下载 |
| Ctrl + Shift + A | 附加组件 / 插件 |
### 控制台与开发
| 快捷键 | 描述 |
|----------------------|------------------|
| Ctrl + Shift + K | Web 控制台 |
| Ctrl + Shift + C | 查看器 |
| Shift + F7 | 样式编辑器 |
| Shift + F5 | 分析器 |
| Ctrl + Shift + E | 网络 |
| Ctrl + U | 页面源码 |
| Ctrl + Shift + J | 浏览器控制台 |
### 标签页与界面
| 快捷键 | 描述 |
|-------------------------------|--------------------------|
| Ctrl + S | 界面保存 |
| Ctrl + + | 放大 |
| Ctrl + - | 缩小 |
| Ctrl + 0 | 重置缩放 |
| Ctrl + K / J | 搜索 |
| Ctrl + Home / End | 到文件头 / 尾 |
| Ctrl + Page Up | 切换到左边标签页 |
| Ctrl + Page Down | 切换到右边标签页 |
| Ctrl + Shift + Page Up | 当前标签页左移 |
| Ctrl + Shift + Page Down | 当前标签页右移 |
### 其他操作
| 快捷键 | 描述 |
|--------------------|------------------|
| Alt + Space | KDE 搜索栏 |
| Alt + → / ← | 前进 / 后退 |
| Alt + 数字键 | 选择标签页18|
| Alt + M | 静音 |
| End | 到达页尾 |
| Home | 到达页首 |
| F6 | 地址栏 |
[1]: https://marketplace.visualstudio.com/items?itemName=GitHub.copilot&utm_source=chatgpt.com "GitHub Copilot"
## VS Code 快捷键 ## VS Code 快捷键
@@ -236,87 +302,5 @@ tags = ["乱七八糟"]
- **函数提示** - **函数提示**
- 在悬停窗口上按下 `cmd`:提示函数的实现 - 在悬停窗口上按下 `cmd`:提示函数的实现
## 浏览器快捷键
### 常用
| 快捷键 | 描述 |
|----------------------|------------------|
| Ctrl + A | 全选 |
| Ctrl + C | 复制 |
| Ctrl + X | 剪切 |
| Ctrl + V | 粘贴 |
| Ctrl + F | 查找 |
| Ctrl + Q | 退出 |
| Ctrl + T | 新建标签页 |
| Ctrl + W | 关闭标签页 |
| Ctrl + N | 新建窗口 |
| Ctrl + Shift + P | 新建隐私浏览窗口 |
### 历史
| 快捷键 | 描述 |
|-------------------------|----------------------------|
| Ctrl + H | 历史侧栏 |
| Ctrl + Shift + H | 我的足迹窗口(历史) |
| Ctrl + Shift + Del | 清除最近历史记录 |
### 书签
| 快捷键 | 描述 |
|-------------------------------|------------------------------------|
| Ctrl + D | 将此页加为书签 |
| Ctrl + I | 页面信息 |
| Ctrl + Shift + O | 显示全部书签(我的足迹窗口) |
| Ctrl + B / Ctrl + Shift + B | 书签侧栏 / 顶栏 |
### 下载与插件
| 快捷键 | 描述 |
|----------------------|----------------|
| Ctrl + Shift + Y | 下载 |
| Ctrl + Shift + A | 附加组件 / 插件 |
### 控制台与开发
| 快捷键 | 描述 |
|----------------------|------------------|
| Ctrl + Shift + K | Web 控制台 |
| Ctrl + Shift + C | 查看器 |
| Shift + F7 | 样式编辑器 |
| Shift + F5 | 分析器 |
| Ctrl + Shift + E | 网络 |
| Ctrl + U | 页面源码 |
| Ctrl + Shift + J | 浏览器控制台 |
### 标签页与界面
| 快捷键 | 描述 |
|-------------------------------|--------------------------|
| Ctrl + S | 界面保存 |
| Ctrl + + | 放大 |
| Ctrl + - | 缩小 |
| Ctrl + 0 | 重置缩放 |
| Ctrl + K / J | 搜索 |
| Ctrl + Home / End | 到文件头 / 尾 |
| Ctrl + Page Up | 切换到左边标签页 |
| Ctrl + Page Down | 切换到右边标签页 |
| Ctrl + Shift + Page Up | 当前标签页左移 |
| Ctrl + Shift + Page Down | 当前标签页右移 |
### 其他操作
| 快捷键 | 描述 |
|--------------------|------------------|
| Alt + Space | KDE 搜索栏 |
| Alt + → / ← | 前进 / 后退 |
| Alt + 数字键 | 选择标签页18|
| Alt + M | 静音 |
| End | 到达页尾 |
| Home | 到达页首 |
| F6 | 地址栏 |
--- ---
**Done.** **Done.**

View File

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

View File

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

View File

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

View File

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

View File

@@ -29,40 +29,46 @@ tags = ["综合工程"]
## 安装软件 ## 安装软件
随后安装常用开源软件,KDE环境和Wayland+WM环境安装的包不同 随后安装常用开源软件(KDE环境省略file和wayland)
```bash ```
# gui # 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 scx-manager
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
# tui # tui
paru -S neovim yazi lazygit btop zellij termshark paru -S neovim yazi lazygit btop zellij termshark
# cli # cli
paru -S alacritty fastfetch onefetch starship atuin bat fzf fd ripgrep eza tree android-tools payload-dumper-go-bin nexttrace-bin syncthing aria2
# fish 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
fish tealdeer expac fish-autopair fish-pure-prompt fisher
# file
paru -S gvfs gvfs-mtp gvfs-afc gvfs-nfs nemo
# zip # zip
paru -S peazip paru -S peazip
# Type # Type
paru -S fcitx5-configtool fcitx5-skin-material fcitx5-rime fcitx5-gtk
paru -S fcitx5-configtool fcitx5-chinese-addons fcitx5-skin-material fcitx5-im fcitx5-rime
# Blog
paru -S zola npm pnpm just go
# ttf # ttf
paru -S ttf-jetbrains-mono-nerd ttf-sarasa-gothic-sc
```
如果使用Wayland+WM方案需要额外安装以下这些 paru -S ttf-jetbrains-mono-nerd
```bash
# Wayland # Wayland
paru -S hyprland waybar network-manager-applet swww wl-gammarelay-rs brightnessctl easyeffects wireplumber pipewire blueman bluez-utils wl-clipboard-rs wl-clip-persist swaync swayosd swappy grim wlogout hyprlock hyprpolkitagent
# file 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
paru -S gvfs gvfs-mtp gvfs-afc gvfs-nfs nemo
``` ```
| 分类 | 软件列表 | | 分类 | 软件列表 |
| ------------ | ------------------------------------------------ | | ------------ | ------------------------------------------------ |
| **窗口管理器** | hyprland | | **窗口管理器** | hyprland |
@@ -84,7 +90,7 @@ paru -S gvfs gvfs-mtp gvfs-afc gvfs-nfs nemo
输入法我们采用雾凇拼音即前面我们安装的fcitx5系列软件包的一个输入方案这里我们使用[自动部署脚本](https://github.com/Mark24Code/rime-auto-deploy) 输入法我们采用雾凇拼音即前面我们安装的fcitx5系列软件包的一个输入方案这里我们使用[自动部署脚本](https://github.com/Mark24Code/rime-auto-deploy)
```bash ```
# step1: 克隆/下载 latest 最新的稳定版到本地 # step1: 克隆/下载 latest 最新的稳定版到本地
git clone --depth=1 https://github.com/Mark24Code/rime-auto-deploy.git --branch latest git clone --depth=1 https://github.com/Mark24Code/rime-auto-deploy.git --branch latest
# step2: 进入项目目录 # step2: 进入项目目录
@@ -103,7 +109,7 @@ cd rime-auto-deploy
安装完毕后可以看到KDE的界面较为简陋这里给出笔者的美化配置 安装完毕后可以看到KDE的界面较为简陋这里给出笔者的美化配置
- 在设置中找到Colors&Themes分别设置为 - 在设置中找到Colors&Themes分别设置为
```bash ```
- ColorBreeze Dark - ColorBreeze Dark
- Application StyleBreeze - Application StyleBreeze
- Plasma StyleSweet - Plasma StyleSweet
@@ -158,27 +164,27 @@ V2EX PolishV站美化
如果Grub引导菜单中没有windows选项可以通过以下方法添加 如果Grub引导菜单中没有windows选项可以通过以下方法添加
- 安装 os-prober首先确保系统中安装了 os-prober这是一个用于检测其他操作系统的工具。 - 安装 os-prober首先确保系统中安装了 os-prober这是一个用于检测其他操作系统的工具。
```bash ```
sudo pacman -S os-prober sudo pacman -S os-prober
sudo os-prober sudo os-prober
``` ```
- 打开 /etc/default/grub 文件进行编辑: - 打开 /etc/default/grub 文件进行编辑:
```bash ```
sudo nano /etc/default/grub sudo nano /etc/default/grub
# 确保 GRUB_DISABLE_OS_PROBER 设置为 false # 确保 GRUB_DISABLE_OS_PROBER 设置为 false
``` ```
- 保存文件并退出编辑器后,运行以下命令更新 GRUB 配置: - 保存文件并退出编辑器后,运行以下命令更新 GRUB 配置:
```bash ```
sudo grub-mkconfig -o /boot/grub/grub.cfg sudo grub-mkconfig -o /boot/grub/grub.cfg
``` ```
或者``手动添加`` 或者``手动添加``
```bash ```
nano /etc/grub.d/40_custom nano /etc/grub.d/40_custom
``` ```
```bash ```
#!/bin/sh #!/bin/sh
exec tail -n +3 $0 exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the # This file provides an easy way to add custom menu entries. Simply type the
@@ -192,73 +198,32 @@ menuentry "Windows 11 (Manual)" {
chainloader /EFI/Microsoft/Boot/bootmgfw.efi chainloader /EFI/Microsoft/Boot/bootmgfw.efi
} }
``` ```
## 制服华硕VMD
华硕的BIOS有一个VMD选项它的机制是这样的如果你想安linux得先关闭VMD但如果你的windows是出厂自带的没有重装过那又得开启VMD否则无法进入windows这里记录在不关闭VMD的情况下如何让linux支持它(以arch linux为例)
先使用这个命令查看磁盘:
```
> lsblk -f
nvme1n1
├─nvme1n1p1 vfat FAT32 SYSTEM xxxx-xxxx
├─nvme1n1p2 ntfs OS
├─nvme1n1p3 ntfs 新加卷
├─nvme1n1p4 ntfs 新加卷
├─nvme1n1p5 ntfs 新加卷
├─nvme1n1p6 ntfs 新加卷
nvme0n1
├─nvme0n1p1
├─nvme0n1p2 ntfs 新加卷
└─nvme0n1p3 xfs xxxxxxxxxxxxxx
```
随后使用以下方法将VMD支持加入initramfs
```
## 挂载linux根分区
mount /dev/nvme0n1p3 /mnt
## 创建boot目录
mkdir -p /mnt/boot
## 挂载EFI
mkdir -p /mnt/boot/EFI
mount /dev/nvme1n1p1 /mnt/boot/EFI
## Chroot进入已经安装的系统
arch-chroot /mnt
## 重新生成 initramfs
nano /etc/mkinitcpio.conf
MODULES=(vmd nvme)
mkinitcpio -P
## 退出重启
exit
reboot
```
## Arch中安装QEMU虚拟机 ## Arch中安装QEMU虚拟机
前面我们已经安装了Qemu高性能虚拟机平台和virt-manager用来管理虚拟机的图形界面随后配置virt-manager并安装Ubuntu-server 前面我们已经安装了Qemu高性能虚拟机平台和virt-manager用来管理虚拟机的图形界面随后配置virt-manager并安装Ubuntu-server
如果virt-manager报错无法找到Qemu 如果virt-manager报错无法找到Qemu
- ​如果 libvirtd 服务未运行virt-manager 将无法连接到虚拟化环境。​ - ​如果 libvirtd 服务未运行virt-manager 将无法连接到虚拟化环境。​
```bash ```
sudo systemctl start libvirtd sudo systemctl start libvirtd
sudo systemctl enable libvirtd sudo systemctl enable libvirtd
``` ```
- 用户权限问题:​​将当前用户添加到 libvirt 组,以获得必要的权限。​ - 用户权限问题:​​将当前用户添加到 libvirt 组,以获得必要的权限。​
```bash ```
sudo usermod -aG libvirt $(whoami) sudo usermod -aG libvirt $(whoami)
``` ```
- 虚拟网络未激活virt-manager 可能无法连接到默认的虚拟网络。​ - 虚拟网络未激活virt-manager 可能无法连接到默认的虚拟网络。​
```bash ```
sudo virsh net-start default sudo virsh net-start default
``` ```
默认网络在系统启动时自动启动,可以执行: 默认网络在系统启动时自动启动,可以执行:
```bash ```
sudo virsh net-autostart default sudo virsh net-autostart default
``` ```
- 配置文件权限问题:​配置文件的权限设置可能导致访问问题。 - 配置文件权限问题:​配置文件的权限设置可能导致访问问题。
```bash ```
sudo chown $(whoami):libvirt /var/run/libvirt/libvirt-sock sudo chown $(whoami):libvirt /var/run/libvirt/libvirt-sock
``` ```
随后安装虚拟机,流程大概为``选择镜像和系统类型--设置CPU/内存--设置空间大小--编辑配置项--开启UEFI引导和3D加速``. 随后安装虚拟机,流程大概为``选择镜像和系统类型--设置CPU/内存--设置空间大小--编辑配置项--开启UEFI引导和3D加速``.
@@ -266,7 +231,7 @@ sudo chown $(whoami):libvirt /var/run/libvirt/libvirt-sock
**开启3D加速** **开启3D加速**
- NIC - NIC
```xml ```
<graphics type="spice"> <graphics type="spice">
<listen type="none"/> <listen type="none"/>
<image compression="off"/> <image compression="off"/>
@@ -275,7 +240,7 @@ sudo chown $(whoami):libvirt /var/run/libvirt/libvirt-sock
``` ```
- video virtio - video virtio
```xml ```
<video> <video>
<model type="virtio" heads="1" primary="yes"> <model type="virtio" heads="1" primary="yes">
<acceleration accel3d="yes"/> <acceleration accel3d="yes"/>
@@ -290,17 +255,17 @@ sudo chown $(whoami):libvirt /var/run/libvirt/libvirt-sock
如果安装了多个linux内核可以使用以下方法调整启动顺序 如果安装了多个linux内核可以使用以下方法调整启动顺序
- 使用以下命令查看内核名称: - 使用以下命令查看内核名称:
```bash ```
ls /boot/vmlinuz* ls /boot/vmlinuz*
``` ```
- 在 /etc/default/grub 中添加或修改如下行: - 在 /etc/default/grub 中添加或修改如下行:
```bash ```
GRUB_TOP_LEVEL="/boot/vmlinuz-linux-cachyos" GRUB_TOP_LEVEL="/boot/vmlinuz-linux-cachyos"
``` ```
需要注意,这种方法会关闭 GRUB 的“记住上次启动项”的功能。 需要注意,这种方法会关闭 GRUB 的“记住上次启动项”的功能。
- 修改完 /etc/default/grub 后,记得重新生成 GRUB 配置文件: - 修改完 /etc/default/grub 后,记得重新生成 GRUB 配置文件:
```bash ```
sudo grub-mkconfig -o /boot/grub/grub.cfg sudo grub-mkconfig -o /boot/grub/grub.cfg
``` ```
**图形界面更改方法:** **图形界面更改方法:**
@@ -308,12 +273,12 @@ sudo grub-mkconfig -o /boot/grub/grub.cfg
可以使用grub-customizer来修改Grub这里以ubuntu为例子 可以使用grub-customizer来修改Grub这里以ubuntu为例子
- 添加PPA源并更新软件列表 - 添加PPA源并更新软件列表
```bash ```
sudo add-apt-repository ppa:danielrichter2007/grub-customizer sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt update sudo apt update
``` ```
- 安装GRUB Customizer - 安装GRUB Customizer
```bash ```
sudo apt install grub-customizer sudo apt install grub-customizer
``` ```
随后在grub-customizer中将要默认启动的选项放在首位即可。 随后在grub-customizer中将要默认启动的选项放在首位即可。
@@ -321,24 +286,24 @@ sudo apt install grub-customizer
## 开机自启动 ## 开机自启动
**设置Syncthing开机自启动** **设置Syncthing开机自启动**
```bash ```
sudo systemctl enable --now syncthing@<username>.service sudo systemctl enable --now syncthing@<username>.service
``` ```
**设置Aria2开机自启动** **设置Aria2开机自启动**
```conf ```
[Unit] [Unit]
Description=Aria2c - lightweight multi-protocol & multi-source command-line download utility Description=Aria2c - lightweight multi-protocol & multi-source command-line download utility
After=network.target After=network.target
[Service] [Service]
User=<username> User=dich
Group=<groupname> Group=dich
WorkingDirectory=/home/<username> WorkingDirectory=/home/dich
Environment=HOME=/home/<username> Environment=HOME=/home/dich
Environment=USER=<username> Environment=USER=dich
ExecStart=/usr/bin/aria2c --conf-path=/home/<username>/.config/aria2/aria2.conf ExecStart=/usr/bin/aria2c --conf-path=/home/dich/.config/aria2/aria2.conf
Restart=always Restart=always
NoNewPrivileges=true NoNewPrivileges=true
PrivateTmp=true PrivateTmp=true
@@ -350,56 +315,59 @@ WantedBy=multi-user.target
## 开启BBR ## 开启BBR
- 确保你的内核版本 >= 4.9 - 确保你的内核版本 >= 4.9
```bash ```
uname -r uname -r
``` ```
- 启用 BBR - 启用 BBR
你只需要设置两个 sysctl 参数即可: 你只需要设置两个 sysctl 参数即可:
```bash ```
sudo sysctl -w net.core.default_qdisc=fq sudo sysctl -w net.core.default_qdisc=fq
sudo sysctl -w net.ipv4.tcp_congestion_control=bbr sudo sysctl -w net.ipv4.tcp_congestion_control=bbr
``` ```
要让它们永久生效,把它们写入配置文件: 要让它们永久生效,把它们写入配置文件:
```bash ```
sudo nano /etc/sysctl.d/99-bbr.conf sudo nano /etc/sysctl.d/99-bbr.conf
``` ```
加入以下内容: 加入以下内容:
```bash ```
net.core.default_qdisc = fq net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr net.ipv4.tcp_congestion_control = bbr
``` ```
然后重新加载配置: 然后重新加载配置:
```bash ```
sudo sysctl --system sudo sysctl --system
``` ```
- 验证 BBR 是否启用 - 验证 BBR 是否启用
```bash ```
sysctl net.ipv4.tcp_congestion_control sysctl net.ipv4.tcp_congestion_control
``` ```
应该输出: 应该输出:
```bash ```
net.ipv4.tcp_congestion_control = bbr net.ipv4.tcp_congestion_control = bbr
``` ```
## 性能模式切换 ## 性能模式切换
需要安装``tlp-git tlp-pd-git tlp-rdw-git`` 需要安装``power-profiles-daemon``
```bash ```
# 查看当前状态 # 查看可用的电源配置文件profiles
tlp-stat -s powerprofilesctl list
# 查看当前正在使用的 profile
powerprofilesctl get
# 切换到“性能”模式 # 切换到“性能”模式
sudo tlp performance sudo powerprofilesctl set performance
# 切换到“平衡”模式 # 切换到“平衡”模式
sudo tlp balanced sudo powerprofilesctl set balanced
# 切换到“省电”模式 # 切换到“省电”模式
sudo tlp power-saver sudo powerprofilesctl set power-saver
``` ```
## 其他可选性能优化 ## 其他性能优化
```bash ```
Profilesyncdaemon Profilesyncdaemon
将浏览器配置文件和缓存挂载到内存,退出时再写回磁盘: 将浏览器配置文件和缓存挂载到内存,退出时再写回磁盘:
@@ -427,7 +395,7 @@ sudo systemctl enable --now ananicy-cpp
## 常用命令 ## 常用命令
```bash ```
更新系统sudo pacman -Syu 更新系统sudo pacman -Syu
重新安装所有软件包sudo pacman -Qq | sudo pacman -S - 重新安装所有软件包sudo pacman -Qq | sudo pacman -S -
@@ -458,28 +426,28 @@ sudo reflector --latest 10 --sort rate --save /etc/pacman.d/mirrorlist
## 在Arch Linux上安装Docker ## 在Arch Linux上安装Docker
一般推荐在qemu虚拟机中安装这里仅做示例 一般推荐在qemu虚拟机中安装这里仅做示例
```bash ```
sudo pacman -S docker sudo pacman -S docker
``` ```
安装完成后需要启动Docker服务并设置为开机自启 安装完成后需要启动Docker服务并设置为开机自启
```bash ```
sudo systemctl start docker sudo systemctl start docker
sudo systemctl enable docker sudo systemctl enable docker
``` ```
运行以下命令来验证Docker是否正常工作 运行以下命令来验证Docker是否正常工作
```bash ```
sudo docker run hello-world sudo docker run hello-world
``` ```
默认情况下只有root用户才能运行Docker命令。为了避免每次运行Docker命令时都需要使用sudo可以将当前用户添加到docker组 默认情况下只有root用户才能运行Docker命令。为了避免每次运行Docker命令时都需要使用sudo可以将当前用户添加到docker组
```bash ```
sudo usermod -aG docker $USER sudo usermod -aG docker $USER
``` ```
之后,需要注销并重新登录,或者重启系统以使更改生效。 之后,需要注销并重新登录,或者重启系统以使更改生效。
安装Docker Compose 安装Docker Compose
```bash ```
sudo pacman -S docker-compose sudo pacman -S docker-compose
``` ```
--- ---

View File

@@ -129,7 +129,7 @@ uci commit luci
- **编译依赖** - **编译依赖**
```bash ```
sudo apt update sudo apt update
sudo apt install -y \ sudo apt install -y \
ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \ 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 autoremove --purge
sudo apt clean sudo apt clean
``` ```
- **新建一个用户,用于编译固件(可选)** - **新建一个用户,用于编译固件(可选)**
```bash ```
useradd -m openwrt # 新建一个名为 openwrt 的用户 useradd -m openwrt # 新建一个名为 openwrt 的用户
``` ```
> 不可以使用Root用户进行编译!!! > 不可以使用Root用户进行编译!!!
- **修改用户默认的 Shell** - **修改用户默认的 Shell**
```bash ```
apt install -y sudo apt install -y sudo
usermod -s /bin/bash openwrt usermod -s /bin/bash openwrt
``` ```
- **切换用户** - **切换用户**
```bash ```
su openwrt su openwrt
cd ~ cd ~
``` ```
- **拉取源码,这里用的是 ImmortalWrt 24.10 分支源码:** - **拉取源码,这里用的是 ImmortalWrt 24.10 分支源码:**
```bash ```
git clone https://github.com/immortalwrt/immortalwrt.git git clone https://github.com/immortalwrt/immortalwrt.git
cd immortalwrt cd immortalwrt
``` ```
@@ -180,11 +180,11 @@ cd immortalwrt
- **选择分支** - **选择分支**
如果你想要编译稳定版(stable),使用 如果你想要编译稳定版(stable),使用
```bash ```
git checkout xxx #例如git checkout v24.10.2 git checkout xxx #例如git checkout v24.10.2
``` ```
如果你想要编译最新版(snapshot),使用 如果你想要编译最新版(snapshot),使用
```bash ```
git switch xxx #例如git switch openwrt-24.10 git switch xxx #例如git switch openwrt-24.10
``` ```
@@ -211,19 +211,19 @@ git switch xxx #例如git switch openwrt-24.10
- **添加软件源,可自行添加软件源至 feeds.conf.default 文件** - **添加软件源,可自行添加软件源至 feeds.conf.default 文件**
```bash ```
vim feeds.conf.default vim feeds.conf.default
``` ```
**常用源** **常用源**
```bash ```
src-git kenzo https://github.com/kenzok8/openwrt-packages src-git kenzo https://github.com/kenzok8/openwrt-packages
src-git small https://github.com/kenzok8/small src-git small https://github.com/kenzok8/small
src-git haibo https://github.com/haiibo/openwrt-packages src-git haibo https://github.com/haiibo/openwrt-packages
src-git liuran001 https://github.com/liuran001/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_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_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 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 git clone https://github.com/chenmozhijin/turboacc.git
``` ```
- **更新并安装插件** - **更新并安装插件**
```bash ```
./scripts/feeds clean ./scripts/feeds clean
./scripts/feeds update -a ./scripts/feeds update -a
./scripts/feeds install -a ./scripts/feeds install -a
@@ -251,7 +251,7 @@ git clone https://github.com/chenmozhijin/turboacc.git
- **自定义配置** - **自定义配置**
```bash ```
#!/usr/bin/env bash #!/usr/bin/env bash
# diy-part2.sh — 在镜像生成时注入默认设置和定制 SSH 横幅及模型修复 # diy-part2.sh — 在镜像生成时注入默认设置和定制 SSH 横幅及模型修复
@@ -319,7 +319,7 @@ chmod +x package/base-files/files/etc/uci-defaults/99-model-fix
### **编译配置菜单说明(部分)** ### **编译配置菜单说明(部分)**
```bash ```
Target System (x86) # 选择目标平台 Target System (x86) # 选择目标平台
└── Subtarget (x86_64) # 选择 64-bit 子架构 └── Subtarget (x86_64) # 选择 64-bit 子架构
└── Target Profile (Generic) # “Generic” 表示通用 x86_64 设备 └── Target Profile (Generic) # “Generic” 表示通用 x86_64 设备
@@ -369,21 +369,21 @@ Xorg # 桌面环境支持X11 图形系统)
``` ```
- **预下载编译所需的软件包** - **预下载编译所需的软件包**
```bash ```
make download -j8 make download -j8
``` ```
- **检查文件完整性** - **检查文件完整性**
```bash ```
find dl -size -1024c -exec ls -l {} \; find dl -size -1024c -exec ls -l {} \;
``` ```
检查文件完整性命令可以列出下载不完整的文件小于1k的文件属于下载不完整如果存在则用下面的命令删除然后重新下载编译所需的软件包再次检查.确认所有文件完整可大大提高编译成功率,避免浪费时间 检查文件完整性命令可以列出下载不完整的文件小于1k的文件属于下载不完整如果存在则用下面的命令删除然后重新下载编译所需的软件包再次检查.确认所有文件完整可大大提高编译成功率,避免浪费时间
```bash ```
find dl -size -1024c -exec rm -f {} \; find dl -size -1024c -exec rm -f {} \;
``` ```
- **最后编译固件(-j 后面是线程数首次编译推荐用单线程编译完成后输出路径是bin/targets.** - **最后编译固件(-j 后面是线程数首次编译推荐用单线程编译完成后输出路径是bin/targets.**
```bash ```
make V=s -j1 make V=s -j1
或者使用 make world -j1 V=s 2>&1 | tee world_debug.log 或者使用 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 等所有状态 | 只有源码目录保持不变 | 专用于回到一个“零配置、重做一切”的状态,完全从头开始构建。 | | `make distclean` | 删除 `make dirclean` 的所有内容 + feeds 下载文件 + `.config`、patch 等所有状态 | 只有源码目录保持不变 | 专用于回到一个“零配置、重做一切”的状态,完全从头开始构建。 |
恢复所有修改(包括未跟踪文件): 恢复所有修改(包括未跟踪文件):
```bash ```
git clean -fd git clean -fd
git restore --source=v24.10.2 --staged --worktree . git restore --source=v24.10.2 --staged --worktree .
``` ```
@@ -437,26 +437,26 @@ git restore --source=v24.10.2 --staged --worktree .
要启用的软件包: 要启用的软件包:
**base** **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 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** **cli**
```bash ```
btop iperf3 tcpdump btop iperf3 tcpdump
``` ```
**luci** **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 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** **lib**
```bash ```
kmod-ipt-conntrack kmod-ipt-nat kmod-nft-compat kmod-ipt-fullconenat kmod-ip6tables ca-certificates kmod-ipt-conntrack kmod-ipt-nat kmod-nft-compat kmod-ipt-fullconenat kmod-ip6tables ca-certificates
``` ```
## 使用SDK快速编译包 ## 使用SDK快速编译包
首先新建一个文件夹并将SDK克隆下来 首先新建一个文件夹并将SDK克隆下来
```bash ```
mkdir imwrt-sdk mkdir imwrt-sdk
cd ./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 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压缩因此解压的命令为 新版本的SDK使用ZSTD压缩因此解压的命令为
```bash ```
tar -I zstd -xvf ./immortalwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64.tar.zst tar -I zstd -xvf ./immortalwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64.tar.zst
``` ```
随后进入该目录并和一般流程一样更新Feeds 随后进入该目录并和一般流程一样更新Feeds
```bash ```
cd ./immortalwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/ cd ./immortalwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/
./scripts/feeds update -a ./scripts/feeds update -a
./scripts/feeds install -a ./scripts/feeds install -a
@@ -478,7 +478,7 @@ cd ./immortalwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/
更新完成后克隆你要编译的包的源码到package下 更新完成后克隆你要编译的包的源码到package下
```bash ```
cd ./package/ cd ./package/
git clone https://github.com/Dichgrem/luci-app-nyn.git git clone https://github.com/Dichgrem/luci-app-nyn.git
cp ./luci-app-nyn/luci-app-zzz ./ cp ./luci-app-nyn/luci-app-zzz ./
@@ -489,7 +489,7 @@ cd ../
随后开始编译编译结果在对应架构的base目录下 随后开始编译编译结果在对应架构的base目录下
```bash ```
make package/luci-app-zzz/compile V=s 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 ~/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 ./bin/packages/x86_64/base/zzz_0.1.1-r1_x86_64.ipk
``` ```
## 常用命令 ## 常用命令:
```
> 注意不能升级kmod前缀的软件包base-files是危险包谨慎升级
```bash
# 更新软件列表 # 更新软件列表
opkg update opkg update
# 列出可升级的非内核包 # 更新所有 LUCI 插件
opkg list-upgradable | grep -vE '^(kmod-|kernel)' opkg list-upgradable | grep luci- | cut -f 1 -d ' ' | xargs opkg upgrade
# 升级单个软件包 # 如果要更新所有软件,包括 OpenWRT 内核、固件等
opkg upgrade 包名 opkg list-upgradable | cut -f 1 -d ' ' | xargs opkg upgrade
# 固件版本号 # 固件版本号
vim /etc/os-release vim /etc/os-release
@@ -578,17 +575,6 @@ nft list table ip mangle
- 关闭防火墙的禁止转发规则,全部允许; - 关闭防火墙的禁止转发规则,全部允许;
- 将X86主路由的网线插到AP的任意一个LAN口。 - 将X86主路由的网线插到AP的任意一个LAN口。
## 更新所有包
```
opkg update
opkg list-upgradable \
| awk '{print $1}' \
| grep -vE '^(base-files|busybox|libc|libgcc|libstdc\+\+|procd|netifd|ubus|uci|kernel|kmod-|fstools|mtd|fwtool)$' \
| xargs -r opkg upgrade
```
## 🔗 ## 🔗
- [Openwrt wiki](https://openwrt.org/zh/docs/start) - [Openwrt wiki](https://openwrt.org/zh/docs/start)

View File

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

View File

@@ -76,7 +76,7 @@ Linux有许多不同的发行版但大致可以分为几个系
因此对于Linux而言文件系统是这样的 因此对于Linux而言文件系统是这样的
```bash ```shell
/ — 根 / — 根
/home — 用户家目录 /home — 用户家目录
/root — 超级用户的家 /root — 超级用户的家
@@ -114,7 +114,7 @@ Linux有许多不同的发行版但大致可以分为几个系
在Ubuntu的界面中李华看到了一个名为``终端``的应用,输入``apt install neofetch``,就安装成功...不,暂时还没有成功,再次输入``sudo apt install neofetch``,就成功安装了neofetch这个软件随后我们输入``neofetch``,可以看到系统的一些信息: 在Ubuntu的界面中李华看到了一个名为``终端``的应用,输入``apt install neofetch``,就安装成功...不,暂时还没有成功,再次输入``sudo apt install neofetch``,就成功安装了neofetch这个软件随后我们输入``neofetch``,可以看到系统的一些信息:
```bash ```shell
neofetch neofetch
.-/+oossssoo+/-. dich@uos .-/+oossssoo+/-. dich@uos
`:+ssssssssssssssssss+:` -------- `:+ssssssssssssssssss+:` --------
@@ -211,7 +211,7 @@ Linux 的权限可以简单理解为``UGO+RWX``.
- Linux命令查询[linux-command](https://wangchujiang.com/linux-command/hot.html) - Linux命令查询[linux-command](https://wangchujiang.com/linux-command/hot.html)
- Linux常用命令表[Quick Reference](https://wangchujiang.com/reference/docs/linux-command.html) - Linux常用命令表[Quick Reference](https://wangchujiang.com/reference/docs/linux-command.html)
```bash ```
date date
Sun Nov 16 09:16:15 PM +08 2025 Sun Nov 16 09:16:15 PM +08 2025
uname -a uname -a
@@ -243,7 +243,7 @@ which ls
- 在一些精简 Linux例如 Alpine、OpenWrt中命令不来自 GNU coreutils而来自一个叫 **BusyBox** 的单程序。BusyBox 只一个二进制文件,但内部包含了上百个命令,这种方式体积小,适用于嵌入式设备。 - 在一些精简 Linux例如 Alpine、OpenWrt中命令不来自 GNU coreutils而来自一个叫 **BusyBox** 的单程序。BusyBox 只一个二进制文件,但内部包含了上百个命令,这种方式体积小,适用于嵌入式设备。
```bash ```
/bin/busybox ls /bin/busybox ls
/bin/busybox cp /bin/busybox cp
/bin/busybox tar /bin/busybox tar
@@ -376,4 +376,4 @@ Linux 的内核天然支持 **Cgroups** 和 **Namespaces**,这是 **Docker**
* **KVM/QEMU** 内置的高性能虚拟化技术,相比 Windows 的 Hyper-V 或 VMware性能更好更通用。 * **KVM/QEMU** 内置的高性能虚拟化技术,相比 Windows 的 Hyper-V 或 VMware性能更好更通用。
--- ---
**Done.** **Done.**

View File

@@ -130,7 +130,7 @@ bluetoothctl info AA:BB:CC:DD:EE:FF
交互式步骤(在 `bluetoothctl` 提示符下): 交互式步骤(在 `bluetoothctl` 提示符下):
```bash ```text
$ bluetoothctl $ bluetoothctl
[bluetooth]# power on [bluetooth]# power on
[bluetooth]# agent on [bluetooth]# agent on
@@ -357,4 +357,4 @@ pamixer --toggle-mute
``` ```
--- ---
**Done.** **Done.**

View File

@@ -6,133 +6,96 @@ date = 2025-07-20
tags = ["Linux"] tags = ["Linux"]
+++ +++
前言 本文以星火一号开发板为例记录STM32命令行开发环境在Linux上的部署用以替代Windows上的RT-Thread-studio。RT-Thread开源但RT-Thread-studio是开源 前言 本文记录STM32命令行开发环境在Linux上的部署用以替代Windows上的RT-Thread-studio。RT-Thread-studio同样是开源
软件。 软件但目前没有Nixos上的打包
<!-- more --> <!-- more -->
# Windows方案 ## 依赖包
> 该方案使用``scons+gcc-arm-none-eabi+openocd``,可以和Vscode等等配合使用. - **Ubuntu**
## 拉取源码 以ubuntu24.04为例,首先安装这些包,包括连接工具,工具链和调试器等等。
```shell
```bash
https://github.com/Dichgrem/sdk-bsp-stm32f407-spark-template.git
```
## 安装依赖
- 安装 Scons 构建工具
```
pip install scons
```
- 安装 gcc-arm-none-eabi 工具链
在[官网](https://developer.arm.com/downloads/-/gnu-rm) 下载``gcc-arm-none-eabi-10.3-2021.10-win32.exe``,安装后使用以下命令设置环境变量
```powershell
$env:RTT_EXEC_PATH="C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin"
```
```powershell
$path = [Environment]::GetEnvironmentVariable("Path", "Machine")
[Environment]::SetEnvironmentVariable(
"Path",
"$path;C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin",
"Machine"
)
```
- 安装 openocd 调试/烧录工具
```bash
scoop install openocd
openocd --version
```
- 安装串口调试工具(可选,也可以用其他串口工具)
```bash
pip install pyserial
```
## 编译固件
进入项目目录并在``projects``下使用scons编译固件,编译结果为``rt-thread.bin``和``rt-thread-elf``
```bash
sdk-bsp-stm32f407-spark
cd ./projects/03_driver_als_ps
sdk-bsp-stm32f407-spark/projects/03_driver_als_ps studyvia C v14.3.0-gcc via ❄️ impure (nix-shell-env)
scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build
......
CC build/kernel/components/drivers/i2c/i2c-bit-ops.o
LINK rt-thread.elf
arm-none-eabi-objcopy -O binary rt-thread.elf rtthread.bin
arm-none-eabi-size rt-thread.elf
text data bss dec hex filename
87128 964 4252 92344 168b8 rt-thread.elf
scons: done building targets.
```
## 烧入测试
使用``openocd``指定开发板对应的cfg并烧入起始地址为``0x08000000``
```bash
openocd -f interface/stlink.cfg -f target/stm32f4x.cfg
openocd -f interface/stlink.cfg -f target/stm32f4x.cfg -c "program rtthread.bin 0x08000000 verify reset exit"
```
## 串口连接
烧入完成后我们可以使用``pyserial``的这个命令连接到串口,退出使用``Ctrl+]``退出
```bash
python -m serial.tools.miniterm COM3 115200
```
> 注意Windows上和开发板连接的串口可能是COM3,COM4等等需要和实际的相符可以在设备管理器中查看.
# Ubuntu 方案
## 拉取源码
```bash
https://github.com/Dichgrem/sdk-bsp-stm32f407-spark-template.git
```
## 安装依赖
```bash
sudo apt update sudo apt update
sudo apt install -y git python3 scons openocd stlink-tools gcc-arm-none-eabi gdb-multiarch sudo apt install -y git python3 scons openocd stlink-tools gcc-arm-none-eabi gdb-multiarch
``` ```
## 编译固件 - **Nixos**
```bash 虽然Nixos上没有RT-Thread-studio这个包但是可以用flake.nix很方便的搭建一个开发环境
scons -j$(nproc)
```nix
{
description = "STM32 && RT-Thread development environment";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit self system; };
});
in
{
devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [
python312
scons
openocd
stlink
stlink-tool
gcc-arm-embedded
picocom
renode-bin
];
};
});
};
}
``` ```
## 测试连接 ## 源码
随后使用Git拉取项目源码
```shell
git clone https://github.com/RT-Thread-Studio/sdk-bsp-stm32f407-spark.git
```
## ENV工具
使用Git拉取RT-Thread配套的linux开发环境并添加Shell变量。
```shell
# 克隆仓库
git clone https://github.com/RT-Thread/env.git ~/env
# 将 ~/env 添加到 PATH
export PATH="$PATH:$HOME/env"
# 显示 PATH
echo "$PATH"
# 查看 pkgs 命令是否存在
type pkgs
```
随后可以使用PKG初始化并安装两个必要的包
```shell
pkgs --update
pip install kconfiglib
pip install scons
```
## 连接
使用USB线连接开发板和开发PC并使用lsusb命令查看是否出现 使用USB线连接开发板和开发PC并使用lsusb命令查看是否出现
```bash ```shell
lsusb lsusb
Bus 001 Device 004: ID 0483:374b STMicroelectronics ST-LINK/V2.1 Bus 001 Device 004: ID 0483:374b STMicroelectronics ST-LINK/V2.1
``` ```
添加成功后可以使用这个命令来检测是否连接成功: 添加成功后可以使用这个命令来检测是否连接成功:
```bash ```shell
st-info --probe st-info --probe
Found 1 stlink programmers Found 1 stlink programmers
version: V2J35S26 version: V2J35S26
@@ -143,37 +106,81 @@ Found 1 stlink programmers
dev-type: STM32F4x5_F4x7 dev-type: STM32F4x5_F4x7
``` ```
> 如果你将Ubuntu安装在QEMU虚拟机中 需要在libvirt中使用Add_hardware添加usb设备。 > 如果你和我一样将Ubuntu安装在QEMU虚拟机中 需要在libvirt中使用Add_hardware添加usb设备。
## 烧入测试 ## 修改交叉工具链
链接成功后进入项目目录,发现``rtconfig.py``没有Linux路径需要我们手动修改交叉工具链部分
```python
#修改 rtconfig.py
# cross_tool provides the cross compiler
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
import os
if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
if os.name == 'nt':
# Windows 平台
EXEC_PATH = r'C:\Users\XXYYZZ'
else:
# 修改这里
# Linux / macOS 平台
EXEC_PATH = '/usr/bin'
elif CROSS_TOOL == 'keil':
PLATFORM = 'armclang' # KEIL AC6
# PLATFORM = 'armcc' # KEIL AC5
EXEC_PATH = r'C:/Keil_v5'
elif CROSS_TOOL == 'iar':
PLATFORM = 'iccarm'
EXEC_PATH = r'C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.3'
elif CROSS_TOOL == 'llvm-arm':
PLATFORM = 'llvm-arm'
if os.name == 'nt':
EXEC_PATH = r'D:\Progrem\LLVMEmbeddedToolchainForArm-17.0.1-Windows-x86_64\bin'
else:
EXEC_PATH = '/usr/bin'
```
## 编译
在完成以上设置之后我们可以开始编译。STM32使用scons编译系统同样是menuconfig命令
```shell
scons --menuconfig
```
修改配置并保存退出后即可开始编译,$(nproc)代表使用全部CPU线程来编译
```shell
scons -j$(nproc)
```
## 烧入
编译成功后你应该会看到有一个rtthread.bin在目录下这就是我们编译出来的系统 编译成功后你应该会看到有一个rtthread.bin在目录下这就是我们编译出来的系统
在烧入之前,我们可以备份一下原来的系统: 在烧入之前,我们可以备份一下原来的系统:
```bash ```shell
st-flash read firmware_backup.bin 0x08000000 0x100001 st-flash read firmware_backup.bin 0x08000000 0x100001
``` ```
随后使用如下命令烧入系统: 随后使用如下命令烧入系统:
```bash ```shell
st-flash write rtthread.bin 0x08000000 st-flash write rtthread.bin 0x08000000
``` ```
## 串口连接 ## 串口
除了USB之外我们还可以使用串口连接 除了USB之外我们还可以使用串口连接
```bash ```shell
sudo apt install picocom sudo apt install picocom
picocom -b 115200 /dev/ttyACM0 picocom -b 115200 /dev/ttyACM0
``` ```
可以使用``ctrl + A 然后 ctrl + x``退出。 可以使用``ctrl + A 然后 ctrl + x``退出。
## 使用Cmake
---
# 其他Tips
- 使用Cmake编译
通过官方文档可以得知除了scons外还可以使用Cmake来编译. 通过官方文档可以得知除了scons外还可以使用Cmake来编译.
@@ -248,42 +255,7 @@ This warning is for project developers. Use -Wno-dev to suppress it.
[100%] Built target rtthread.elf [100%] Built target rtthread.elf
``` ```
## 使用Renode
- Nixos
虽然Nixos上没有RT-Thread-studio这个包但是可以用flake.nix很方便的搭建一个开发环境
```nix
{
description = "STM32 && RT-Thread development environment";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit self system; };
});
in
{
devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [
python312
scons
openocd
stlink
stlink-tool
gcc-arm-embedded
picocom
renode-bin
];
};
});
};
}
```
- 使用Renode
如果没有真实的开发版可以使用Renode来进行仿真模拟 如果没有真实的开发版可以使用Renode来进行仿真模拟
@@ -372,4 +344,4 @@ arm-none-eabi-gdb firmware.elf
``` ```
--- ---
**Done.** **Done.**

View File

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

View File

@@ -1,5 +1,5 @@
+++ +++
title = "Windows系列(0):系统安装与设置" title = "Windows系列(1):系统安装与设置"
date = 2024-05-24 date = 2024-05-24
[taxonomies] [taxonomies]
@@ -12,7 +12,7 @@ tags = ["Windows"]
## 总纲 ## 总纲
安装Windows有两种情况:1.在一台全新的电脑上安装2.想为现有的系统更换版本。本文主要介绍这两种情况。如果只想对现有的系统进行优化,推荐看下一篇的``"Windows系列(1):常用操作与配置"``. 安装Windows有两种情况:1.在一台全新的电脑上安装2.想为现有的系统更换版本。本文主要介绍这两种情况。如果只想对现有的系统进行优化,推荐看下一篇的``"Windows系列(2):常用操作与配置"``.
**全新安装** **全新安装**
- 获得一个Windows的ISO镜像 - 获得一个Windows的ISO镜像
@@ -178,7 +178,7 @@ tags = ["Windows"]
- **抓包**: [Wireshark](https://www.wireshark.org/download.html) - **抓包**: [Wireshark](https://www.wireshark.org/download.html)
- **启动器**: [Flow.Launcher](https://github.com/Flow-Launcher/Flow.Launcher) - **启动器**: [Flow.Launcher](https://github.com/Flow-Launcher/Flow.Launcher)
- **输入法**: [Rime](https://rime.im/download/) - **输入法**: [Rime](https://rime.im/download/)
- **浏览器**: [Floorp](https://github.com/Floorp-Projects/Floorp) / [Chrome](https://dl.google.com/tag/s/installdataindex/update2/installers/ChromeStandaloneSetup64.exe) - **浏览器**: [Floorp](https://github.com/Floorp-Projects/Floorp) / [Chrome](https://www.google.com/chrome/)
- **编辑器**: [VSCodium](https://github.com/VSCodium/vscodium) - **编辑器**: [VSCodium](https://github.com/VSCodium/vscodium)
- **虚拟机**: HyperV - **虚拟机**: HyperV
- **科学上网**: [GFS](https://github.com/GUI-for-Cores/GUI.for.SingBox) - **科学上网**: [GFS](https://github.com/GUI-for-Cores/GUI.for.SingBox)

View File

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

View File

@@ -1,5 +1,5 @@
+++ +++
title = "Windows系列(2):分类与激活" title = "Windows系列(3):分类与激活"
date = 2024-05-26 date = 2024-05-26
[taxonomies] [taxonomies]

View File

@@ -1,6 +1,6 @@
+++ +++
title = "Windows系列(3):封装与全自动安装" title = "Windows系列(4):封装与全自动安装"
date = 2024-05-27 date = 2024-05-29
[taxonomies] [taxonomies]
tags = ["Windows"] tags = ["Windows"]

View File

@@ -1,177 +0,0 @@
+++
title = "Windows系列(4):高效操作与强化"
date = 2024-05-28
[taxonomies]
tags = ["Windows"]
+++
前言 本文记载windows下的常用快捷键与PowerShell强化配置.
<!-- more -->
## 快捷键
高效使用 Windows 的第一步,就是**减少鼠标依赖**。
Windows 自身已经内置了大量非常实用的快捷键,只是很多人并没有系统地使用过。
- **Alt + Tab**
在**已打开的窗口之间切换**(经典快捷键)
- **Win + Tab**
打开**任务视图**,可查看所有窗口与虚拟桌面
- **Alt + F4**
关闭当前窗口
> 在桌面下使用时可弹出关机 / 重启菜单
- **Win + D**
显示桌面 / 恢复窗口
- **Win + ↑ / ↓ / ← / →**
窗口最大化 / 最小化 / 左右分屏
- **Win + Shift + ← / →**
将当前窗口移动到另一个显示器
---
### 虚拟桌面
- **Win + Ctrl + D**
新建虚拟桌面
- **Win + Ctrl + ← / →**
在虚拟桌面之间切换
- **Win + Ctrl + F4**
关闭当前虚拟桌面
---
### 应用启动与系统
- **Win**
打开开始菜单,直接输入搜索应用
- **Win + R**
打开“运行”窗口
- **Win + E**
打开资源管理器
- **Win + I**
打开系统设置
- **Win + L**
锁屏
---
### 截图与录屏
- **Win + Shift + S**
截图(区域 / 窗口 / 全屏)
- **Win + PrtSc**
全屏截图并自动保存
- **Win + G**
打开 Xbox Game Bar可用于屏幕录制
---
### 常用编辑操作
- **Ctrl + C / V / X**
复制 / 粘贴 / 剪切
- **Ctrl + Z / Y**
撤销 / 重做
- **Ctrl + A**
全选
- **Ctrl + S**
保存
- **Ctrl + F**
查找
- **Ctrl + Shift + Esc**
直接打开任务管理器
## 启动器
有了窗口切换和关闭,还需要打开,这里推荐这两个:
- [Flow.Launcher](https://github.com/Flow-Launcher/Flow.Launcher)
- [ZeroLaunch-rs](https://github.com/ghost-him/ZeroLaunch-rs)
现在我们就可以使用``Win+Tab``切换窗口,使用``Alt+F4``关闭窗口,使用``Alt+Space``启动软件.
## Powershell强化
要达到类似Linux下``oh-myzsh+atuin+fzf+zoxide+starship``的效果,可以使用以下方法增强:
- 安装模块
```bash
winget install junegunn.fzf
fzf --version
winget install JanDeDobbeleer.OhMyPosh
oh-my-posh version
winget install ajeetdsouza.zoxide
zoxide --version
```
- 导入模块
```bash
Install-Module PSReadLine -Scope CurrentUser -Force
Install-Module posh-git -Scope CurrentUser -Force
Install-Module PSFzf -Scope CurrentUser -Force
```
- 写入配置
首先执行这个命令:
```bash
notepad $PROFILE
```
在打开的窗口中写入:
```bash
# ---------- PSReadLine ----------
Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle InlineView
# ---------- Git ----------
Import-Module posh-git
# ---------- fzf ----------
Import-Module PSFzf
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r'
# ---------- zoxide ----------
Invoke-Expression (& { (zoxide init powershell | Out-String) })
# ---------- oh-my-posh ----------
oh-my-posh init pwsh | Invoke-Expression
# ---------- Bash-style line editing ----------
# Ctrl+A → 行首
Set-PSReadLineKeyHandler -Key Ctrl+a -Function BeginningOfLine
# Ctrl+E → 行尾
Set-PSReadLineKeyHandler -Key Ctrl+e -Function EndOfLine
# Ctrl+U → 删除从光标到行首
Set-PSReadLineKeyHandler -Key Ctrl+u -Function BackwardDeleteLine
# Ctrl+K → 删除从光标到行尾
Set-PSReadLineKeyHandler -Key Ctrl+k -Function ForwardDeleteLine
```
随后新开启一个PowerShell可以看到有Git提示ctrl+R唤起历史右方向键透明补全的效果.
---
**Done.**

View File

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

View File

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

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env -S just --justfile #!/usr/bin/env -S just --justfile
build: build:
zola build && pagefind --site public --root-selector body zola build && pagefind --site public --root-selector body

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}

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