<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Blog on Ray's Blog</title><link>https://raychi.site/tags/blog/</link><description>Recent content in Blog on Ray's Blog</description><generator>Hugo</generator><language>zh-CN</language><copyright>Copyright © 2025, Ray</copyright><lastBuildDate>Sun, 28 Sep 2025 00:00:00 +0800</lastBuildDate><atom:link href="https://raychi.site/tags/blog/index.xml" rel="self" type="application/rss+xml"/><item><title>如何重置Linux系统中的root密码</title><link>https://raychi.site/reset-linux-root-passwd/</link><pubDate>Sun, 28 Sep 2025 00:00:00 +0800</pubDate><guid>https://raychi.site/reset-linux-root-passwd/</guid><description>&lt;h2 id="关于重置linux密码问题">关于重置Linux密码问题&lt;/h2>
&lt;p>我有一个旧服务器（物理机子），之前出了一点问题，现在修好了准备启用。但是我忘了root密码，，然后有几种重制的方法。&lt;/p>
&lt;p>别担心，本文将介绍几种重置Linux系统root密码的方法。&lt;/p>
&lt;h2 id="方法1使用grub引导加载程序">方法1：使用GRUB引导加载程序&lt;/h2>
&lt;h3 id="步骤1重启系统">步骤1：重启系统&lt;/h3>
&lt;p>重启你的Linux系统，在GRUB菜单出现时立即按任意键停止启动过程。&lt;/p>
&lt;h3 id="步骤2编辑启动项">步骤2：编辑启动项&lt;/h3>
&lt;p>选择要启动的内核（通常是第一个选项），然后按&lt;code>e&lt;/code>键进行编辑。&lt;/p>
&lt;h3 id="步骤3修改内核参数">步骤3：修改内核参数&lt;/h3>
&lt;p>找到以&lt;code>linux&lt;/code>开头的行，通常包含类似&lt;code>/boot/vmlinuz-xxx&lt;/code>的文本。在该行的末尾添加以下参数：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-fallback" data-lang="fallback">&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">1&lt;/span>&lt;span>init=/bin/bash
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>然后按&lt;code>Ctrl+X&lt;/code>或&lt;code>F10&lt;/code>继续启动。&lt;/p>
&lt;h3 id="步骤4重新挂载文件系统">步骤4：重新挂载文件系统&lt;/h3>
&lt;p>系统会启动到bash shell。输入以下命令重新挂载根文件系统为可读写：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">1&lt;/span>&lt;span>mount -o remount,rw /
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="步骤5重置密码">步骤5：重置密码&lt;/h3>
&lt;p>使用&lt;code>passwd&lt;/code>命令重置root密码：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">1&lt;/span>&lt;span>passwd root
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>系统会提示你输入新密码并确认。&lt;/p>
&lt;h3 id="步骤6重新挂载为只读并重启">步骤6：重新挂载为只读并重启&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">1&lt;/span>&lt;span>mount -o remount,ro /
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">2&lt;/span>&lt;span>exec /sbin/init
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>或者直接重启系统：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">1&lt;/span>&lt;span>reboot
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="方法2使用live-cdusb">方法2：使用Live CD/USB&lt;/h2>
&lt;p>如果你有Linux Live CD或USB驱动器，可以使用它来重置密码。&lt;/p>
&lt;h3 id="步骤1启动live-cdusb">步骤1：启动Live CD/USB&lt;/h3>
&lt;p>从Live CD或USB启动你的系统。&lt;/p>
&lt;h3 id="步骤2挂载根分区">步骤2：挂载根分区&lt;/h3>
&lt;p>打开终端，列出磁盘分区找到你的根分区：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">1&lt;/span>&lt;span>sudo fdisk -l
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>假设你的根分区是&lt;code>/dev/sda1&lt;/code>，则挂载它：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">1&lt;/span>&lt;span>sudo mkdir /mnt/sysroot
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">2&lt;/span>&lt;span>sudo mount /dev/sda1 /mnt/sysroot
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="步骤3切换到挂载的系统">步骤3：切换到挂载的系统&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">1&lt;/span>&lt;span>sudo chroot /mnt/sysroot
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="步骤4重置密码">步骤4：重置密码&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">1&lt;/span>&lt;span>passwd root
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="步骤5退出并重启">步骤5：退出并重启&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">1&lt;/span>&lt;span>exit
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">2&lt;/span>&lt;span>sudo umount /mnt/sysroot
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">3&lt;/span>&lt;span>sudo reboot
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="方法3使用单用户模式">方法3：使用单用户模式&lt;/h2>
&lt;p>对于某些系统，你也可以尝试进入单用户模式：&lt;/p></description></item><item><title>静态博客</title><link>https://raychi.site/staticsites/</link><pubDate>Sat, 01 Jun 2024 00:00:00 +0800</pubDate><guid>https://raychi.site/staticsites/</guid><description>&lt;h2 id="介绍">介绍&lt;/h2>
&lt;p>静态博客是一种使用静态文件（如HTML、CSS和JavaScript）构建的博客系统。与动态博客不同，静态博客的内容在发布后不会发生变化，因此它们通常比动态博客更快、更安全，并且更容易部署。&lt;/p>
&lt;p>静态博客通常使用Markdown或其他标记语言编写内容，然后使用静态站点生成器（如Jekyll、Hugo、Gatsby等）将内容转换为静态文件。这些静态文件可以托管在任何静态文件托管服务上，如GitHub Pages、Netlify、Vercel等。&lt;/p>
&lt;p>静态博客的优点包括：&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>不需要服务器&lt;/strong>&lt;/p>
&lt;p>不需要去购买云服务器，并且配置各种环境。每年单独服务器租赁价格是一笔不小的开销。&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>轻量级&lt;/strong>&lt;/p>
&lt;p>静态博客的页面加载速度快，因为它们只需要加载HTML、CSS和JavaScript文件，而不需要执行复杂的服务器端脚本或数据库查询。&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>安全性高&lt;/strong>&lt;/p>
&lt;p>静态博客没有数据库和动态内容，因此减少了安全漏洞的风险。即使服务器被攻击，也很难造成严重的数据丢失或安全威胁。&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>易于维护&lt;/strong>&lt;/p>
&lt;p>由于内容是静态文件，维护工作相对简单。你只需要更新Markdown文件，然后重新生成站点即可。&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>版本控制友好&lt;/strong>&lt;/p>
&lt;p>所有内容都可以存储在Git仓库中，这使得版本控制和协作变得更加容易。&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="常用的静态博客生成器">常用的静态博客生成器&lt;/h2>
&lt;h3 id="jekyll">Jekyll&lt;/h3>
&lt;p>Jekyll是最受欢迎的静态博客生成器之一，它使用Ruby语言开发，并与GitHub Pages紧密集成。Jekyll的设计哲学是&amp;quot;将原始内容转换为静态网站&amp;quot;，它支持Markdown、 Liquid模板语言等。&lt;/p>
&lt;h3 id="hugo">Hugo&lt;/h3>
&lt;p>Hugo是一个用Go语言编写的静态网站生成器，以其极快的构建速度而闻名。Hugo支持Markdown、HTML等多种内容格式，并提供了丰富的主题和配置选项。&lt;/p>
&lt;h3 id="gatsby">Gatsby&lt;/h3>
&lt;p>Gatsby是一个基于React的静态网站生成器，它使用GraphQL来管理数据。Gatsby非常适合需要复杂交互和动态功能的网站。&lt;/p>
&lt;h3 id="hexo">Hexo&lt;/h3>
&lt;p>Hexo是一个快速、简洁且高效的博客框架，基于Node.js开发。Hexo支持Markdown写作，并提供了丰富的插件和主题。&lt;/p>
&lt;h3 id="gatsby-vs-jekyll-vs-hugo-vs-hexo">Gatsby vs Jekyll vs Hugo vs Hexo&lt;/h3>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>特性&lt;/th>
 &lt;th>Jekyll&lt;/th>
 &lt;th>Hugo&lt;/th>
 &lt;th>Gatsby&lt;/th>
 &lt;th>Hexo&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>构建速度&lt;/td>
 &lt;td>慢&lt;/td>
 &lt;td>极快&lt;/td>
 &lt;td>中等&lt;/td>
 &lt;td>快&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>语言&lt;/td>
 &lt;td>Ruby&lt;/td>
 &lt;td>Go&lt;/td>
 &lt;td>JavaScript&lt;/td>
 &lt;td>Node.js&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>主题数量&lt;/td>
 &lt;td>多&lt;/td>
 &lt;td>中等&lt;/td>
 &lt;td>多&lt;/td>
 &lt;td>多&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>学习曲线&lt;/td>
 &lt;td>容易&lt;/td>
 &lt;td>容易&lt;/td>
 &lt;td>陡峭&lt;/td>
 &lt;td>容易&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>GitHub Pages支持&lt;/td>
 &lt;td>是&lt;/td>
 &lt;td>是&lt;/td>
 &lt;td>否&lt;/td>
 &lt;td>否&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="如何构建静态博客">如何构建静态博客&lt;/h2>
&lt;h3 id="步骤1选择工具">步骤1：选择工具&lt;/h3>
&lt;p>首先，你需要选择一个静态博客生成器。对于初学者，我们推荐Jekyll或Hugo，因为它们都有丰富的文档和社区支持。&lt;/p>
&lt;h3 id="步骤2安装和配置">步骤2：安装和配置&lt;/h3>
&lt;p>根据你选择的工具，安装过程会有所不同。以下是使用Jekyll的示例：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681"> 1&lt;/span>&lt;span>&lt;span style="color:#8b949e;font-style:italic"># 安装Jekyll&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681"> 2&lt;/span>&lt;span>gem install jekyll
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681"> 3&lt;/span>&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681"> 4&lt;/span>&lt;span>&lt;span style="color:#8b949e;font-style:italic"># 创建新站点&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681"> 5&lt;/span>&lt;span>jekyll new myblog
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681"> 6&lt;/span>&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681"> 7&lt;/span>&lt;span>&lt;span style="color:#8b949e;font-style:italic"># 进入站点目录&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681"> 8&lt;/span>&lt;span>cd myblog
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681"> 9&lt;/span>&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">10&lt;/span>&lt;span>&lt;span style="color:#8b949e;font-style:italic"># 启动开发服务器&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#6e7681">11&lt;/span>&lt;span>bundle exec jekyll serve
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="步骤3创建内容">步骤3：创建内容&lt;/h3>
&lt;p>使用Markdown编写文章。Jekyll会在_posts目录中查找Markdown文件，并自动生成HTML页面。&lt;/p></description></item></channel></rss>