<?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>命令行安全 &#8211; mylogs.cn</title>
	<atom:link href="https://mylogs.cn/tag/%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%ae%89%e5%85%a8/feed/" rel="self" type="application/rss+xml" />
	<link>https://mylogs.cn</link>
	<description>发现、记录、分享</description>
	<lastBuildDate>Fri, 07 Aug 2026 16:02:44 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>AI 帮你写代码，这条命令千万别放行</title>
		<link>https://mylogs.cn/ai-%e5%b8%ae%e4%bd%a0%e5%86%99%e4%bb%a3%e7%a0%81%ef%bc%8c%e8%bf%99%e6%9d%a1%e5%91%bd%e4%bb%a4%e5%8d%83%e4%b8%87%e5%88%ab%e6%94%be%e8%a1%8c/</link>
					<comments>https://mylogs.cn/ai-%e5%b8%ae%e4%bd%a0%e5%86%99%e4%bb%a3%e7%a0%81%ef%bc%8c%e8%bf%99%e6%9d%a1%e5%91%bd%e4%bb%a4%e5%8d%83%e4%b8%87%e5%88%ab%e6%94%be%e8%a1%8c/#respond</comments>
		
		<dc:creator><![CDATA[steve, zhang]]></dc:creator>
		<pubDate>Fri, 07 Aug 2026 16:02:44 +0000</pubDate>
				<category><![CDATA[经验与技巧]]></category>
		<category><![CDATA[AI编程]]></category>
		<category><![CDATA[Claude Code]]></category>
		<category><![CDATA[命令行安全]]></category>
		<category><![CDATA[开发工具]]></category>
		<category><![CDATA[数据安全]]></category>
		<guid isPermaLink="false">https://mylogs.cn/ai-%e5%b8%ae%e4%bd%a0%e5%86%99%e4%bb%a3%e7%a0%81%ef%bc%8c%e8%bf%99%e6%9d%a1%e5%91%bd%e4%bb%a4%e5%8d%83%e4%b8%87%e5%88%ab%e6%94%be%e8%a1%8c/</guid>

					<description><![CDATA[用 Claude Code、Codex 或谷歌 Antigravity 写代码，很容易进入「一路顺风」的状态： [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">用 Claude Code、Codex 或谷歌 Antigravity 写代码，很容易进入「一路顺风」的状态：指个项目、说清需求，代码哗哗往外冒。但模型再强也会犯错，大部分错顶多浪费点时间和额度。真正要命的是另一类——PCWorld 资深撰稿人 Ben Patterson 在相关社区里反复看到同一种惨案，起因几乎都是同一条命令：<code>rm -rf</code>。</p>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6a7606595ebdb&quot;}" data-wp-interactive="core/image" data-wp-key="6a7606595ebdb" class="wp-block-image size-large aligncenter wp-lightbox-container"><img fetchpriority="high" decoding="async" width="1024" height="683" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://mylogs.cn/wp-content/uploads/2026/08/3d62794eb759773e645866d35317ef37_header.webp" alt="AI 帮你写代码，这条命令千万别放行" class="wp-image-3990" style="max-width:100%;height:auto;" srcset="https://mylogs.cn/wp-content/uploads/2026/08/3d62794eb759773e645866d35317ef37_header.webp 1024w, https://mylogs.cn/wp-content/uploads/2026/08/3d62794eb759773e645866d35317ef37_header-300x200.webp 300w, https://mylogs.cn/wp-content/uploads/2026/08/3d62794eb759773e645866d35317ef37_header-768x512.webp 768w" sizes="(max-width: 1024px) 100vw, 1024px" /><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button><figcaption class="wp-element-caption">图片来源：PCWorld</figcaption></figure>





<p class="wp-block-paragraph">有位用户的原话是：让 Claude Opus 5 建个备份，结果它把备份建到了错误的目录，然后直接 <code>rm -rf</code> 清空了整块硬盘。删完之后回了三个字：「抱歉，手误。」</p>



<h2 class="wp-block-heading">先看懂这条命令有多狠</h2>



<p class="wp-block-paragraph"><code>rm</code> 是 Linux 里删除文件的标准命令，单用破坏力有限。加上 <code>-r</code>（递归）和 <code>-f</code>（强制）就变了性质——一个目录连同所有文件和子目录，几秒钟内全部消失，不进回收站，不给确认。</p>



<p class="wp-block-paragraph">最危险的是它出现在用户主目录附近。比如 <code>rm -rf /Users/benpatt/deleteme</code>，本意只是删主目录下那个 deleteme 文件夹；路径尾巴那段一漏，主目录里的东西一次性全没。更极端的是 <code>sudo rm -rf /</code>，sudo 让你变成超级用户，单独一个 <code>/</code> 是系统根目录，这条下去整块盘清空。</p>



<h2 class="wp-block-heading">三条防线，现在就能设</h2>



<ol class="wp-block-list"><li><strong>看到就打断。</strong> AI 清理旧目录、做收尾时会主动建议这条命令，别顺手点通过。回它一句：「别用 rm -rf，换一种更安全的删除方式。」</li><li><strong>把规矩写进配置文件。</strong> Claude 的 <code>CLAUDE.md</code>、Codex 的 <code>AGENTS.md</code> 里加一条硬规则，Ben Patterson 给的原文可以照抄：<code>Never run rm -rf or any equivalent recursive, forced deletion — including reordered flags, aliases, shell wrappers, scripts, find -delete, or git clean -fdx.</code>（禁止运行 rm -rf 及任何等效的递归强制删除，包括调换参数顺序、别名、shell 包装、脚本、find -delete 和 git clean -fdx）。堵住变体这句是关键，否则换个写法照样绕过去。</li><li><strong>别撒手不管。</strong> 质疑它的逻辑、复核它的决定，这不是不信任 AI，是基本的工程习惯。</li></ol>



<p class="wp-block-paragraph">我的判断是，很多人还没意识到自己已经换了身份——只要在用 Claude Code 或 Codex，你就是个 Linux 用户，该有的敬畏心一样都不能少。少一个斜杠的代价，AI 不会帮你承担。</p>



<p class="wp-block-paragraph">来源：PCWorld</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mylogs.cn/ai-%e5%b8%ae%e4%bd%a0%e5%86%99%e4%bb%a3%e7%a0%81%ef%bc%8c%e8%bf%99%e6%9d%a1%e5%91%bd%e4%bb%a4%e5%8d%83%e4%b8%87%e5%88%ab%e6%94%be%e8%a1%8c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
