﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux教程 - Linux迷</title>
	<atom:link href="https://www.linuxmi.com/linux/feed" rel="self" type="application/rss+xml" />
	<link>https://www.linuxmi.com</link>
	<description>分享Linux和编程</description>
	<lastBuildDate>Mon, 04 May 2026 10:13:55 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.3</generator>

<image>
	<url>https://www.linuxmi.com/wp-content/uploads/2020/02/cropped-Favicon-32x32.png</url>
	<title>Linux教程 - Linux迷</title>
	<link>https://www.linuxmi.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Ubuntu 24.04 升级到 Ubuntu 26.04 图文指南</title>
		<link>https://www.linuxmi.com/upgrade-ubuntu-24-04-to-ubuntu-26-04.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=upgrade-ubuntu-24-04-to-ubuntu-26-04</link>
					<comments>https://www.linuxmi.com/upgrade-ubuntu-24-04-to-ubuntu-26-04.html#respond</comments>
		
		<dc:creator><![CDATA[linuxmi]]></dc:creator>
		<pubDate>Mon, 04 May 2026 10:12:48 +0000</pubDate>
				<category><![CDATA[Linux教程]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Ubuntu 26.04]]></category>
		<guid isPermaLink="false">https://www.linuxmi.com/?p=28042</guid>

					<description><![CDATA[<p>Ubuntu 26.04 LTS（Resolute Raccoon）已经正式发布，对于正在使用 Ub &#8230;</p>
<p>The post <a href="https://www.linuxmi.com/upgrade-ubuntu-24-04-to-ubuntu-26-04.html">Ubuntu 24.04 升级到 Ubuntu 26.04 图文指南</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></description>
										<content:encoded><![CDATA[<p data-start="39" data-end="199">Ubuntu 26.04 LTS（Resolute Raccoon）已经正式发布，对于正在使用 Ubuntu 24.04 LTS（Noble Numbat）的用户来说，这意味着可以升级到最新的长期支持版本，享受更稳定、更安全的系统体验。升级主要是通过命令行工具来完成的，步骤虽然简单明了，但对于不熟悉命令行的新手来说，也最好提前了解操作流程。需要注意的是，每一次重大系统升级都可能带来一定风险，例如软件不兼容或数据丢失，因此在升级之前，务必先备份好重要文件和数据，以确保万一出现问题，也能轻松恢复。总的来说，只要做好准备，升级到 Ubuntu 26.04 LTS 将是一次顺畅且值得尝试的体验。</p>
<p data-start="39" data-end="199">相关链接：选择Ubuntu 26.04 LTS 发布 <a href="https://www.linuxmi.com/ubuntu-26-04-lts.html">https://www.linuxmi.com/ubuntu-26-04-lts.html</a></p>
<h2 data-section-id="1e86eyz" data-start="293" data-end="307">💾 第一步：备份系统</h2>
<p data-start="309" data-end="378">备份不是强制要求，但强烈推荐先创建系统快照，以防升级过程中出现意外。你可以使用熟悉的快照工具，如果不确定用哪种，可以参考一些推荐方案。</p>
<p data-start="380" data-end="408">如果不打算使用快照工具，也可以将重要目录打包成压缩文件：</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="relative">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly m-0"><code><span class="ͼ10">☠ linuxmi@linuxmi ~/www.linuxmi.com ➜ sudo</span> tar czf /ubuntu2404lts.tar.gz \
     <span class="ͼ12">--exclude</span><span class="ͼv">=</span>/ubuntu2404lts.tar.gz \
     <span class="ͼ12">--exclude</span><span class="ͼv">=</span>/dev \
     <span class="ͼ12">--exclude</span><span class="ͼv">=</span>/run \
     <span class="ͼ12">--exclude</span><span class="ͼv">=</span>/mnt \
     <span class="ͼ12">--exclude</span><span class="ͼv">=</span>/proc \
     <span class="ͼ12">--exclude</span><span class="ͼv">=</span>/sys \
     <span class="ͼ12">--exclude</span><span class="ͼv">=</span>/tmp \
     <span class="ͼ12">--exclude</span><span class="ͼv">=</span>/media \
     <span class="ͼ12">--exclude</span><span class="ͼv">=</span>/lost<span class="ͼv">+</span>found \
     /</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-28049" src="https://www.linuxmi.com/wp-content/uploads/2026/05/upgrade-ubuntu-24-04-to-ubuntu-26-04.png" alt="" width="1000" height="650" /></div>
<div class="">生成的压缩包 <code data-start="687" data-end="704">/ubuntu2404lts.tar.gz</code> 请移动到另一块硬盘、另一台电脑或远程服务器保存，保存在同一块磁盘上并不能保证安全。</div>
</div>
</div>
</div>
</div>
<hr data-start="748" data-end="751" />
<h2 data-section-id="1rxo0y" data-start="753" data-end="770">🔄 第二步：确保系统已更新</h2>
<p data-start="772" data-end="816">升级前必须确保 Ubuntu 24.04 LTS 系统已经安装了所有更新。执行以下命令：</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="pointer-events-none absolute inset-x-4 top-12 bottom-4">
<div class="pointer-events-none sticky z-40 shrink-0 z-1!">
<div class="sticky bg-token-border-light"></div>
</div>
</div>
<div class="relative">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly m-0"><code><span class="ͼ10">☠ linuxmi@linuxmi ~/www.linuxmi.com ➜ sudo</span> apt update
<span class="ͼ10">☠ linuxmi@linuxmi ~/www.linuxmi.com ➜ sudo</span> apt upgrade</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class=""><img decoding="async" class="alignnone size-full wp-image-28047" src="https://www.linuxmi.com/wp-content/uploads/2026/05/upgrade-ubuntu-24-04-to-ubuntu-26-04-1.png" alt="" width="1600" height="950" /></div>
</div>
</div>
</div>
</div>
<p data-start="864" data-end="885">如果有 Snap 应用需要更新，也请执行：</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="relative">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly m-0"><code><span class="ͼ10">☠ linuxmi@linuxmi ~/www.linuxmi.com ➜ sudo</span> snap refresh</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p data-start="918" data-end="931">接着清理不再需要的软件包：</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="relative">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly m-0"><code><span class="ͼ10">☠ linuxmi@linuxmi ~/www.linuxmi.com ➜ sudo</span> apt autoremove <span class="ͼ12">--purge</span></code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class=""><img decoding="async" class="alignnone size-full wp-image-28056" src="https://www.linuxmi.com/wp-content/uploads/2026/05/upgrade-ubuntu-24-04-to-ubuntu-26-04-9.png" alt="" width="1600" height="950" /></div>
</div>
</div>
</div>
</div>
<p data-start="974" data-end="982">完成后重启系统：</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="relative">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly m-0"><code><span class="ͼ10">☠ linuxmi@linuxmi ~/www.linuxmi.com ➜ sudo</span> reboot</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p data-start="1009" data-end="1030">此时系统应已完全更新，没有待安装的软件包。</p>
<h2 data-section-id="zzn4s6" data-start="1037" data-end="1055">⚙️ 第三步：检查升级提示设置</h2>
<p data-start="1057" data-end="1096">Ubuntu LTS 系统默认只会提示升级到新 LTS 版本。请检查配置文件：</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="relative">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly m-0"><code><span class="ͼ10">☠ linuxmi@linuxmi ~/www.linuxmi.com ➜ cat</span> /etc/update-manager/release-upgrades</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class=""><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-28048" src="https://www.linuxmi.com/wp-content/uploads/2026/05/upgrade-ubuntu-24-04-to-ubuntu-26-04-2.png" alt="" width="1600" height="950" /></div>
</div>
</div>
</div>
</div>
<p data-start="1152" data-end="1159">确保内容如下：</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="relative">
<div class="pe-11 pt-3">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly m-0"><code>Prompt=lts</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p data-start="1181" data-end="1218">如果显示的是 <code data-start="1188" data-end="1203">Prompt=normal</code>，请修改为 LTS 升级模式：</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="relative">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly m-0"><code><span class="ͼ10">☠ linuxmi@linuxmi ~/www.linuxmi.com ➜ sudo</span> <span class="ͼ10">sed</span> <span class="ͼ12">-i</span> <span class="ͼz">'s/Prompt=.*/Prompt=lts/'</span> /etc/update-manager/release-upgrades</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p data-start="1308" data-end="1368">这样系统会按照 LTS 路径升级，从 24.04 LTS 升级到 26.04 LTS，而不会提供非 LTS 的中间版本。</p>
<p data-start="1308" data-end="1368"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-28052" src="https://www.linuxmi.com/wp-content/uploads/2026/05/upgrade-ubuntu-24-04-to-ubuntu-26-04-5.png" alt="" width="1920" height="1080" /></p>
<h2 data-section-id="4m1epn" data-start="1375" data-end="1389">🚀 第四步：开始升级</h2>
<p data-start="1391" data-end="1398">执行升级命令：</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="relative">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly m-0"><code><span class="ͼ10">☠ linuxmi@linuxmi ~/www.linuxmi.com ➜ sudo</span> do-release-upgrade</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p data-start="1437" data-end="1464"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-28050" src="https://www.linuxmi.com/wp-content/uploads/2026/05/upgrade-ubuntu-24-04-to-ubuntu-26-04-3.png" alt="" width="1600" height="950" /></p>
<p data-start="1437" data-end="1464">如果系统暂未提供升级提示，可加上 <code data-start="1454" data-end="1458">-d</code> 强制执行：</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="relative">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly m-0"><code><span class="ͼ10">☠ linuxmi@linuxmi ~/www.linuxmi.com ➜ sudo</span> do-release-upgrade <span class="ͼ12">-d</span></code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class=""><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-28051" src="https://www.linuxmi.com/wp-content/uploads/2026/05/upgrade-ubuntu-24-04-to-ubuntu-26-04-4.png" alt="" width="1600" height="950" /></div>
</div>
</div>
</div>
</div>
<p data-start="1506" data-end="1570">升级工具会检查系统，自动切换软件源到 Ubuntu 26.04 仓库，并显示将要安装、升级或删除的软件包列表。确认提示即可继续。</p>
<p data-start="1572" data-end="1588">升级过程中你可能会遇到以下情况：</p>
<ul data-start="1590" data-end="1691">
<li data-section-id="9itxjr" data-start="1590" data-end="1623">系统询问是否让服务自动重启：选择 “Yes” 可让升级更顺畅。</li>
<li data-section-id="1c06zcq" data-start="1624" data-end="1652">对已修改的配置文件：如果不确定，保留当前版本更安全。</li>
<li data-section-id="k9vjpw" data-start="1653" data-end="1691">升级接近完成时：系统会提示删除已过时的软件包，输入 <code data-start="1681" data-end="1684">y</code> 并回车即可。</li>
</ul>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-28053" src="https://www.linuxmi.com/wp-content/uploads/2026/05/upgrade-ubuntu-24-04-to-ubuntu-26-04-6.png" alt="" width="1600" height="950" /></p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-28054" src="https://www.linuxmi.com/wp-content/uploads/2026/05/upgrade-ubuntu-24-04-to-ubuntu-26-04-7.png" alt="" width="1600" height="950" /></p>
<p data-start="1693" data-end="1750">升级完成后，系统会提示重启，重启后即可登录 Ubuntu 26.04 LTS（Resolute Raccoon）。</p>
<p data-start="1693" data-end="1750"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-28055" src="https://www.linuxmi.com/wp-content/uploads/2026/05/upgrade-ubuntu-24-04-to-ubuntu-26-04-8.png" alt="" width="1920" height="1080" /></p>
<h2 data-section-id="ngankg" data-start="1757" data-end="1768">🔧 升级后步骤</h2>
<p data-start="1770" data-end="1793">登录系统后，建议执行以下操作确保系统完全更新：</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="relative">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly m-0"><code><span class="ͼ10">sudo</span> snap refresh          <span class="ͼt"># 刷新 Snap 应用</span>
<span class="ͼ10">sudo</span> apt update
<span class="ͼ10">sudo</span> apt upgrade           <span class="ͼt"># 检查并更新剩余软件包</span>
<span class="ͼ10">sudo</span> apt autoremove <span class="ͼ12">--purge</span> <span class="ͼt"># 清理不再需要的软件包</span></code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<h2 data-section-id="13gtq5p" data-start="1950" data-end="1958">📝 总结</h2>
<p data-start="1960" data-end="2074">至此，你的 Ubuntu 24.04 LTS（Noble Numbat）系统已经成功升级到 Ubuntu 26.04 LTS（Resolute Raccoon）。升级完成后，请确保主要应用、驱动、扩展和外部仓库能够正常工作。</p>
<p data-start="2076" data-end="2159">Ubuntu 26.04 LTS 提供标准支持至 2031 年 4 月，并可通过 Ubuntu Pro 获取扩展支持。<a href="https://documentation.ubuntu.com/release-notes/26.04/" target="_blank" rel="noopener">官方发布说明</a>也值得查看，以了解所有更新和新特性。</p><p>The post <a href="https://www.linuxmi.com/upgrade-ubuntu-24-04-to-ubuntu-26-04.html">Ubuntu 24.04 升级到 Ubuntu 26.04 图文指南</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.linuxmi.com/upgrade-ubuntu-24-04-to-ubuntu-26-04.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>在 Kali GNU/Linux Roll 中安装 OpenSSH 10.0 图文指南</title>
		<link>https://www.linuxmi.com/kali-gnu-linux-roll-install-openssh-10-0.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=kali-gnu-linux-roll-install-openssh-10-0</link>
					<comments>https://www.linuxmi.com/kali-gnu-linux-roll-install-openssh-10-0.html#respond</comments>
		
		<dc:creator><![CDATA[linuxmi]]></dc:creator>
		<pubDate>Sun, 13 Apr 2025 01:27:41 +0000</pubDate>
				<category><![CDATA[Linux教程]]></category>
		<category><![CDATA[openSSH]]></category>
		<guid isPermaLink="false">https://www.linuxmi.com/?p=26498</guid>

					<description><![CDATA[<p>截至目前（2025年4月），OpenSSH 10.0 已经正式发布了，这次更新移除了过时的 DSA  &#8230;</p>
<p>The post <a href="https://www.linuxmi.com/kali-gnu-linux-roll-install-openssh-10-0.html">在 Kali GNU/Linux Roll 中安装 OpenSSH 10.0 图文指南</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>截至目前（2025年4月），<a href="https://www.linuxmi.com/openssh-10-0.html"><strong>OpenSSH 10.0</strong> 已经正式发布</a>了，这次更新移除了过时的 DSA 签名，默认启用了结合量子防护的密钥交换算法，还改进了 scp/sftp 行为和 sshd 安全性。配置文件支持更灵活的条件匹配，体验更流畅。</p>
<p>一句话总结：更安全、更现代、也更好用，SSH 用户值得马上升级！</p>
<p>但 Kali Linux 默认源里的版本一般不会第一时间更新到这么新。要安装最新版本，你通常有几个选择：</p>
<h3 class="" data-start="144" data-end="183">方式一：使用 Kali Rolling 测试源（适合稍微新一点的版本）</h3>
<p class="" data-start="185" data-end="285">Kali 是基于 Debian Testing 的，你可以切到测试源或 <code data-start="221" data-end="235">kali-rolling</code> 较新分支看看能不能拿到更新版。<br data-start="251" data-end="254" />不过<strong data-start="256" data-end="272">一般不会立刻到10.0版</strong>，可能只是9.x的更新版。</p>
<p class="" data-start="287" data-end="292">命令参考：</p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ sudo apt update
</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26500" src="https://www.linuxmi.com/wp-content/uploads/2025/04/1.png" alt="" width="1182" height="687" /></p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ sudo apt install openssh-server</code></pre>
<p class="" data-start="355" data-end="375">如果版本太旧，继续往下看手动编译的方法。</p>
<h3 class="" data-start="382" data-end="410">方式二：自己编译安装（最保险拿到最新10.0版）</h3>
<p class="" data-start="412" data-end="451">如果你要<strong data-start="416" data-end="438">第一时间用 OpenSSH 10.0</strong>，那基本需要自己手动编译。</p>
<p class="" data-start="453" data-end="468">步骤比较清楚，Linux迷（<a href="https://www.linuxmi.com/">www.linuxmi.com</a>）小编给你整理好啦：</p>
<h4 class="" data-start="470" data-end="487">1. 安装编译需要的依赖</h4>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary"></div>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ sudo apt update</code></pre>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ sudo apt install build-essential zlib1g-dev libssl-dev libpam0g-dev libselinux1-dev</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26502" src="https://www.linuxmi.com/wp-content/uploads/2025/04/2.png" alt="" width="1278" height="721" /></p>
<h4 class="" data-start="602" data-end="627">2. 下载 OpenSSH 10 的源码</h4>
<p class="" data-start="629" data-end="639">去官网拉最新版源码：</p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-10.0p1.tar.gz
</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26503" src="https://www.linuxmi.com/wp-content/uploads/2025/04/3.png" alt="" width="1191" height="688" /></p>
<p class="" data-start="734" data-end="739">然后解压：</p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ tar zxvf openssh-10.0p1.tar.gz</code></pre>
<p data-start="734" data-end="739"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26504" src="https://www.linuxmi.com/wp-content/uploads/2025/04/4.png" alt="" width="1192" height="687" /></p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ cd openssh-10.0p1</code></pre>
<h4 class="" data-start="803" data-end="817">3. 配置编译参数</h4>
<p class="" data-start="819" data-end="860">一般你可以用默认配置，不过推荐加上 <code data-start="837" data-end="843">/usr</code> 这样系统知道怎么找你的 SSH。</p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com] 
└─$./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords</code></pre>
<p data-start="944" data-end="972"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26505" src="https://www.linuxmi.com/wp-content/uploads/2025/04/5.png" alt="" width="1196" height="697" /></p>
<p class="" data-start="944" data-end="972">如果你想用更标准的 Kali 配置，可以多加一些，比如：</p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com] 
└─$./configure --prefix=/usr --sysconfdir=/etc/ssh --with-privsep-path=/var/lib/sshd --with-pam</code></pre>
<h4 class="" data-start="1080" data-end="1093">4. 编译并安装</h4>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com] 
└─$make -j$(nproc)</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26506" src="https://www.linuxmi.com/wp-content/uploads/2025/04/6.png" alt="" width="1192" height="683" /></p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com] 
└─$ sudo make install</code></pre>
<p class="" data-start="1142" data-end="1152">安装好后，确认版本：</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ ssh -V</code></pre>
</div>
</div>
<p class="" data-start="1174" data-end="1179">应该看到：</p>
<pre class="pure-highlightjs"><code class="null">10.0p2, OpenSSL 3.4.1 11 Feb 2025</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26495" src="https://www.linuxmi.com/wp-content/uploads/2025/04/openssh-10-0.png" alt="" width="1920" height="1080" /></p>
<h4 class="" data-start="1218" data-end="1241">5. 重启 ssh 服务（如果需要）</h4>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">sudo systemctl restart ssh</code></pre>
</div>
</div>
<p class="" data-start="1283" data-end="1304">如果你的系统服务名字叫 <code data-start="1295" data-end="1301">sshd</code>，用：</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">sudo systemctl restart sshd</code></pre>
</div>
</div>
<hr class="" data-start="1347" data-end="1350" />
<h3 class="" data-start="1352" data-end="1361">⚡ 小提示</h3>
<ul data-start="1363" data-end="1526">
<li class="" data-start="1363" data-end="1413">
<p class="" data-start="1365" data-end="1413"><strong data-start="1365" data-end="1375">备份好旧配置</strong>：升级前备份 <code data-start="1382" data-end="1404">/etc/ssh/sshd_config</code>，防止配置出问题。</p>
</li>
<li class="" data-start="1414" data-end="1475">
<p class="" data-start="1416" data-end="1475"><strong data-start="1416" data-end="1427">小心远程服务器</strong>：如果你是在远程机器上操作，<strong data-start="1441" data-end="1463">千万别直接 kill 掉旧 sshd</strong>，不然连接断了麻烦大了。</p>
</li>
<li class="" data-start="1476" data-end="1526">
<p class="" data-start="1478" data-end="1526"><strong data-start="1478" data-end="1486">长期维护</strong>：自己编译的版本不会跟随系统更新，需要你自己关注 OpenSSH 后续安全补丁。</p>
</li>
</ul>
<p>相关链接：<a href="https://www.linuxmi.com/openssh-10-0.html">https://www.linuxmi.com/openssh-10-0.html</a></p><p>The post <a href="https://www.linuxmi.com/kali-gnu-linux-roll-install-openssh-10-0.html">在 Kali GNU/Linux Roll 中安装 OpenSSH 10.0 图文指南</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.linuxmi.com/kali-gnu-linux-roll-install-openssh-10-0.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>默认命令太落后？试试这些更快更好用的 Linux 工具</title>
		<link>https://www.linuxmi.com/easy-to-use-linux-tools.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=easy-to-use-linux-tools</link>
					<comments>https://www.linuxmi.com/easy-to-use-linux-tools.html#respond</comments>
		
		<dc:creator><![CDATA[linuxmi]]></dc:creator>
		<pubDate>Sat, 01 Feb 2025 01:00:33 +0000</pubDate>
				<category><![CDATA[Linux教程]]></category>
		<guid isPermaLink="false">https://www.linuxmi.com/?p=26144</guid>

					<description><![CDATA[<p>如果你和我一样，喜欢用最快、最简便的方式来完成任务，那么你一定要了解一些更高效的 Linux 工具。 &#8230;</p>
<p>The post <a href="https://www.linuxmi.com/easy-to-use-linux-tools.html">默认命令太落后？试试这些更快更好用的 Linux 工具</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>如果你和我一样，喜欢用最快、最简便的方式来完成任务，那么你一定要了解一些更高效的 Linux 工具。实际上，有些命令不仅比你平时用的那些更方便，而且功能也更强大，能大大提升工作效率。今天，我就想和大家分享几个我自己常用的工具，它们不仅能帮你更轻松地处理任务，还能让你体验到更流畅的操作。如果你还没尝试过，今天就是个好机会！</p>
<h2>1. <strong>bat：带语法高亮的 cat</strong></h2>
<p><code>cat</code> 命令用来在终端查看文件内容，而 <code>bat</code> 是它的增强版，支持语法高亮、Git 集成和自动分页显示。此外，<code>bat</code> 还能更清晰地显示不可打印字符。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26043" src="https://www.linuxmi.com/wp-content/uploads/2025/01/bat3.png" alt="" width="1186" height="773" /></p>
<p>不同发行版的安装方法：</p>
<pre class="pure-highlightjs"><code class="null"># Debian/Ubuntu
sudo apt install bat

# Fedora
sudo dnf install bat

# Arch Linux
sudo pacman -S bat

# openSUSE
sudo zypper install bat</code></pre>
<p>安装后，使用方式和 <code>cat</code> 一样：</p>
<pre class="pure-highlightjs"><code class="null">bat file1</code></pre>
<p><strong>注意</strong>：如果你在 Debian/Ubuntu 上安装了 <code>bat</code>，需要用 <code>batcat</code> 代替 <code>bat</code>，因为 <code>bat</code> 这个名称已被其他软件占用：</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">batcat file1</code></pre>
</div>
</div>
<p>如果觉得 <code>batcat</code> 太长，可以用 <code>alias</code> 命令给它起个简短的别名：</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">alias bat='batcat'</code></pre>
</div>
</div>
<p>此外，<code>bat</code> 还支持更换主题，比如：</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">bat --theme=Dracula file1</code></pre>
</div>
</div>
<p>如果想永久修改主题，可以在 <code>~/.bashrc</code> 里设置环境变量。</p>
<p>相关：Bat v0.25 发布  <a href="https://www.linuxmi.com/bat-v0-25-cat.html">https://www.linuxmi.com/bat-v0-25-cat.html</a></p>
<h2>2. <strong>ncdu：比 du 更友好的磁盘空间分析工具</strong></h2>
<p><code>du</code> 命令可以查看磁盘使用情况，但输出信息不太直观。而 <code>ncdu</code> 提供了一个交互式界面，方便查看哪些文件占用了最多空间。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-16755" src="https://www.linuxmi.com/wp-content/uploads/2022/06/ncdu.png" alt="" width="946" height="661" /></p>
<p>安装方式：</p>
<pre class="pure-highlightjs"><code class="null"># Debian/Ubuntu
sudo apt install ncdu

# Fedora
sudo dnf install ncdu

# Arch Linux
sudo pacman -S ncdu

# openSUSE
sudo zypper install ncdu</code></pre>
<p>使用方法：</p>
<pre class="pure-highlightjs"><code class="null"># 分析当前目录
ncdu

# 分析特定目录，例如 /snap
ncdu /snap

# 分析整个硬盘
ncdu /</code></pre>
<p>扫描完成后，它会以列表形式显示所有文件夹和文件的大小，并按大小排序。你可以用方向键导航，按 <code>i</code> 查看详细信息，按 <code>d</code> 删除文件，按 <code>q</code> 退出。</p>
<p>如果不想扫描外接存储设备，可以用：</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">ncdu -d /</code></pre>
</div>
</div>
<h2>3. <strong>eza：比 ls 更漂亮</strong></h2>
<p><code>eza</code> 是 <code>ls</code> 命令的增强版，支持彩色显示、超链接、图标等，视觉效果更好。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26148" src="https://www.linuxmi.com/wp-content/uploads/2025/01/eza.png" alt="" width="1360" height="768" /></p>
<p>安装方式：</p>
<pre class="pure-highlightjs"><code class="null"># 需要安装 Rust 先
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env

# 安装 eza
cargo install eza</code></pre>
<p>使用方式：</p>
<pre class="pure-highlightjs"><code class="null"># 类似 ls
eza
# 显示详细信息和图标（需要终端支持）
eza -lh --icons</code></pre>
<h2>4. <strong>fd：更友好的文件搜索</strong></h2>
<p><code>fd</code> 并不是 <code>find</code> 的完全替代品，但它语法更直观，支持正则表达式，使用起来更顺手。</p>
<p>相关：fd &#8211; Linux 上非常快速查找文件的命令  <a href="https://www.linuxmi.com/fd-linux-command.html">https://www.linuxmi.com/fd-linux-command.html</a></p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-21358" src="https://www.linuxmi.com/wp-content/uploads/2023/04/fd-3.png" alt="" width="1042" height="628" /></p>
<p>安装方法：</p>
<pre class="pure-highlightjs"><code class="null"># Ubuntu/Debian
sudo apt install fd-find

# Fedora
sudo dnf install fd-find

# Arch Linux
sudo pacman -S fd

# openSUSE
sudo zypper install fd</code></pre>
<p>使用示例：</p>
<pre class="pure-highlightjs"><code class="null"># 搜索当前目录
fdfind

# 搜索包含 "file" 关键字的文件
fdfind file

# 在特定目录下搜索
fdfind file /folder1

# 搜索特定扩展名的文件，例如 .sh 脚本
fdfind -e sh</code></pre>
<h2>5. <strong>ripgrep：比 grep 更快</strong></h2>
<p><code>ripgrep</code> (<code>rg</code>) 是一个强大的文本搜索工具，比 <code>grep</code> 更快，特别适合搜索代码文件。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26156" src="https://www.linuxmi.com/wp-content/uploads/2025/01/ripgrep-2.png" alt="" width="990" height="361" /></p>
<p>安装方法：</p>
<pre class="pure-highlightjs"><code class="null"># Debian/Ubuntu
sudo apt-get install ripgrep

# Fedora
sudo dnf install ripgrep

# Arch Linux
sudo pacman -S ripgrep

# openSUSE
sudo zypper install ripgrep</code></pre>
<p>使用示例：</p>
<pre class="pure-highlightjs"><code class="null"># 在 linuxmi.py.md 里搜索 "linuxmi"
rg "linuxmi" linuxmi.py

# 在整个项目目录里搜索 "is"
rg "linuxmi" linuxmi_project

# 仅在 Python 文件中搜索
rg "Python" linuxmi_project --type py</code></pre>
<p>默认情况下，<code>ripgrep</code> 不会搜索隐藏文件和目录。</p>
<p>相关：Linux 专业开发者必看：ripgrep 完美替代 grep  <a href="https://www.linuxmi.com/ripgrep.html">https://www.linuxmi.com/ripgrep.html</a></p>
<h2>6. <strong>zoxide：比 cd 更聪明</strong></h2>
<p><code>cd</code> 是最基础的 Linux 命令之一，而 <code>zoxide</code> 让导航变得更智能，它会记住你访问过的目录，方便快速跳转。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26167" src="https://www.linuxmi.com/wp-content/uploads/2025/01/z.png" alt="" width="1049" height="626" /></p>
<p>安装方法：</p>
<pre class="pure-highlightjs"><code class="null">curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh</code></pre>
<p>然后初始化（Bash 用户）：</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs">echo 'eval "$(zoxide init bash)"' &gt;&gt; ~/.bashrc
source ~/.bashrc</pre>
</div>
</div>
<p>使用示例：</p>
<pre class="pure-highlightjs"><code class="null"># 进入深层目录
z demo1/demo2/demo3/demo4/

# 以后可以直接用 z 进入最近访问过的目录
z demo4</code></pre>
<p>如果有多个同名目录，会列出可选项（需要安装 <code>fzf</code>）。</p>
<h2>7. <strong>btop：比 top 更直观</strong></h2>
<p><code>btop</code> 是 <code>top</code> 命令的替代品，支持鼠标操作，界面更美观，还有动画效果。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-21710" src="https://www.linuxmi.com/wp-content/uploads/2023/06/btop.png" alt="" width="1920" height="1080" /></p>
<p>安装方法：</p>
<pre class="pure-highlightjs"><code class="null"># 下载适合的二进制文件
tar -xjf btop-x86_64-linux-musl.tbz
cd btop/
./install.sh</code></pre>
<p>运行：</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">btop</code></pre>
</div>
</div>
<p>可以实时监控 CPU、内存、磁盘、网络等信息。</p>
<h2>8. <strong>tldr：比 man 更简单</strong></h2>
<p><code>man</code> 命令能显示详细的命令手册，但对新手来说不太友好。而 <code>tldr</code> 提供了更简洁的命令说明，包含实际用例。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-16748" src="https://www.linuxmi.com/wp-content/uploads/2022/06/tldr.png" alt="" width="946" height="997" /></p>
<p>安装方式（需要 Node.js）：</p>
<pre class="pure-highlightjs"><code class="null">npm install -g tldr</code></pre>
<p>使用示例：</p>
<pre class="pure-highlightjs"><code class="null"># 查看 rm 命令的简明用法
tldr rm
</code></pre>
<h2>9. <strong>sd：比 sed 更简单</strong></h2>
<p><code>sd</code> 提供了更直观的语法，比 <code>sed</code> 更容易上手，支持常见的正则表达式。</p>
<p>安装方式：</p>
<pre class="pure-highlightjs"><code class="null">cargo install sd</code></pre>
<p>示例：</p>
<p>替换文本</p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ sed -i 's/data char oid/linuxmi ubuntu debian/g' linuxmi.c
┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ sd 'data char oid' 'linuxmi ubuntu debian' linuxmi.c</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26166" src="https://www.linuxmi.com/wp-content/uploads/2025/01/sd.png" alt="" width="1049" height="514" /></p>
<p><code>sd</code> 还支持更复杂的搜索和替换模式。</p>
<h4>结语</h4>
<p>虽然这些工具无法完全取代传统命令，但在很多实际应用中，它们无疑更加便捷和高效。通过使用这些工具，你可以大大提高工作效率，让日常的 Linux 操作变得更加流畅和轻松。如果你也想让自己的 Linux 使用体验更加顺畅，不妨试试看这些命令，说不定会带来意想不到的惊喜！</p><p>The post <a href="https://www.linuxmi.com/easy-to-use-linux-tools.html">默认命令太落后？试试这些更快更好用的 Linux 工具</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.linuxmi.com/easy-to-use-linux-tools.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Linux 专业开发者必看：ripgrep 完美替代 grep</title>
		<link>https://www.linuxmi.com/ripgrep.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ripgrep</link>
					<comments>https://www.linuxmi.com/ripgrep.html#respond</comments>
		
		<dc:creator><![CDATA[linuxmi]]></dc:creator>
		<pubDate>Fri, 31 Jan 2025 01:22:53 +0000</pubDate>
				<category><![CDATA[Linux教程]]></category>
		<category><![CDATA[ripgrep]]></category>
		<guid isPermaLink="false">https://www.linuxmi.com/?p=26150</guid>

					<description><![CDATA[<p>ripgrep 是开源社区 RIIR（重写成 Rust）项目中的一个杰出成果，旨在取代传统的 Lin &#8230;</p>
<p>The post <a href="https://www.linuxmi.com/ripgrep.html">Linux 专业开发者必看：ripgrep 完美替代 grep</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><strong>ripgrep</strong> 是开源社区 RIIR（重写成 Rust）项目中的一个杰出成果，旨在取代传统的 <strong>Linux grep</strong> 命令，提供更高效、更快速的文件搜索体验。它在速度、功能和易用性上都有显著优势，是程序员和开发者在日常工作中不可或缺的工具。</p>
<h3><strong>ripgrep 的基本语法</strong></h3>
<p>与传统的 <strong>grep</strong> 命令相似，<strong>ripgrep</strong> 的基本语法也很简单：</p>
<pre class="pure-highlightjs"><code class="null">rg &lt;pattern&gt; [files/directories]</code></pre>
<p>使用时，你无需显式指定文件名，<strong>ripgrep</strong> 会自动搜索所有文件。这种“自动搜索”机制特别适合不确定文件位置时使用，省去了手动指定文件名的麻烦。虽然 <strong>grep</strong> 也可以在所有文件中搜索，但 <strong>ripgrep</strong> 无需额外操作，便能轻松完成任务。</p>
<h3><strong>ripgrep 是什么？</strong></h3>
<p><strong>ripgrep</strong> 是一个高效的递归正则表达式匹配工具，设计目标是快速且准确地搜索文件内容。它的突出特点包括：</p>
<ul>
<li>自动考虑 <code>.gitignore</code> 文件，避免搜索无关文件，提高搜索效率</li>
<li>支持在多种编码格式下工作，包括 UTF-8、SHIFT_JIS 等</li>
<li>可在压缩文件（如 ZIP 格式）内进行搜索</li>
<li>默认忽略隐藏文件，并通过 <code>.gitignore</code> 加速搜索</li>
</ul>
<p>你可以将 <strong>ripgrep</strong> 看作是 <strong>grep</strong> 的升级版，专注于高效的内容搜索，避免了 <strong>grep</strong> 在处理原始字节流时的低效。</p>
<h3><strong>安装 ripgrep</strong></h3>
<p>虽然 <strong>grep</strong> 在大多数 Linux 系统中已经预装，但 <strong>ripgrep</strong> 并不会随系统默认安装。不过，<strong>ripgrep</strong> 在主流 Linux 发行版中都可以通过包管理器轻松安装。以下是常见发行版的安装命令：</p>
<ul>
<li><strong>Arch Linux</strong>:
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none"><code class="!whitespace-pre hljs language-bash">pacman -S ripgrep</code></div>
</div>
</li>
<li><strong>Gentoo</strong>:
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none"><code class="!whitespace-pre hljs language-bash">emerge sys-apps/ripgrep</code></div>
</div>
</li>
<li><strong>Fedora / Red Hat</strong>:
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none"><code class="!whitespace-pre hljs language-bash">sudo dnf install ripgrep</code></div>
</div>
</li>
<li><strong>openSUSE</strong> (15.1 及以后版本):
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none"><code class="!whitespace-pre hljs language-bash">sudo zypper install ripgrep</code></div>
</div>
</li>
<li><strong>Debian Buster 及以上版本</strong>:
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none"><code class="!whitespace-pre hljs language-bash">sudo apt install ripgrep</code></div>
</div>
</li>
</ul>
<h3><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26152" src="https://www.linuxmi.com/wp-content/uploads/2025/01/ripgrep.png" alt="" width="972" height="425" /></h3>
<h3><strong>使用 ripgrep</strong></h3>
<p>如果你已经习惯了 <strong>grep</strong> 命令，使用 <strong>ripgrep</strong> 会非常简单。你只需提供一个搜索字符串和文件名，<strong>ripgrep</strong> 会在指定文件中搜索并显示匹配的文本和行号。</p>
<p>例如，搜索 <code>linuxi.py</code> 文件中的 <code>linuxmi</code> 关键字：</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ rg linuxmi linuxmi.py
2:# Linux迷 www.linuxmi.com
4:~'echo Hello world!Linux迷 www.linuxmi.com</code></pre>
</div>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26154" src="https://www.linuxmi.com/wp-content/uploads/2025/01/ripgrep-1.png" alt="" width="981" height="338" /></p>
<p><strong>ripgrep</strong> 会展示匹配的行号和内容。</p>
<p>你还可以指定多个文件进行搜索，<strong>ripgrep</strong> 会列出匹配的文件及相关内容。</p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ rg linuxmi linuxmi.com.sh linuxmi.py
linuxmi.com.sh
2:# Linux迷 www.linuxmi.com

linuxmi.py
2:# Linux迷 www.linuxmi.com
4:~'echo Hello world!Linux迷 www.linuxmi.com'</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26156" src="https://www.linuxmi.com/wp-content/uploads/2025/01/ripgrep-2.png" alt="" width="990" height="361" /></p>
<h3><strong>上下文搜索</strong></h3>
<p>在搜索代码时，了解匹配行的上下文信息往往会更有帮助。使用 <code>-C</code> 或 <code>--context</code> 选项，你可以显示匹配行前后的内容。</p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ rg -C 2 linuxmi linuxmi.py
1-#! /usr/bin/env zxpy
2:# Linux迷 www.linuxmi.com
3-
4:~'echo Hello world!Linux迷 www.linuxmi.com'
5-
6-file_count = ~'ls -1 | wc -l'</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26158" src="https://www.linuxmi.com/wp-content/uploads/2025/01/ripgrep-3.png" alt="" width="1010" height="402" /></p>
<p>例如，使用 <code>-A</code> 显示匹配行后的内容.</p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ rg -A 2 done linuxmi.c
16:  printf("Thread %s done!\n", name);
17-  return NULL;
18-}</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26160" src="https://www.linuxmi.com/wp-content/uploads/2025/01/ripgrep-4.png" alt="" width="1010" height="318" /></p>
<p><code>-B</code> 显示匹配行前的内容。</p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ rg -B 2 done linuxmi.c
14-  }
15- 
16:  printf("Thread %s done!\n", name);</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26161" src="https://www.linuxmi.com/wp-content/uploads/2025/01/ripgrep-5.png" alt="" width="1010" height="318" /></p>
<h3><strong>列号选项</strong></h3>
<p>如果你是 <strong>vim</strong> 用户，<code>--column</code> 选项会打印匹配文本所在行的列号。</p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ rg --column done linuxmi.c
16:25:  printf("Thread %s done!\n", name);</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26162" src="https://www.linuxmi.com/wp-content/uploads/2025/01/ripgrep-6.png" alt="" width="1010" height="262" /></p>
<p>另一个与列号相关的选项是 <code>-M</code> 或 <code>--max-columns</code>，它接受一个数字值，表示最大列数。如果某一行的列数超过该值，<strong>ripgrep</strong> 会提示该行被省略。</p>
<pre class="pure-highlightjs"><code class="null">┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ rg --max-columns 20 done linuxmi.c
16:[Omitted long line with 1 matches]</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-26163" src="https://www.linuxmi.com/wp-content/uploads/2025/01/ripgrep-7.png" alt="" width="1010" height="346" /></p>
<h3><strong>其他有用选项</strong></h3>
<p>除了常见的功能外，<strong>ripgrep</strong> 还提供了多种有用的选项：</p>
<ul>
<li>使用 <code>-s</code> 或 <code>--case-sensitive</code> 进行区分大小写的搜索</li>
<li>使用 <code>-i</code> 或 <code>--ignore-case</code> 进行不区分大小写的搜索</li>
<li>使用 <code>-j</code> 或 <code>--threads</code> 选项，可以在多个线程上并行执行搜索，适合大型代码库</li>
<li>使用 <code>-v</code> 或 <code>--invert-match</code> 排除特定模式</li>
<li>如果你想搜索压缩文件中的文本，可以使用 <code>-z</code> 或 <code>--search-zip</code> 选项，常与 <code>-a</code> 一起使用，把二进制文件当做文本文件处理</li>
</ul>
<h3><strong>总结</strong></h3>
<p><strong>ripgrep</strong> 是一个非常强大的工具，特别适合开发者在类 Unix 环境下使用。它相较于传统的 <strong>grep</strong> 命令，提供了更快速、更高效的文件搜索体验，特别是在处理大量文件时。它不仅能自动忽略无关文件，还能进行压缩文件搜索，支持多种编码格式，简化了开发者的工作流程。尽管 <strong>ripgrep</strong> 并非 <strong>grep</strong> 的替代品，但它的功能和速度使其成为了更现代的选择，尤其适合那些需要频繁进行文件内容搜索的开发人员。如果你还没有尝试过 <strong>ripgrep</strong>，不妨给它一个机会，它会让你的工作更加高效。</p><p>The post <a href="https://www.linuxmi.com/ripgrep.html">Linux 专业开发者必看：ripgrep 完美替代 grep</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.linuxmi.com/ripgrep.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>如何从 Ubuntu 22.04 LTS 升级到 Ubuntu 24.04.1 LTS</title>
		<link>https://www.linuxmi.com/ubuntu-22-04-lts-upgrade-ubuntu-24-04-1.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ubuntu-22-04-lts-upgrade-ubuntu-24-04-1</link>
					<comments>https://www.linuxmi.com/ubuntu-22-04-lts-upgrade-ubuntu-24-04-1.html#respond</comments>
		
		<dc:creator><![CDATA[linuxmi]]></dc:creator>
		<pubDate>Mon, 16 Sep 2024 12:52:24 +0000</pubDate>
				<category><![CDATA[Linux教程]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Ubuntu 22.04]]></category>
		<category><![CDATA[Ubuntu 24.04]]></category>
		<guid isPermaLink="false">https://www.linuxmi.com/?p=25330</guid>

					<description><![CDATA[<p>近日，Ubuntu 24.04.5 LTS 正式发布，这是 Ubuntu 24.04 LTS (No &#8230;</p>
<p>The post <a href="https://www.linuxmi.com/ubuntu-22-04-lts-upgrade-ubuntu-24-04-1.html">如何从 Ubuntu 22.04 LTS 升级到 Ubuntu 24.04.1 LTS</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>近日，<a href="https://www.linuxmi.com/ubuntu-22-04-5-lts.html">Ubuntu 24.04.5 LTS 正式发布</a>，这是 Ubuntu 24.04 LTS (Noble Numbat) 系列的最后一个小版本更新。而 Canonical 早已为 Ubuntu 22.04 LTS (Jammy Jellyfish) 用户开放了升级通道。</p>
<p>通常情况下，Canonical 会在新版本发布约六个月后开放从旧版 LTS 到新版 LTS 的升级路径，以确保安全。也就是说，现在你可以从 Ubuntu 22.04 LTS 升级到 Ubuntu 24.04.1 LTS。</p>
<p>虽然 24.04.1 LTS 本身并没有太多新内容，主要是整合了此前发布的更新和安全补丁，适合不想安装后再下载大量更新的用户。虽然内核版本没变，但关键是升级路径终于为 22.04 LTS 用户开放了！</p>
<p style="text-align: center;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25333" src="https://www.linuxmi.com/wp-content/uploads/2024/09/ubuntu-22-04-lts-upgrade-ubuntu-24-04-5-1-9.png" alt="" width="1920" height="1080" /></p>
<h3>如何通过图形界面升级？</h3>
<p>当 Ubuntu 24.04 LTS 可以升级时，你应该会收到系统通知。如果没有通知，打开“软件更新器”，你会看到“Ubuntu 24.04.1 LTS 现在可用（当前版本 22.04）”的提示。点击“升级”按钮就可以开始。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-25341" src="https://www.linuxmi.com/wp-content/uploads/2024/09/ubuntu-22-04-lts-upgrade-ubuntu-24-04-5-1.png" alt="" width="1108" height="577" /></p>
<p>接着，会弹出一个窗口，提供更多关于 Ubuntu 24.04 LTS 的信息。以前会显示详情，可以阅读完整说明，现在不知道怎么没有了，若只想升级，直接点击“升级”按钮即可。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25342" src="https://www.linuxmi.com/wp-content/uploads/2024/09/ubuntu-22-04-lts-upgrade-ubuntu-24-04-5-1-1_0.png" alt="" width="1183" height="662" /></p>
<p>然后按屏幕提示进行操作。系统会列出需要升级、安装或删除的包，并建议你先关闭所有其他程序以免数据丢失。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-25340" src="https://www.linuxmi.com/wp-content/uploads/2024/09/ubuntu-22-04-lts-upgrade-ubuntu-24-04-5-2.png" alt="" width="1126" height="580" /></p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-25339" src="https://www.linuxmi.com/wp-content/uploads/2024/09/ubuntu-22-04-lts-upgrade-ubuntu-24-04-5-3.png" alt="" width="1225" height="910" /></p>
<p>升级过程中，锁屏功能会被禁用。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-25337" src="https://www.linuxmi.com/wp-content/uploads/2024/09/ubuntu-22-04-lts-upgrade-ubuntu-24-04-5-5.png" alt="" width="1179" height="606" /></p>
<p>升级时间取决于你的网络和电脑性能。过程中你会看到提示，Mozilla Thunderbird 邮件客户端将改为 Snap 包格式。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25343" src="https://www.linuxmi.com/wp-content/uploads/2024/09/ubuntu-22-04-lts-upgrade-ubuntu-24-04-5-9.png" alt="" width="1281" height="849" /></p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-25336" src="https://www.linuxmi.com/wp-content/uploads/2024/09/ubuntu-22-04-lts-upgrade-ubuntu-24-04-5-6.png" alt="" width="1361" height="942" /></p>
<p>完成后，系统会建议你移除过时软件包，最后需要重启电脑完成升级。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-25335" src="https://www.linuxmi.com/wp-content/uploads/2024/09/ubuntu-22-04-lts-upgrade-ubuntu-24-04-5-7.png" alt="" width="1343" height="956" /></p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-25334" src="https://www.linuxmi.com/wp-content/uploads/2024/09/ubuntu-22-04-lts-upgrade-ubuntu-24-04-5-8.png" alt="" width="1920" height="1080" /></p>
<h3>如何通过命令行升级？</h3>
<p>首先，确保你备份了重要文件，以防万一。然后，确认当前系统是最新的，可以在终端运行以下命令来完成：</p>
<div class="dark bg-gray-950 contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative"></div>
<pre class="pure-highlightjs"><code class="null">sudo apt update &amp;&amp; sudo apt full-upgrade</code></pre>
<p>重启系统后，如果没有看到升级通知，打开终端，运行以下命令启动升级：</p>
<div class="dark bg-gray-950 contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative"></div>
<pre class="pure-highlightjs"><code class="null">do-release-upgrade</code></pre>
<p>按照提示按下 y 继续，等待升级所需的包下载并安装，整个过程大概也会持续一个小时或更长时间。</p>
<p>同样，系统会提示 Thunderbird 将转换为 Snap 包格式。升级完成后，系统会通知你移除过时软件，并要求重启电脑。</p>
<h3>总结</h3>
<p>无论是通过图形界面还是命令行，你都可以轻松地将 Ubuntu 22.04 LTS 升级到最新的 Ubuntu 24.04 LTS (Noble Numbat)，享受新版带来的改进和功能！</p><p>The post <a href="https://www.linuxmi.com/ubuntu-22-04-lts-upgrade-ubuntu-24-04-1.html">如何从 Ubuntu 22.04 LTS 升级到 Ubuntu 24.04.1 LTS</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.linuxmi.com/ubuntu-22-04-lts-upgrade-ubuntu-24-04-1.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Linux fmt 命令：轻松搞定文本格式化</title>
		<link>https://www.linuxmi.com/linux-fmt.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linux-fmt</link>
					<comments>https://www.linuxmi.com/linux-fmt.html#respond</comments>
		
		<dc:creator><![CDATA[linuxmi]]></dc:creator>
		<pubDate>Tue, 20 Aug 2024 00:20:10 +0000</pubDate>
				<category><![CDATA[Linux教程]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux命令]]></category>
		<guid isPermaLink="false">https://www.linuxmi.com/?p=25188</guid>

					<description><![CDATA[<p>fmt 命令是一个方便的文本格式化工具，它可以让你的文本看起来更加整齐有序。通过调整行宽和段落布局， &#8230;</p>
<p>The post <a href="https://www.linuxmi.com/linux-fmt.html">Linux fmt 命令：轻松搞定文本格式化</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><code>fmt</code> 命令是一个方便的文本格式化工具，它可以让你的文本看起来更加整齐有序。通过调整行宽和段落布局，<code>fmt</code> 能使文本内容更易于阅读。它既可以处理文件内容，也可以从标准输入中获取数据，进行自动调整。默认情况下，<code>fmt</code> 会将每行宽度设为 75 个字符，但你也可以通过命令选项自定义这个宽度。对于想要快速统一文本排版的人来说，<code>fmt</code> 是个非常实用的小工具。</p>
<p>在本教程中，我们将带你了解 <code>fmt</code> 的基本用法及其主要功能。文中的命令和示例已在 Ubuntu 24.04 上进行了测试。</p>
<h3>基本用法</h3>
<p><code>fmt</code> 是 Linux 命令行用户常用的简单工具，其基本语法如下：</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">fmt [-WIDTH] [OPTION]... [FILE]...</code></pre>
</div>
</div>
<p><code>fmt</code> 的主要功能是重新格式化文件中的每个段落，并将结果输出到标准输出。你可以通过 <code>-WIDTH</code> 选项来调整行宽。</p>
<p>接下来，我们通过几个常见的 Q&amp;A 示例，帮助你更好地理解 <code>fmt</code> 的用法。</p>
<h3>Q1: 如何使用 <code>fmt</code> 格式化文件内容为一行？</h3>
<p>默认情况下，不加选项的 <code>fmt</code> 命令会将文件内容格式化为一行输出。只需将文件名作为参数传递即可。</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">fmt [文件名]</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25190" src="https://www.linuxmi.com/wp-content/uploads/2024/08/fmt1.png" alt="" width="1209" height="818" /></p>
</div>
</div>
<p>此时，<code>fmt</code> 会将文件中的多行内容整合为一行输出，但原始文件并不会被修改。</p>
<h3>Q2: 如何更改最大行宽？</h3>
<p><code>fmt</code> 默认将每行的最大宽度设置为 75 个字符。如果你想调整这个值，可以使用 <code>-w</code> 选项并指定一个数字。</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">fmt -w [宽度] [文件名]</code></pre>
</div>
</div>
<p>例如，将行宽缩小为 20 个字符：</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">fmt -w 20 [文件名]</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25191" src="https://www.linuxmi.com/wp-content/uploads/2024/08/fmt2.png" alt="" width="1209" height="806" /></p>
</div>
</div>
<h3>Q3: 如何突出显示第一行？</h3>
<p>你可以通过使用 <code>-t</code> 选项来让第一行的缩进与其他行不同，以实现突出显示的效果。</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">fmt -t [文件名]</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25194" src="https://www.linuxmi.com/wp-content/uploads/2024/08/fmt3.png" alt="" width="1209" height="397" /></p>
</div>
</div>
<p>此选项会让第一行的格式更加显眼。</p>
<h3>Q4: 如何让 <code>fmt</code> 拆分长行？</h3>
<p><code>fmt</code> 也可以拆分过长的行内容，使用 <code>-s</code> 选项即可实现这一功能。</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">fmt -s [文件名]</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25195" src="https://www.linuxmi.com/wp-content/uploads/2024/08/fmt4.png" alt="" width="1209" height="397" /></p>
</div>
</div>
<p>这有助于将内容更好地分段和排版。</p>
<h3>Q5: 如何设置单词和句子的间距？</h3>
<p>使用 <code>-u</code> 选项，<code>fmt</code> 会确保单词之间有一个空格，而句子之间有两个空格。这在排版要求较严格时非常有用。</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">fmt -u [文件名]</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25196" src="https://www.linuxmi.com/wp-content/uploads/2024/08/fmt5.png" alt="" width="1209" height="397" /></p>
</div>
</div>
<p>我们测试发现，<code>fmt</code> 默认会启用这个选项。</p>
<h3>总结</h3>
<p>虽然 <code>fmt</code> 的功能相对简单，但它仍然是处理文本格式化时的得力工具。无论是为了调整行宽，还是为了确保排版一致，<code>fmt</code> 都能轻松胜任。即使你平时可能不常使用它，但在需要快速调整文本格式时，它绝对能派上用场。如果你想深入了解 <code>fmt</code> 的更多选项和功能，可以随时查阅<a href="https://linux.die.net/man/1/fmt" target="_blank" rel="nofollow noopener">其手册页</a>。</p><p>The post <a href="https://www.linuxmi.com/linux-fmt.html">Linux fmt 命令：轻松搞定文本格式化</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.linuxmi.com/linux-fmt.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>掌握 dd 命令：Linux 系统数据管理的终极工具</title>
		<link>https://www.linuxmi.com/linux-dd-command.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linux-dd-command</link>
					<comments>https://www.linuxmi.com/linux-dd-command.html#respond</comments>
		
		<dc:creator><![CDATA[linuxmi]]></dc:creator>
		<pubDate>Wed, 14 Aug 2024 02:41:50 +0000</pubDate>
				<category><![CDATA[Linux教程]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux命令]]></category>
		<guid isPermaLink="false">https://www.linuxmi.com/?p=25139</guid>

					<description><![CDATA[<p>dd命令是一款功能强大的工具，用于在Linux系统上进行底层数据复制和转换。dd代表“数据复制器”（ &#8230;</p>
<p>The post <a href="https://www.linuxmi.com/linux-dd-command.html">掌握 dd 命令：Linux 系统数据管理的终极工具</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>dd命令是一款功能强大的工具，用于在Linux系统上进行底层数据复制和转换。dd代表“数据复制器”（data duplicator），常被用来创建文件、分区或整个磁盘的精确副本，因此在创建备份、克隆硬盘或将磁盘映像写入物理介质时非常有用。这个命令可以在文件或设备之间复制和转换数据，并提供了控制块大小、跳过或查找数据，甚至应用压缩或字节交换等过滤器的选项。由于它可以在如此基础的层面上工作，使用dd时必须非常谨慎，因为错误的使用可能导致数据丢失或损坏。</p>
<p>在本教程中，我们将通过一些易于理解的例子来讨论该工具的工作原理。但在此之前，值得一提的是，这里提到的所有示例都在Ubuntu 24.04上进行了测试。</p>
<h3><strong>Linux dd命令简介 </strong></h3>
<p>简而言之，dd命令允许你复制和转换文件。这个工具提供了一些操作数，你可以使用它们来指定你想要的格式。以下是man手册中描述的命令通用语法：</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">dd [参数]... 
dd [选项]</code></pre>
</div>
</div>
<h3><strong>使用dd命令从ISO文件创建可启动的USB驱动器 </strong></h3>
<p>在Linux中，dd命令的一个常见用途是从ISO文件创建可启动的USB驱动器。这通常在准备安装操作系统的USB盘时使用。命令如下所示：</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">sudo dd if=/path/to/your.iso of=/dev/sdX bs=4M status=progress &amp;&amp; sync</code></pre>
</div>
</div>
<p>在这个例子中：</p>
<ul>
<li><code>if=/path/to/your.iso</code> 指定了输入文件，即ISO映像。</li>
<li><code>of=/dev/sdX</code> 指定了输出文件，即USB驱动器（将X替换为你USB设备的对应字母）。</li>
<li><code>bs=4M</code> 设置块大小为4兆字节，优化了复制过程。</li>
<li><code>status=progress</code> 提供了复制过程的实时更新。</li>
<li><code>sync</code> 确保在完成之前所有数据都写入到USB驱动器。</li>
</ul>
<p>这个命令将创建一个可启动的USB驱动器，可以用于安装ISO文件中包含的操作系统。</p>
<h3><strong>常见问题解答 </strong></h3>
<p>以下是一些问答式的例子，可以帮助你更好地了解dd命令的使用方法。</p>
<p><strong>Q1. 如何使用dd命令更改输入文本的大小写？</strong></p>
<p>假设你有一些用小写字母写的文本行，现在需要快速将它们转换为大写字母。你可以使用conv命令行选项（其值为ucase）来实现。</p>
<p>例如：</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25140" src="https://www.linuxmi.com/wp-content/uploads/2024/08/1.png" alt="" width="1014" height="273" /></p>
<p>以下是命令及输入文本的截图。按下组合键Ctrl+d后，dd命令识别到输入结束，随后生成以下输出：</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25141" src="https://www.linuxmi.com/wp-content/uploads/2024/08/2.png" alt="" width="1014" height="574" /></p>
<p>如你所见，输入的文本已从小写转换为大写。最后三行只是一些操作相关的统计信息。</p>
<p><strong>注意</strong>：同样地，你也可以使用<code>lcase</code>选项将大写字母转换为小写。</p>
<p><strong>Q2. 如何从文件读取并写入文件？</strong></p>
<p>在上面的例子中，我们通过标准输入（stdin）输入了文本。不过，你也可以使用输入和输出文件。要指定输入和输出文件的名称，可以使用<code>if</code>和<code>of</code>命令行选项。</p>
<p>例如，如果你想将file1中的文本大小写转换后写入file2，可以这样做：</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">dd if=file1 of=file2 conv=ucase</code></pre>
</div>
</div>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25142" src="https://www.linuxmi.com/wp-content/uploads/2024/08/3.png" alt="" width="1014" height="574" /></p>
<p><strong>Q3. 如何在读取输入时跳过文本？</strong></p>
<p>如果你希望在读取输入文本时跳过一些初始字节，可以使用<code>skip</code>选项，该选项需要一个数值。如果这个值为&#8217;N&#8217;，dd会跳过输入开头的N个<code>ibs</code>大小的块。这就引出了<code>ibs</code>选项，它用来指定工具每次读取的字节数（默认是512）。</p>
<p>假设你想跳过输入文件的前6个字节，你需要先将<code>ibs</code>设为6，然后将<code>skip</code>值设为1，这样工具在读取输入文件时就会跳过1个6字节的块。</p>
<p>所以你可以看到，读取file1时&#8221;hello!&#8221;被跳过了——这就是它没有出现在file2中的原因。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25143" src="https://www.linuxmi.com/wp-content/uploads/2024/08/4.png" alt="" width="1014" height="445" /></p>
<p><strong>Q4. 如何在输出中交换每对输入字节？</strong></p>
<p>如果你有这样的需求，可以使用dd命令交换每对输入字节。你可以通过为<code>conv</code>选项设置<code>swab</code>值来实现。以下截图可以更清楚地说明这一点：</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25144" src="https://www.linuxmi.com/wp-content/uploads/2024/08/5.png" alt="" width="1029" height="402" /></p>
<p><strong>Q5. 如何让dd命令只在输出文件不存在时才工作？</strong></p>
<p>如果你希望dd命令在输出文件已经存在时不进行任何操作，可以使用<code>conv</code>选项的<code>excl</code>值来实现这一条件。</p>
<p>下面的截图展示了这一用法：</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25145" src="https://www.linuxmi.com/wp-content/uploads/2024/08/6.png" alt="" width="1029" height="230" /></p>
<p><strong>Q6. 如何确保在追加模式下更新输出文件？</strong></p>
<p>默认情况下，dd会覆盖已有的输出文件。如果你希望dd命令将文本追加到输出文件的末尾，可以使用<code>oflag</code>选项中的<code>append</code>值和<code>conv</code>选项中的<code>notrunc</code>值。</p>
<p>例如：</p>
<div class="dark bg-gray-950 rounded-md border-[0.5px] border-token-border-medium">
<div class="overflow-y-auto p-4" dir="ltr">
<pre class="pure-highlightjs"><code class="null">dd if=file1 of=file3 oflag=append conv=notrunc</code></pre>
</div>
</div>
<p>以下是该命令的实际操作示例：</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25146" src="https://www.linuxmi.com/wp-content/uploads/2024/08/7.png" alt="" width="1029" height="961" /></p>
<p><strong>Q7. 如何让dd命令不创建输出文件？</strong></p>
<p>如果你希望dd命令在输出文件不存在时不创建该文件，可以使用<code>conv</code>选项的<code>nocreat</code>值。</p>
<p>例如：</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-25147" src="https://www.linuxmi.com/wp-content/uploads/2024/08/8.png" alt="" width="1029" height="445" /></p>
<p><strong>Q8. 如何控制stderr上的信息级别？</strong></p>
<p>如果你想限制dd命令在stderr上输出的信息量，可以使用<code>status</code>选项。例如，如果你只想显示错误信息，可以将该选项的值设置为<code>none</code>：</p>
<pre class="pure-highlightjs"><code class="null">dd if=file1 of=file3 status=none</code></pre>
<p>其他可用值包括noxfer和progress。以下是man手册对status选项的说明：</p>
<p>status=LEVEL 打印到stderr的信息级别；<br />
&#8216;none&#8217; 仅显示错误信息，&#8217;noxfer&#8217; 抑制最终传输统计信息，&#8217;progress&#8217; 显示定期传输统计信息。</p>
<h3><strong>结论</strong></h3>
<p>本教程中讨论的这些示例只是dd命令功能的一部分。实际上，你可以使用dd命令创建虚拟文件系统以及对硬盘或系统分区进行备份。想要了解更多关于dd命令的信息，可以查阅它的<a href="https://linux.die.net/man/1/dd" target="_blank" rel="nofollow noopener">man手册</a>。</p><p>The post <a href="https://www.linuxmi.com/linux-dd-command.html">掌握 dd 命令：Linux 系统数据管理的终极工具</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.linuxmi.com/linux-dd-command.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Amber：用高级语言编写 Bash 脚本的新革命</title>
		<link>https://www.linuxmi.com/amber-bash.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=amber-bash</link>
					<comments>https://www.linuxmi.com/amber-bash.html#respond</comments>
		
		<dc:creator><![CDATA[linuxmi]]></dc:creator>
		<pubDate>Thu, 20 Jun 2024 00:52:23 +0000</pubDate>
				<category><![CDATA[Linux教程]]></category>
		<category><![CDATA[Amber]]></category>
		<category><![CDATA[bash]]></category>
		<guid isPermaLink="false">https://www.linuxmi.com/?p=24858</guid>

					<description><![CDATA[<p>Bash 脚本需要改进吗？ 也许不需要，但 Amber 认为至少可以用高级编程语言来编写 Bash  &#8230;</p>
<p>The post <a href="https://www.linuxmi.com/amber-bash.html">Amber：用高级语言编写 Bash 脚本的新革命</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Bash 脚本需要改进吗？</p>
<p>也许不需要，但 Amber 认为至少可以用高级编程语言来编写 Bash 脚本。</p>
<p>高级编程语言更接近人类语言，用更容易理解和编写的语言编写代码。</p>
<h3>Amber：一种编译成 Bash 的编程语言</h3>
<p>Amber 让你可以更轻松地用高级编程语言来编写 Bash 脚本。怎么做到的呢？让我们来看看。</p>
<p>Amber 是一个可以编译成 Bash 脚本的编程语言。</p>
<p><strong>🚧 请注意：这个项目目前处于开发初期，只有一个 alpha 版本。如果你愿意可以尝试，但不要在生产环境中使用它。</strong></p>
<p>Amber 基于 ECMA 脚本语法设计。ECMA 旨在标准化通用脚本语言的语法。通过这种方式，你可以在遵循 ECMA 语法的各种脚本语言中使用熟悉的语法。</p>
<h3>使用 Amber</h3>
<p>你可以用 Amber 编写脚本，然后编译成 Bash 脚本，或者直接运行 Amber 脚本：</p>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com
 % amber linuxmi.ab </code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-24860" src="https://www.linuxmi.com/wp-content/uploads/2024/06/amner2.png" alt="" width="1194" height="918" /></p>
<p>如果你愿意，你也可以将 Amber 脚本编译成一个 Bash 脚本，然后在任何需要的地方使用这个 Bash 脚本。例如，我编写了一个 Amber 脚本示例，并在系统上运行，结果与 Bash 脚本相同。</p>
<pre class="pure-highlightjs"><code class="null">// 定义变量
let name = "linuxmi"
let age = 30

// 显示问候语
echo "你好, 我是 {name}"

// 执行条件检查
if age &lt; 18 {
    echo "我还不是成年人" // 我还不是成年人
} else {
    echo "我是成年人" // 我是成年人
}

// 遍历数组
let fruits = ["苹果", "香蕉", "<span data-slate-fragment="JTVCJTdCJTIydHlwZSUyMiUzQSUyMnBhcmFncmFwaCUyMiUyQyUyMmNoaWxkcmVuJTIyJTNBJTVCJTdCJTIyaWQlMjIlM0ElMjJEanFnbmtnbHdlJTIyJTJDJTIycGFyYUlkeCUyMiUzQTAlMkMlMjJzcmMlMjIlM0ElMjJjaGVycnklMjBkYXRlJTIyJTJDJTIyZHN0JTIyJTNBJTIyJUU2JUE4JUIxJUU2JUExJTgzJUU2JTlFJUEzJTIyJTJDJTIybWV0YWRhdGElMjIlM0ElMjIlMjIlMkMlMjJtZXRhRGF0YSUyMiUzQSU1QiU1RCUyQyUyMnRleHQlMjIlM0ElMjIlRTYlQTglQjElRTYlQTElODMlRTYlOUUlQTMlMjIlN0QlNUQlN0QlNUQ=">樱桃</span>", "<span data-slate-fragment="JTVCJTdCJTIydHlwZSUyMiUzQSUyMnBhcmFncmFwaCUyMiUyQyUyMmNoaWxkcmVuJTIyJTNBJTVCJTdCJTIyaWQlMjIlM0ElMjJEanFnbmtnbHdlJTIyJTJDJTIycGFyYUlkeCUyMiUzQTAlMkMlMjJzcmMlMjIlM0ElMjJjaGVycnklMjBkYXRlJTIyJTJDJTIyZHN0JTIyJTNBJTIyJUU2JUE4JUIxJUU2JUExJTgzJUU2JTlFJUEzJTIyJTJDJTIybWV0YWRhdGElMjIlM0ElMjIlMjIlMkMlMjJtZXRhRGF0YSUyMiUzQSU1QiU1RCUyQyUyMnRleHQlMjIlM0ElMjIlRTYlQTglQjElRTYlQTElODMlRTYlOUUlQTMlMjIlN0QlNUQlN0QlNUQ=">枣</span>"]
echo "我最喜欢的水果是:" // 我最喜欢的水果是：
loop fruit in fruits {
    echo fruit // 输出每个水果
}
</code></pre>
<p>然后将其编译成 Bash 脚本：</p>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com
 % amber linuxmi.ab linuxmi.sh
linuxmi@linuxmi ~/www.linuxmi.com
 % ./linuxmi.sh</code></pre>
<p>生成的 linuxmi.sh 文件包含：</p>
<pre class="pure-highlightjs"><code class="null">#!/usr/bin/env bash
# Written in [Amber](https://amber-lang.com/)

__0_name="linuxmi"
__1_age=30
echo "你好, 我是 ${__0_name}"
if [ $(echo ${__1_age} '&lt;' 18 | bc -l | sed '/\./ s/\.\{0,1\}0\{1,\}$//') != 0 ]; then
    echo "我还不是成年人"
else
    echo "我是成年人"
fi
__AMBER_ARRAY_0=("苹果" "香蕉" "樱桃" "枣");
__2_fruits=("${__AMBER_ARRAY_0[@]}")
echo "我最喜欢的水果是:"
for fruit in "${__2_fruits[@]}"
do
    echo "${fruit}"
done</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-24859" src="https://www.linuxmi.com/wp-content/uploads/2024/06/amber3.png" alt="" width="1194" height="1004" /></p>
<p>Amber 旨在提供一个类型安全和运行时安全的编程语言，能够在编译过程中处理错误和疏漏。它抛出的警告比处理 Bash 脚本语法错误时的盲猜游戏更容易理解。比如，“syntax error: unexpected end of file”并不足以让你理解 Bash 脚本中的语法错误，对吧？</p>
<p>这个功能本身就可以为那些刚接触 Bash 脚本的新手省去很多头痛的问题。</p>
<p>Amber 是一个开源项目，采用 GPL 3.0 许可证。</p>
<h3>在 Linux 上安装 Amber</h3>
<p>要在 Linux 上安装 Amber 语言，你可以使用这个 Bash 脚本（这有点讽刺）。你需要有 sudo 权限。</p>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com
 % curl -s "https://raw.githubusercontent.com/Ph0enixKM/AmberNative/master/setup/install.sh" | bash

Installing Amber... 🚀
[sudo] linuxmi 的密码： 
Amber has been installed successfully. 🎉
&gt; Now you can use amber by typing `amber` in your terminal.</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-24861" src="https://www.linuxmi.com/wp-content/uploads/2024/06/amber.png" alt="" width="1194" height="746" /></p>
<p>输出中的那些表情符号表明 Amber 的目标用户（或开发者）是 Z 世代的 Linux 用户。典型的系统管理员会使用带有颜色输出的 echo 命令 😉</p>
<p>Amber 有相当不错的<a href="https://docs.amber-lang.com/?ref=www.linuxmi.com" target="_blank" rel="nofollow noopener">文档</a>，可以帮助你入门这个脚本语言。</p><p>The post <a href="https://www.linuxmi.com/amber-bash.html">Amber：用高级语言编写 Bash 脚本的新革命</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.linuxmi.com/amber-bash.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Ubuntu 上镜像 iPhone 屏幕，UxPlay 带来全新体验</title>
		<link>https://www.linuxmi.com/uxplay-ubuntu-iphone.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=uxplay-ubuntu-iphone</link>
					<comments>https://www.linuxmi.com/uxplay-ubuntu-iphone.html#respond</comments>
		
		<dc:creator><![CDATA[linuxmi]]></dc:creator>
		<pubDate>Wed, 13 Mar 2024 11:51:04 +0000</pubDate>
				<category><![CDATA[Linux教程]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[UxPlay]]></category>
		<guid isPermaLink="false">https://www.linuxmi.com/?p=24224</guid>

					<description><![CDATA[<p>想不想在 Ubuntu 桌面上镜像你的 iPhone 屏幕？现在在 Ubuntu 软件源中有一个免费 &#8230;</p>
<p>The post <a href="https://www.linuxmi.com/uxplay-ubuntu-iphone.html">Ubuntu 上镜像 iPhone 屏幕，UxPlay 带来全新体验</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>想不想在 Ubuntu 桌面上镜像你的 iPhone 屏幕？现在在 Ubuntu 软件源中有一个免费的开源应用程序可以帮你实现这个目标。</p>
<p>如果你想在 Ubuntu 上镜像你的 iPhone 或 iPad，UxPlay 是一种简单的方法 — 而且它是免费的、开源软件。</p>
<p>这个应用叫做 UxPlay，安装后，你可以快速将你的 iPhone（或 iPad）屏幕与 Ubuntu 共享，还可以带有音频，而且你不需要在你的苹果设备上安装任何应用程序来使用它。</p>
<p>你苹果设备屏幕上显示的任何内容都会实时流到你的桌面上，显示在一个浮动窗口中，你可以自由地在桌面上移动或全屏显示。</p>
<h2><strong>它是如何工作的？</strong></h2>
<p>UxPlay 使用 AirPlay，这是苹果内置的屏幕共享技术 — — 无需越狱或有线连接，只需要一个支持 AirPlay 的设备（即 iPhone 4 或更高版本）和一个正常的网络连接。</p>
<p>现在，苹果在 2017 年重新设计了 AirPlay（AirPlay 2），但仍继续包含这个应用程序使用的“旧协议”，以在 Linux 上启用屏幕镜像。苹果可能会在将来的更新中删除旧的协议，但截至 iOS 17.x，它仍然存在并且可以正常使用。</p>
<p>如果你想将你的 iPhone 或 iPad 镜像到 Ubuntu 上，使用 UxPlay 是实现这一目标的简单方式 — — 而且它完全免费、开源，非常棒！</p>
<p>UxPlay 只能镜像你的屏幕（以及它的音频），所以你不能与所见之物进行交互。但镜像有许多用途：它可以帮助你在工作中进行协作、共享演示文稿、演示代码、艺术作品或其他内容，可以在流媒体或视频通话中进行观看/听取设备上的内容，等等。</p>
<p>由于 UxPlay 使用了硬件加速的 H.264 解码器（在可用时，如果没有，它会退回到软件解码）通过 GStreamer 插件，性能很好，视频流畅，几乎没有停顿、卡顿和丢帧 。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-24228" src="https://www.linuxmi.com/wp-content/uploads/2024/03/uxplay-ubuntu-iphone-1.png" alt="" width="1920" height="1080" /></p>
<h2><strong>你可以将屏幕共享全屏显示</strong></h2>
<p>除了 AirPlay 镜像模式（用于投射屏幕及其有损压缩的 AAC 音频）之外，UxPlay 还支持 AirPlay 音频模式，用于苹果无损 (ALAC) 音频（意味着只有音频，没有视频），可以播放设备上的任何内容。</p>
<p>所以，如果你只想听 iPad 或 iPhone 上的某些内容，并通过桌面或笔记本电脑的扬声器听到它，使用该功能可以获得最佳的音频质量。</p>
<p><strong>要与 Ubuntu 共享你的 iPhone/iPad 屏幕：</strong></p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-24227" src="https://www.linuxmi.com/wp-content/uploads/2024/03/uxplay-ubuntu-iphone-2.png" alt="" width="1920" height="1080" /></p>
<p>安装 UxPlay。在 Ubuntu 软件中心或应用中心中搜索它，或打开一个终端窗口，运行 sudo apt install uxplay 来安装它。</p>
<p>安装所需的 GStreamer 插件。没有这些插件，应用程序将无法工作。运行 sudo apt install gstreamer1.0-plugins-bad gstreamer1.0-libav 来安装它们。</p>
<p>通过在终端中运行 uxplay 来启动 UxPlay。</p>
<p>在你的 iPhone/iPad 上打开控制中心（从屏幕右上角向下滑动），点击屏幕镜像图标（重叠的方块），从列表中选择“UxPlay”。<br />
是的，你现在可以在 UxPlay 中立即查看你的智能手机或平板电脑屏幕上显示的内容了。</p>
<p>当你完成时，通过你的 iPhone 断开连接，并关闭桌面上的 UxPlay 窗口（如果它没有自动关闭的话）。然后，在终端中按下键盘上的 ctrl + c 键来结束 UxPlay 进程。</p>
<h2><strong>UxPlay 不能做的事情</strong></h2>
<p>使用这个应用程序无法镜像 DRM 视频</p>
<p>有时会将 <a href="https://github.com/FDH2/UxPlay" target="_blank" rel="nofollow noopener">UxPlay</a> 称为“iPhone 的 Scrpy”或“免费的 Vysor 替代品”，但它不是。与这两个应用程序不同，UxPlay 只是一个镜像工具，不允许你使用鼠标和键盘从计算机上与设备进行交互。</p>
<p>还有其他限制。你不能通过 UxPlay“看到”受 DRM 加密的苹果视频内容（例如 Apple TV 应用程序、亚马逊 Prime 和其他应用程序中的内容）。</p>
<p>最后，无法进行非镜像 AirPlay2 视频流传输。这意味着你不能打开一个应用程序，点击原生的“投射”图标，选择 UxPlay，并将视频流绕过你的设备，直接重定向到应用程序。</p>
<p><strong>UxPlay 还可以做什么</strong></p>
<p>想要进一步配置吗？</p>
<p>UxPlay 的 Github 页面提供了许多可用选项的详细信息，包括旋转屏幕、指定帧率（有助于提高性能）、禁用视频以进行仅音频流、选择特定的解码器等等。</p>
<p>如果你想“硬编码”选项而不必手动传递它们，你可以编辑工具的配置文件，否则只需根据需要运行它们即可。</p>
<p><strong>一些有用的选项：</strong></p>
<ul>
<li>设置分辨率：使用 -s 标志加上分辨率，例如，uxplay -s 1920&#215;1080</li>
<li>旋转屏幕：在连接之前传递 -r 加上 L 或 R</li>
<li>进入全屏模式：在键盘上按 F11 键（再按一次退出）或传递 -fs</li>
</ul>
<p>有趣的是，UxPlay 能够在树莓派 4B（以及更早版本）上使用 Video4Linux2 进行硬件加速解码，但这可能会因发行版而异。在树莓派 4 上的 Ubuntu 中，这应该会自动工作。</p>
<h2><strong>总结</strong></h2>
<p>这就是你可以将 iPhone 或 iPad 屏幕分享到运行 Ubuntu 的任何台式电脑或笔记本电脑的方法。</p>
<p>还有其他可用的选项，许多功能更强大，但大多数是付费软件，只能在 Windows 或 macOS 上使用，并涉及从 App Store 安装应用程序。</p>
<p>但是，对于一个简单的自由开源软件方法来说，这是无与伦比的。</p>
<p><span style="color: #ff0000;"><strong>Ubuntu 上镜像 iPhone 屏幕视频演示请用微信扫描关注以下视频号：</strong></span></p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-24230" src="https://www.linuxmi.com/wp-content/uploads/2024/03/videocode.png" alt="" width="500" height="500" /></p><p>The post <a href="https://www.linuxmi.com/uxplay-ubuntu-iphone.html">Ubuntu 上镜像 iPhone 屏幕，UxPlay 带来全新体验</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.linuxmi.com/uxplay-ubuntu-iphone.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Ubuntu 上安装 FreeNginx 的终极指南</title>
		<link>https://www.linuxmi.com/ubuntu-freenginx.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ubuntu-freenginx</link>
					<comments>https://www.linuxmi.com/ubuntu-freenginx.html#respond</comments>
		
		<dc:creator><![CDATA[linuxmi]]></dc:creator>
		<pubDate>Wed, 21 Feb 2024 11:59:49 +0000</pubDate>
				<category><![CDATA[Linux教程]]></category>
		<category><![CDATA[FreeNginx]]></category>
		<category><![CDATA[Nginx]]></category>
		<guid isPermaLink="false">https://www.linuxmi.com/?p=24080</guid>

					<description><![CDATA[<p>FreeNginx 在 NGINX 核心开发者因内部冲突和政策变化而辞职后引起了很多关注，他启动了自 &#8230;</p>
<p>The post <a href="https://www.linuxmi.com/ubuntu-freenginx.html">Ubuntu 上安装 FreeNginx 的终极指南</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>FreeNginx 在 NGINX 核心开发者因内部冲突和政策变化而辞职后引起了很多关注，他启动了自己的 FreeNginx 项目，一个重视社区贡献胜过公司利益的自由开源版本。</p>
<p>目前，这个项目还很新，你几乎找不到在使用上的任何差异，但未来有望迅速改进、修复问题，并引入令人兴奋的新功能。</p>
<p>如果你想尝试一下，那么请阅读本文的全部内容，了解如何使用实际示例从源代码在Ubuntu上安装FreeNginx。</p>
<p>相关：Nginx 新篇章：开发者拒绝妥协，启动 FreeNginx <a href="https://www.linuxmi.com/nginx-to-freenginx.html">https://www.linuxmi.com/nginx-to-freenginx.html</a></p>
<h2><strong>如何在Ubuntu上安装FreeNginx</strong></h2>
<p>在撰写本文时，安装FreeNginx的唯一可用选项是通过Linux源代码；对于Windows用户，可以在下载部分找到压缩文件。</p>
<p>在本文中，我们将专注于在Ubuntu上安装FreeNginx，所以请逐一按照下面提到的每个步骤进行操作。</p>
<p>1、打开终端，并执行以下命令以更新系统仓库信息：</p>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com/freenginx-1.25.4
 % sudo apt update</code></pre>
<p>2、安装所需的软件包、依赖项和库，以及用于源代码编译的开发工具。</p>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com
 % sudo apt install -y wget build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev libgd-dev libxml2 libxml2-dev uuid-dev
</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-24084" src="https://www.linuxmi.com/wp-content/uploads/2024/02/freenginx2.png" alt="" width="966" height="626" /></p>
<p>3、停止并移除系统中现有的NGINX，以避免以后可能出现的潜在冲突问题。</p>
<p>打开终端，并执行以下命令以更新系统仓库信息：</p>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com/freenginx-1.25.4
 % sudo apt --purge remove nginx-*</code></pre>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com/freenginx-1.25.4
 % sudo apt autoremove</code></pre>
<p>4、现在，访问官方的<a href="https://freenginx.org/en/download.html" target="_blank" rel="nofollow noopener">FreeNginx下载页面</a>，并下载您希望安装的FreeNginx版本（主线版本、稳定版本或遗留版本）的源代码压缩包文件。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-24081" src="https://www.linuxmi.com/wp-content/uploads/2024/02/freenginxd.png" alt="" width="838" height="401" /></p>
<p>作为另一种选择，您还可以通过终端使用wget命令进行下载。</p>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com
 % wget https://freenginx.org/download/freenginx-1.25.4.tar.gz</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-24083" src="https://www.linuxmi.com/wp-content/uploads/2024/02/freenginx3.png" alt="" width="966" height="696" /></p>
<p>5、解压下载的压缩包文件，然后将其移动到提取的目录中。</p>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com
 % tar -zxvf freenginx-*.tar.gz &amp;&amp; cd freenginx*/</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-24082" src="https://www.linuxmi.com/wp-content/uploads/2024/02/freenginx4.png" alt="" width="966" height="696" /></p>
<p>6、使用配置标志为 NGINX 配置文件、访问日志和错误日志路径以及一些 NGINX 模块配置自定义路径。</p>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com/freenginx-1.25.4
 % ./configure --prefix=/var/www/html --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --with-pcre --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-http_ssl_module --with-http_image_filter_module=dynamic --modules-path=/etc/nginx/modules --with-http_v2_module --with-stream=dynamic --with-http_addition_module --with-http_mp4_module
</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-24085" src="https://www.linuxmi.com/wp-content/uploads/2024/02/freenginx1.png" alt="" width="966" height="346" /></p>
<p>7、配置完成后，继续使用以下两个命令编译 NGINX 源代码并安装它：</p>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com
 % make</code></pre>
<p>&nbsp;</p>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com
 % sudo make install</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-24088" src="https://www.linuxmi.com/wp-content/uploads/2024/02/freenginxd5.png" alt="" width="966" height="696" /></p>
<p>8、FreeNginx 现已成功安装；您可以检查其版本和配置选项。</p>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com/freenginx-1.25.4
 % nginx -v
nginx version: freenginx/1.25.4
linuxmi@linuxmi ~/www.linuxmi.com/freenginx-1.25.4
 % nginx -V</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-24089" src="https://www.linuxmi.com/wp-content/uploads/2024/02/freenginxd6.png" alt="" width="966" height="731" /></p>
<p>9、现在，如果 Nginx 已经在运行，请停止它，然后在 /lib/systemd/system 路径下创建一个 Freenginx systemd 单元文件，用于管理 Freenginx。</p>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com/freenginx-1.25.4
 % nginx -s stop</code></pre>
<pre class="pure-highlightjs"><code class="null">linuxmi@linuxmi ~/www.linuxmi.com/freenginx-1.25.4
 % sudo vi /lib/systemd/system/nginx.service</code></pre>
<p>然后粘贴此脚本：</p>
<pre class="pure-highlightjs"><code class="null">[Unit]
Description=The Freenginx HTTP and reverse proxy server
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
        
[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
        
[Install]
WantedBy=multi-user.target</code></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-24090" src="https://www.linuxmi.com/wp-content/uploads/2024/02/freenginx7.png" alt="" width="966" height="731" /></p>
<p>现在，按下 <strong><span style="color: #ff0000;">Esc</span></strong> 键退出编辑模式，然后输入<span style="color: #ff0000;"><strong> :</strong></span>，接着写入并执行 <span style="color: #ff0000;"><strong>wq!</strong> </span>命令来保存文件。</p>
<p>完成！现在您可以使用 systemctl 命令来管理 FreeNginx，以下是一些可用于管理 FreeNginx 的 systemctl 命令示例：</p>
<table>
<thead>
<tr>
<th>命令</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>sudo systemctl status nginx</td>
<td>检查 FreeNginx 的状态。</td>
</tr>
<tr>
<td>sudo systemctl enable nginx</td>
<td>在启动时自动启动 FreeNginx。</td>
</tr>
<tr>
<td>sudo systemctl start nginx</td>
<td>启动 FreeNginx 服务器。</td>
</tr>
<tr>
<td>sudo systemctl stop nginx</td>
<td>停止 FreeNginx 服务器。</td>
</tr>
<tr>
<td>sudo systemctl disable nginx</td>
<td>在启动时禁用 FreeNginx 的自动启动。</td>
</tr>
</tbody>
</table><p>The post <a href="https://www.linuxmi.com/ubuntu-freenginx.html">Ubuntu 上安装 FreeNginx 的终极指南</a> first appeared on <a href="https://www.linuxmi.com">Linux迷</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.linuxmi.com/ubuntu-freenginx.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
