<?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 &#8211; 良的世界</title>
	<atom:link href="https://www.lemonary.cn/category/%E5%B7%A5%E4%BD%9C/linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lemonary.cn</link>
	<description></description>
	<lastBuildDate>Thu, 27 Mar 2025 06:33:58 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.lemonary.cn/wp-content/uploads/2024/12/profile-150x150.jpg</url>
	<title>Linux &#8211; 良的世界</title>
	<link>https://www.lemonary.cn</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>find命令之-perm参数</title>
		<link>https://www.lemonary.cn/find%e5%91%bd%e4%bb%a4%e4%b9%8b-perm%e5%8f%82%e6%95%b0/</link>
					<comments>https://www.lemonary.cn/find%e5%91%bd%e4%bb%a4%e4%b9%8b-perm%e5%8f%82%e6%95%b0/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Thu, 27 Mar 2025 06:31:58 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[find]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1816</guid>

					<description><![CDATA[一、准备工作 find命令的-perm参数选项有三种写法。下面创建一些文件，作为准备工作。 注意：每个文件的文 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">一、准备工作</h2>



<p class="wp-block-paragraph">find命令的-perm参数选项有三种写法。下面创建一些文件，作为准备工作。</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="468" height="444" src="https://www.lemonary.cn/wp-content/uploads/2025/03/image-123.png" alt="" class="wp-image-1817" srcset="https://www.lemonary.cn/wp-content/uploads/2025/03/image-123.png 468w, https://www.lemonary.cn/wp-content/uploads/2025/03/image-123-300x285.png 300w" sizes="(max-width: 468px) 100vw, 468px" /></figure>



<p class="wp-block-paragraph">注意：每个文件的文件名与其权限呈对应状态，便于我们观察现象。</p>



<h2 class="wp-block-heading">二、三种写法</h2>



<p class="wp-block-paragraph">（1）不带任何符号，表示精确匹配指定的权限</p>



<pre class="wp-block-code"><code>&#91;root@shine find-perm]# find . -perm 333
./333
&#91;root@shine find-perm]# find . -perm 666
没有匹配到文件</code></pre>



<p class="wp-block-paragraph">（2）权限前加一个“-”</p>



<pre class="wp-block-code"><code>&#91;root@shine find-perm]# find . -perm -444
./777
./644
./444
./755
./555</code></pre>



<p class="wp-block-paragraph">可以看到匹配到5个文件，需要注意的是，这里并不是比大小，用755为例：</p>



<ul class="wp-block-list">
<li>User：7=4+2+1。r+w+x</li>



<li>Group：5=4+1。w+x</li>



<li>Other：5=4+1。w+x</li>
</ul>



<p class="wp-block-paragraph">-perm -444表示3个权限位都至少要有4。也就是三个权限都必须包括写权限。</p>



<p class="wp-block-paragraph">（3）权限前加一个“/”</p>



<pre class="wp-block-code"><code>&#91;root@shine find-perm]# find . -perm /444
./777
./750
./400
./644
./444
./500
./755
./555
./700
./600</code></pre>



<p class="wp-block-paragraph">可以看到相比于“-”匹配到了更多的文件。以600为例：</p>



<ul class="wp-block-list">
<li>User：6=4+2。r+w</li>



<li>Group：0。</li>



<li>Other：0。</li>
</ul>



<p class="wp-block-paragraph">只有User权限下符合要求，仍然匹配成功，则说明“/”表示或者的意思，所以-perm /444就表示3个权限位中只要有一个符合匹配条件，剩下两个权限位就忽略不判断了。</p>



<h2 class="wp-block-heading">三、总结</h2>



<ul class="wp-block-list">
<li><code>find . -perm -444</code>：3个权限位都必须至少匹配指定的权限</li>



<li><code>find . -perm /444</code>：3个权限位中的任意一个匹配指定的权限</li>



<li><code>find . -perm 444</code>：精确匹配指定的权限</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/find%e5%91%bd%e4%bb%a4%e4%b9%8b-perm%e5%8f%82%e6%95%b0/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Linux脚本之登录系统时显示重要的指标状态</title>
		<link>https://www.lemonary.cn/linux%e8%84%9a%e6%9c%ac%e4%b9%8b%e7%99%bb%e5%bd%95%e7%b3%bb%e7%bb%9f%e6%97%b6%e6%98%be%e7%a4%ba%e9%87%8d%e8%a6%81%e7%9a%84%e6%8c%87%e6%a0%87%e7%8a%b6%e6%80%81/</link>
					<comments>https://www.lemonary.cn/linux%e8%84%9a%e6%9c%ac%e4%b9%8b%e7%99%bb%e5%bd%95%e7%b3%bb%e7%bb%9f%e6%97%b6%e6%98%be%e7%a4%ba%e9%87%8d%e8%a6%81%e7%9a%84%e6%8c%87%e6%a0%87%e7%8a%b6%e6%80%81/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Thu, 27 Mar 2025 01:40:20 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Script]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1807</guid>

					<description><![CDATA[一、脚本效果 另外指标可以根据数值显示不同的颜色，以提示指标的严重程度。 二、脚本内容 关注公众号，回复“sy [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">一、脚本效果</h2>



<figure class="wp-block-image size-full"><img decoding="async" width="700" height="669" src="https://www.lemonary.cn/wp-content/uploads/2025/03/image-122.png" alt="" class="wp-image-1811" srcset="https://www.lemonary.cn/wp-content/uploads/2025/03/image-122.png 700w, https://www.lemonary.cn/wp-content/uploads/2025/03/image-122-300x287.png 300w" sizes="(max-width: 700px) 100vw, 700px" /></figure>



<p class="wp-block-paragraph">另外指标可以根据数值显示不同的颜色，以提示指标的严重程度。</p>



<h2 class="wp-block-heading">二、脚本内容</h2>



<p class="wp-block-paragraph">关注公众号，回复“systemstatus”获取脚本。</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="932" height="1024" src="https://www.lemonary.cn/wp-content/uploads/2024/11/ea54ce754702f781b75ebc30ee29fe9-932x1024.jpg" alt="" class="wp-image-1487" style="width:327px;height:auto" srcset="https://www.lemonary.cn/wp-content/uploads/2024/11/ea54ce754702f781b75ebc30ee29fe9-932x1024.jpg 932w, https://www.lemonary.cn/wp-content/uploads/2024/11/ea54ce754702f781b75ebc30ee29fe9-273x300.jpg 273w, https://www.lemonary.cn/wp-content/uploads/2024/11/ea54ce754702f781b75ebc30ee29fe9-768x844.jpg 768w, https://www.lemonary.cn/wp-content/uploads/2024/11/ea54ce754702f781b75ebc30ee29fe9.jpg 1059w" sizes="(max-width: 932px) 100vw, 932px" /></figure>



<h2 class="wp-block-heading">三、脚本使用方法</h2>



<p class="wp-block-paragraph">将脚本赋予执行权限后放到<code>/etc/profile.d</code>目录下，该目录下的脚本会在用户登录时自动执行。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/linux%e8%84%9a%e6%9c%ac%e4%b9%8b%e7%99%bb%e5%bd%95%e7%b3%bb%e7%bb%9f%e6%97%b6%e6%98%be%e7%a4%ba%e9%87%8d%e8%a6%81%e7%9a%84%e6%8c%87%e6%a0%87%e7%8a%b6%e6%80%81/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>集群间服务器配置免密</title>
		<link>https://www.lemonary.cn/%e9%9b%86%e7%be%a4%e9%97%b4%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%85%8d%e7%bd%ae%e5%85%8d%e5%af%86/</link>
					<comments>https://www.lemonary.cn/%e9%9b%86%e7%be%a4%e9%97%b4%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%85%8d%e7%bd%ae%e5%85%8d%e5%af%86/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Tue, 25 Mar 2025 02:47:30 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[ssh]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1804</guid>

					<description><![CDATA[一、环境说明 集群中包括三台服务器 二、配置免密 （1）配置主机名映射（三台服务器均需操作） 重启ssh服务  [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">一、环境说明</h2>



<p class="wp-block-paragraph">集群中包括三台服务器</p>



<ul class="wp-block-list">
<li>192.168.241.131（dwp）</li>



<li>192.168.241.132（dws）</li>



<li>192.168.241.133（dwm）</li>
</ul>



<h2 class="wp-block-heading">二、配置免密</h2>



<h3 class="wp-block-heading">（1）配置主机名映射（三台服务器均需操作）</h3>



<pre class="wp-block-code"><code>vim /etc/hosts
192.168.241.131 dwp
192.168.241.132 dws
192.168.241.133 dwm</code></pre>



<p class="wp-block-paragraph">重启ssh服务</p>



<pre class="wp-block-code"><code>systemctl start sshd</code></pre>



<h3 class="wp-block-heading">（2）生成SSH密钥对（三台服务器均需操作）</h3>



<pre class="wp-block-code"><code>&#91;root@dwp ~]# ssh-keygen
多次回车
&#91;root@dwp ~]# ssh-copy-id 192.168.241.131
&#91;root@dwp ~]# ssh-copy-id 192.168.241.132
&#91;root@dwp ~]# ssh-copy-id 192.168.241.133
或者
&#91;root@dwp ~]# ssh-copy-id dwp
&#91;root@dwp ~]# ssh-copy-id dws
&#91;root@dwp ~]# ssh-copy-id dwm</code></pre>



<p class="wp-block-paragraph">如下：</p>



<pre class="wp-block-code"><code>&#91;root@dwp ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:n4866Plm9ba0Z7jBmeii0Rru6SIyJK6wnU53oI+HR+M root@dwp
The key's randomart image is:
+---&#91;RSA 3072]----+
|                 |
|                 |
|                 |
|                 |
|    .   S        |
|.. .o. . ..+ o   |
|= o+..+...+.*.   |
|+=o=Eo.*=. ++oo  |
|++=+.=X=o+o.==   |
+----&#91;SHA256]-----+
&#91;root@dwp ~]# ssh-copy-id 192.168.241.131
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.241.131 (192.168.241.131)' can't be established.
ECDSA key fingerprint is SHA256:Y2mowFFYesLVUdYE7bDew7pLShtEuOYMCNVgilHds/o.
Are you sure you want to continue connecting (yes/no/&#91;fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

Authorized users only. All activities may be monitored and reported.
root@192.168.241.131's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.241.131'"
and check to make sure that only the key(s) you wanted were added.

&#91;root@dwp ~]# ssh-copy-id 192.168.241.132
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

Authorized users only. All activities may be monitored and reported.
root@192.168.241.132's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.241.132'"
and check to make sure that only the key(s) you wanted were added.

&#91;root@dwp ~]# ssh-copy-id 192.168.241.133
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

Authorized users only. All activities may be monitored and reported.
root@192.168.241.133's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.241.133'"
and check to make sure that only the key(s) you wanted were added.</code></pre>



<p class="wp-block-paragraph">另外两台的执行过程略。</p>



<h2 class="wp-block-heading">三、登录验证</h2>



<pre class="wp-block-code"><code>&#91;root@dwp ~]# ssh dws

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Tue Mar 25 10:32:26 2025 from 192.168.241.131
&#91;root@dws ~]# 注销
Connection to dws closed.
&#91;root@dwp ~]# ssh dwm

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Tue Mar 25 10:32:36 2025 from 192.168.241.131
&#91;root@dwm ~]# ssh dws

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Tue Mar 25 10:33:09 2025 from 192.168.241.131
&#91;root@dws ~]# </code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/%e9%9b%86%e7%be%a4%e9%97%b4%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%85%8d%e7%bd%ae%e5%85%8d%e5%af%86/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>x86与ARM架构的对比分析</title>
		<link>https://www.lemonary.cn/x86%e4%b8%8earm%e6%9e%b6%e6%9e%84%e7%9a%84%e5%af%b9%e6%af%94%e5%88%86%e6%9e%90/</link>
					<comments>https://www.lemonary.cn/x86%e4%b8%8earm%e6%9e%b6%e6%9e%84%e7%9a%84%e5%af%b9%e6%af%94%e5%88%86%e6%9e%90/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Mon, 17 Feb 2025 05:29:01 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[x86]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1446</guid>

					<description><![CDATA[一、核心区别 二、各自优劣势 三、应用场景 四、趋势与相互渗透 五、总结]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">一、核心区别</h2>



<ul class="wp-block-list">
<li>指令集类型：
<ul class="wp-block-list">
<li>x86：基于CISC（复杂指令集），指令复杂且功能强大，单条指令可执行多步操作（如内存访问、计算），但解码和执行周期可能较长。</li>



<li>ARM：基于RISC（精简指令集），指令长度固定且简单，注重单周期执行，依赖多条指令组合完成复杂任务，效率更高。</li>
</ul>
</li>



<li>功耗与能效：
<ul class="wp-block-list">
<li>x86：传统设计侧重高性能，功耗较高（尤其桌面/服务器级芯片），近年通过制程优化（如Intel 7nm）改善能效。</li>



<li>ARM：天生为低功耗设计，采用精简指令、高效流水线，适合移动设备，如智能手机（如苹果A系列）和物联网设备。</li>
</ul>
</li>



<li>授权模式：
<ul class="wp-block-list">
<li>x86：封闭授权，仅Intel、AMD等少数厂商可生产，生态集中。</li>



<li>ARM：开放授权（IP授权或架构授权），厂商可定制设计（如苹果M系列、高通骁龙），促进多样性。</li>
</ul>
</li>



<li>硬件架构：
<ul class="wp-block-list">
<li>x86：历史包袱较重，需兼容旧指令，设计复杂；多核扩展依赖超线程等技术。</li>



<li>ARM：模块化设计，支持自定义扩展（如NEON指令加速AI），多核集成更灵活（如服务器芯片128核以上）。</li>
</ul>
</li>
</ul>



<h2 class="wp-block-heading">二、各自优劣势</h2>



<div class="wpdt-c row wpDataTableContainerSimpleTable wpDataTables wpDataTablesWrapper
"
    >
        <table id="wpdtSimpleTable-24"
           style="border-collapse:collapse;
                   border-spacing:0px;"
           class="wpdtSimpleTable wpDataTable"
           data-column="3"
           data-rows="3"
           data-wpID="24"
           data-responsive="0"
           data-has-header="0">

                    <tbody>        <tr class="wpdt-cell-row " >
                                <td class="wpdt-cell wpdt-fs-000016 wpdt-bold"
                                            data-cell-id="A1"
                    data-col-index="0"
                    data-row-index="0"
                    style=" width:5.2820053715309%;                    padding:10px;
                    "
                    >
                                        架构                    </td>
                                                <td class="wpdt-cell wpdt-fs-000016 wpdt-bold"
                                            data-cell-id="B1"
                    data-col-index="1"
                    data-row-index="0"
                    style=" width:50.581915846016%;                    padding:10px;
                    "
                    >
                                        优势                    </td>
                                                <td class="wpdt-cell wpdt-fs-000016 wpdt-bold"
                                            data-cell-id="C1"
                    data-col-index="2"
                    data-row-index="0"
                    style=" width:44.136078782453%;                    padding:10px;
                    "
                    >
                                        劣势                    </td>
                                        </tr>
                            <tr class="wpdt-cell-row " >
                                <td class="wpdt-cell wpdt-fs-000016 wpdt-bold"
                                            data-cell-id="A2"
                    data-col-index="0"
                    data-row-index="1"
                    style="                    padding:10px;
                    "
                    >
                                        x86                    </td>
                                                <td class="wpdt-cell wpdt-fs-000016"
                                            data-cell-id="B2"
                    data-col-index="1"
                    data-row-index="1"
                    style="                    padding:10px;
                    "
                    >
                                        - 高性能计算：擅长复杂任务（如视频渲染、科学计算）。<br>
- 成熟生态：Windows/Linux桌面软件、企业级应用（如数据库）高度兼容。<br>
- 虚拟化支持：服务器级虚拟化技术（如Intel VT-x）成熟。                    </td>
                                                <td class="wpdt-cell wpdt-fs-000016"
                                            data-cell-id="C2"
                    data-col-index="2"
                    data-row-index="1"
                    style="                    padding:10px;
                    "
                    >
                                        - 高功耗：不适合无持续供电场景。<br>
- 设计复杂：升级迭代周期长（如Intel的10nm延迟）。<br>
- 授权限制：第三方难以参与创新。                    </td>
                                        </tr>
                            <tr class="wpdt-cell-row " >
                                <td class="wpdt-cell wpdt-fs-000016 wpdt-bold"
                                            data-cell-id="A3"
                    data-col-index="0"
                    data-row-index="2"
                    style="                    padding:10px;
                    "
                    >
                                        ARM                    </td>
                                                <td class="wpdt-cell wpdt-fs-000016"
                                            data-cell-id="B3"
                    data-col-index="1"
                    data-row-index="2"
                    style="                    padding:10px;
                    "
                    >
                                        - 高能效比：单位功耗性能优异，延长移动设备续航。<br>
- 灵活定制：厂商可针对场景优化（如特斯拉自动驾驶芯片）。<br>
- 多核扩展性：易于堆叠核心（如Ampere Altra服务器CPU达128核）。                    </td>
                                                <td class="wpdt-cell wpdt-fs-000016"
                                            data-cell-id="C3"
                    data-col-index="2"
                    data-row-index="2"
                    style="                    padding:10px;
                    "
                    >
                                        - 软件兼容性：传统x86软件需模拟或重编译（如Rosetta 2转译）。<br>
- 绝对性能上限：单线程性能仍落后x86旗舰（如Intel Core i9）。<br>
- 生态碎片化：不同厂商设计差异可能导致优化难题。                    </td>
                                        </tr>
                    </table>
</div><style id='wpdt-custom-style-24'>
.wpdt-fs-000016 { font-size: 16px !important;}
</style>




<h2 class="wp-block-heading">三、应用场景</h2>



<ul class="wp-block-list">
<li>x86主导领域：
<ul class="wp-block-list">
<li>个人电脑与工作站：如游戏PC（NVIDIA RTX + Intel i9）、Adobe创意软件。</li>



<li>数据中心与云计算：AWS EC2、Azure虚拟机依赖AMD EPYC或Intel Xeon。</li>



<li>高性能计算（HPC）：超级计算机（如Fugaku早期x86版本）用于气候模拟、核研究。</li>
</ul>
</li>



<li>ARM主导领域：
<ul class="wp-block-list">
<li>移动设备：智能手机（iPhone A系列）、平板电脑（iPad M系列）。</li>



<li>嵌入式与物联网：智能家居（如Nest恒温器）、工业传感器。</li>



<li>新兴市场：ARM服务器（AWS Graviton）、笔记本（MacBook M系列）挑战传统x86领域。</li>
</ul>
</li>
</ul>



<h2 class="wp-block-heading">四、趋势与相互渗透</h2>



<ul class="wp-block-list">
<li>ARM的扩张：
<ul class="wp-block-list">
<li>服务器市场：Graviton3比x86实例性价比高40%（AWS数据），吸引成本敏感型企业。</li>



<li>桌面革命：Apple Silicon（M2 Ultra）展示ARM在创作领域的潜力，Final Cut Pro优化后媲美x86。</li>
</ul>
</li>



<li>x86的反击：
<ul class="wp-block-list">
<li>能效提升：Intel 12代酷睿混合架构（P核+E核）借鉴ARM大小核设计，优化多任务功耗。</li>



<li>嵌入式市场：Intel Atom处理器进军工业自动化，对抗ARM Cortex-R系列。</li>
</ul>
</li>
</ul>



<h2 class="wp-block-heading">五、总结</h2>



<ul class="wp-block-list">
<li>选择x86：需极致单线程性能、成熟企业软件支持，或构建高性能服务器。</li>



<li>选择ARM：追求长续航、定制化硬件，或布局物联网、边缘计算等新兴场景。</li>



<li>未来：随着ARM性能提升（如3nm制程）和x86能效改进，两者界限或进一步模糊，形成异构计算（如NVIDIA Grace CPU + GPU）共存格局。</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/x86%e4%b8%8earm%e6%9e%b6%e6%9e%84%e7%9a%84%e5%af%b9%e6%af%94%e5%88%86%e6%9e%90/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CentOS下部署vsftpd服务的详细教程</title>
		<link>https://www.lemonary.cn/centos%e4%b8%8b%e9%83%a8%e7%bd%b2vsftpd%e6%9c%8d%e5%8a%a1%e7%9a%84%e8%af%a6%e7%bb%86%e6%95%99%e7%a8%8b/</link>
					<comments>https://www.lemonary.cn/centos%e4%b8%8b%e9%83%a8%e7%bd%b2vsftpd%e6%9c%8d%e5%8a%a1%e7%9a%84%e8%af%a6%e7%bb%86%e6%95%99%e7%a8%8b/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Sun, 26 Jan 2025 03:26:42 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[vsftpd]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1379</guid>

					<description><![CDATA[原文链接：https://blog.csdn.net/ruogan1993/article/details/1 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">原文链接：<a href="https://blog.csdn.net/ruogan1993/article/details/134604642">https://blog.csdn.net/ruogan1993/article/details/134604642</a></p>
</blockquote>



<h2 class="wp-block-heading">一、前言</h2>



<p class="wp-block-paragraph">本文介绍总结在CentOS系统Linux下通过vsftp服务搭建FTP服务器</p>



<h2 class="wp-block-heading">二、FTP介绍</h2>



<p class="wp-block-paragraph">FTP（File Transfer&nbsp;<a href="https://so.csdn.net/so/search?q=Protocol&amp;spm=1001.2101.3001.7020" target="_blank" rel="noreferrer noopener">Protocol</a>）是一种文件传输协议，基于客户端/服务器架构，支持以下两种工作模式：</p>



<ul class="wp-block-list">
<li>主动模式：客户端向FTP服务器发送端口信息，由服务器主动连接该端口。</li>



<li>被动模式：FTP服务器开启并发送端口信息给客户端，由客户端连接该端口，服务器被动接受连接。</li>
</ul>



<p class="wp-block-paragraph">说明：大多数FTP客户端都在局域网中，没有独立的公网IP地址，且有防火墙阻拦，主动模式下FTP服务器成功连接到客户端比较困难。因此，如无特殊需求，建议您将FTP服务器配置为被动模式。</p>



<p class="wp-block-paragraph">FTP支持以下三种认证模式：</p>



<ul class="wp-block-list">
<li>匿名用户模式：任何人无需密码验证就可以直接登录到FTP服务器。这种模式最不安全，一般只用来保存不重要的公开文件，不推荐在生产环境中使用。</li>



<li>本地用户模式：通过Linux系统本地账号进行验证的模式，相较于匿名用户模式更安全。</li>



<li>虚拟用户模式：FTP服务器的专有用户。虚拟用户只能访问Linux系统为其提供的FTP服务，而不能访问Linux系统的其它资源，进一步增强了FTP服务器的安全性。</li>
</ul>



<h2 class="wp-block-heading">三、部署教程</h2>



<h3 class="wp-block-heading">3.1 安装vsftpd服务</h3>



<pre class="wp-block-code"><code>yum -y install vsftpd</code></pre>



<h3 class="wp-block-heading">3.2 虚拟用户模式</h3>



<h4 class="wp-block-heading">3.2.1 创建账号密码</h4>



<p class="wp-block-paragraph">首先，创建用于进行ftp认证的用户数据库文件vu.txt，其中奇数行是用户名，偶数行是登录密码。其次，利用db_load命令用哈希算法将原始明文信息文件转换成vsftpd服务程序可加载的数据库文件vu.db。最后，为了避免其它用户访问该数据库文件的内容，修改降低数据库文件的权限，把原始的明文文件删除。</p>



<pre class="wp-block-code"><code>#进入vsftpd配置目录
cd /etc/vsftpd/

#创建vu.txt明文文件
cat &gt;&gt;/etc/vsftpd/vu.txt&lt;&lt;EOF
admin
admin
upload
upload
download
download
EOF

#把vu.txt明文文件转换成vu.db数据库文件
db_load -T -t hash -f vu.txt vu.db

#修改降低vu.db数据库文件的权限并删除原始明文文件
chmod 600 vu.db
rm -f vu.txt</code></pre>



<h4 class="wp-block-heading">3.2.2 创建用户、虚拟用户、ftp路径</h4>



<p class="wp-block-paragraph">创建本地用户，创建虚拟用户upload目录并修改目录的所属组和用户，修改ftp根目录权限</p>



<pre class="wp-block-code"><code>#创建系统本地用户ftpadmin及所属目录并禁用该用户登录服务器
useradd -d /home/ftp -s /sbin/nologin ftpadmin

#创建虚拟用户upload的目录
mkdir /home/ftp/upload

#修改虚拟用户upload的所属组和所属用户
chown -R ftpadmin:ftpadmin /home/ftp/upload

#修改/home/ftp/的权限
chmod -Rf 755 /home/ftp/</code></pre>



<h4 class="wp-block-heading">3.2.3 创建PAM文件</h4>



<p class="wp-block-paragraph">创建用于支持虚拟用户的PAM文件</p>



<pre class="wp-block-code"><code>#Tips：不用写数据库文件vu.db的后缀
cat >>/etc/pam.d/vs.vu&lt;&lt;EOF
auth required pam_userdb.so db=/etc/vsftpd/vu
account required pam_userdb.so db=/etc/vsftpd/vu
EOF</code></pre>



<h4 class="wp-block-heading">3.2.4 创建账号配置文件</h4>



<p class="wp-block-paragraph">创建目录/etc/vsftpd/vu_perm用于存放为不同虚拟用户设置不同的权限的文件。例如，admin，upload和download。</p>



<pre class="wp-block-code"><code>#Tips:虚拟用户权限的文件名与虚拟用户名称保持一致。
#创建目录/etc/vsftpd/vu_perm
mkdir /etc/vsftpd/vu_perm

#创建虚拟用户admin的权限文件admin,使其具备上传、下载、创建目录、删除和移动文件的权限
cat &gt;&gt;/etc/vsftpd/vu_perm/admin&lt;&lt;EOF
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
local_root=/home/ftp
EOF

#创建虚拟用户upload的权限文件upload,使其仅具备上传文件、创建目录的权限
cat &gt;&gt;/etc/vsftpd/vu_perm/upload&lt;&lt;EOF
anon_upload_enable=YES
anon_mkdir_write_enable=YES
local_root=/home/ftp/upload
EOF

#创建虚拟用户download的权限文件download,使其仅具备下载文件的权限
cat &gt;&gt;/etc/vsftpd/vu_perm/download&lt;&lt;EOF
anon_world_readable_only=NO
local_root=/home/ftp
EOF

#为了安全起见，递归修改/etc/vsftpd/vu_perm的权限
chmod -R 600 /etc/vsftpd/vu_perm/</code></pre>



<h4 class="wp-block-heading">3.2.5 配置vsftpd服务程序的主配置文件</h4>



<pre class="wp-block-code"><code>#备份sftpd服务程序的主配置文件
cp /etc/vsftpd/vsftpd.conf.bak

#把默认未注释的配置文件重定写入vsftpd.conf配置文件中
grep -v "#" /etc/vsftpd/vsftpd.conf.bak &gt; /etc/vsftpd/vsftpd.conf

#修改配置文件
vi /etc/vsftpd/vsftpd.conf</code></pre>



<p class="wp-block-paragraph">修改后配置内容，<strong>加粗部分为修改或增加内容</strong></p>



<p class="wp-block-paragraph">[root@localhost ~]# cat /etc/vsftpd/vsftpd.conf<br><strong>anonymous_enable=NO</strong><br>local_enable=YES<br>write_enable=YES<br><strong>guest_enable=YES<br>guest_username=ftpadmin<br>allow_writeable_chroot=YES</strong><br>local_umask=022<br>dirmessage_enable=YES<br>xferlog_enable=YES<br>connect_from_port_20=YES<br><strong>xferlog_file=/var/log/xferlog</strong><br>xferlog_std_format=YES<br>listen=NO<br>listen_ipv6=YES<br><strong>pam_service_name=vs.vu</strong><br>userlist_enable=YES<br><strong>user_config_dir=/etc/vsftpd/vu_perm</strong></p>



<h4 class="wp-block-heading">3.2.6</h4>



<h3 class="wp-block-heading">3.3 安全配置，涉及到Firewall和SeLinux的配置</h3>



<pre class="wp-block-code"><code>#放通ftp服务，允许客户端连接服务器ftp服务（TCP 21）并使配置生效
firewall-cmd --permanent --zone=public --add-service=ftp
firewall-cmd --reload

#获取关于ftp相关的SeLinux布尔值设置
getsebool -a | grep ftp

#修改SeLinux关于ftp服务的布尔值
#Tips：-p表示永久生效，不受服务器重启的影响。
setsebool -P ftpd_connect_all_unreserved=on
setsebool -P ftpd_full_access=on
#也可以选择直接关闭SELinux：修改/etc/sysconfig/selinux文件，SELINUX=disabled，并重启服务器生效。</code></pre>



<h3 class="wp-block-heading">3.4 重启vsftpd服务并设置跟随系统自启动</h3>



<pre class="wp-block-code"><code>#重启vsftpd服务
systemctl restart vsftpd

#设置vsftpd服务开机自启动
systemctl enable vsftpd</code></pre>



<h3 class="wp-block-heading">另：本地用户模式 &#8211; root用户</h3>



<p class="wp-block-paragraph">vsftpd服务主配置文件</p>



<pre class="wp-block-code"><code>anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
ftpd_banner=Welcome to blah FTP service.
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
listen=NO
listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES</code></pre>



<p class="wp-block-paragraph">创建/etc/vsftpd/chroot_list文件，写入root与密码（第一行写root，第二行写密码），例如</p>



<pre class="wp-block-code"><code>root
123456789</code></pre>



<p class="wp-block-paragraph">将/etc/vsftpd/ftpusers和/etc/vsftpd/user_list两个文件中的root全部注释。</p>



<p class="wp-block-paragraph">同样配置完成需要重启vsftpd服务生效。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/centos%e4%b8%8b%e9%83%a8%e7%bd%b2vsftpd%e6%9c%8d%e5%8a%a1%e7%9a%84%e8%af%a6%e7%bb%86%e6%95%99%e7%a8%8b/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SecureCRT软件的一些便捷的使用技巧</title>
		<link>https://www.lemonary.cn/securecrt%e8%bd%af%e4%bb%b6%e7%9a%84%e4%b8%80%e4%ba%9b%e4%be%bf%e6%8d%b7%e7%9a%84%e4%bd%bf%e7%94%a8%e6%8a%80%e5%b7%a7/</link>
					<comments>https://www.lemonary.cn/securecrt%e8%bd%af%e4%bb%b6%e7%9a%84%e4%b8%80%e4%ba%9b%e4%be%bf%e6%8d%b7%e7%9a%84%e4%bd%bf%e7%94%a8%e6%8a%80%e5%b7%a7/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Tue, 17 Dec 2024 03:11:22 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[SecureCRT]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1080</guid>

					<description><![CDATA[一、问题概述 用了多年的Xshell5，今天闲来无事安装了SecureCRT软件试试，还有些意外收获。用欲善其 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="一、问题概述">一、问题概述</h2>



<p class="wp-block-paragraph">用了多年的Xshell5，今天闲来无事安装了SecureCRT软件试试，还有些意外收获。用欲善其事必先利其器，接下来就记录一下今天了解的一些小技巧。</p>



<h2 class="wp-block-heading" id="二、技巧详述">二、技巧详述</h2>



<h3 class="wp-block-heading" id="2.1-默认会话">2.1 默认会话</h3>



<p class="wp-block-paragraph">SecureCRT软件同Xshell一样，可以配置软件启动时自动连接的会话，即默认会话。配置方法：</p>



<p class="wp-block-paragraph"><strong>Options——Global Options&#8230;——General——Default Session——Add&#8230;——选择想要添加的会话即可</strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="911" height="826" src="https://www.lemonary.cn/wp-content/uploads/2024/12/image-65.png" alt="" class="wp-image-1081" srcset="https://www.lemonary.cn/wp-content/uploads/2024/12/image-65.png 911w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-65-300x272.png 300w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-65-768x696.png 768w" sizes="auto, (max-width: 911px) 100vw, 911px" /></figure>



<p class="wp-block-paragraph">配置好后，下一次启动SecureCRT的时候软件就会自动连接该默认会话。</p>



<h3 class="wp-block-heading" id="2.2-按钮栏">2.2 按钮栏</h3>



<p class="wp-block-paragraph">按钮栏能够自定义按钮，将一些常用的命令添加到按钮中，例如查看当前CPU和内存使用率，切换用户等等命令。配置完成后，便可用点击按钮来代替手动敲击命令，非常地方便。</p>



<p class="wp-block-paragraph">View——Button Bar</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="282" height="641" src="https://www.lemonary.cn/wp-content/uploads/2024/12/image-66.png" alt="" class="wp-image-1082" srcset="https://www.lemonary.cn/wp-content/uploads/2024/12/image-66.png 282w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-66-132x300.png 132w" sizes="auto, (max-width: 282px) 100vw, 282px" /></figure>



<p class="wp-block-paragraph">开启后，便可从下方看到按钮栏，右键即可添加按钮</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="856" height="193" src="https://www.lemonary.cn/wp-content/uploads/2024/12/image-68.png" alt="" class="wp-image-1084" srcset="https://www.lemonary.cn/wp-content/uploads/2024/12/image-68.png 856w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-68-300x68.png 300w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-68-768x173.png 768w" sizes="auto, (max-width: 856px) 100vw, 856px" /></figure>



<p class="wp-block-paragraph">示例</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="771" height="453" src="https://www.lemonary.cn/wp-content/uploads/2024/12/image-71.png" alt="" class="wp-image-1087" srcset="https://www.lemonary.cn/wp-content/uploads/2024/12/image-71.png 771w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-71-300x176.png 300w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-71-768x451.png 768w" sizes="auto, (max-width: 771px) 100vw, 771px" /></figure>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">注意：如按上图输入，点击按钮时，free -m命令并不会直接执行，还需敲击回车，所以如果想要让命令直接执行，需要在命令后接上一个\r（上图Send String commands下是部分特殊字符的标识，例如\r表示回车）。故：</p>
</blockquote>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="771" height="453" src="https://www.lemonary.cn/wp-content/uploads/2024/12/image-72.png" alt="" class="wp-image-1088" srcset="https://www.lemonary.cn/wp-content/uploads/2024/12/image-72.png 771w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-72-300x176.png 300w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-72-768x451.png 768w" sizes="auto, (max-width: 771px) 100vw, 771px" /></figure>



<p class="wp-block-paragraph">便可以实现点击按钮快速查看内存使用情况，点击OK，即新增按钮成功。</p>



<h3 class="wp-block-heading" id="2.3-反空闲">2.3 反空闲</h3>



<p class="wp-block-paragraph">在连接某些设备时，如果一段时间内设备没有收到输入，就会自动断开连接。此时，我们可以通过设置反空闲，让SecureCRT定时发送一个反空闲字符，一般情况下，此字符采用空格键。为了让大家看清，我此处配置的是回车，如下图：</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="829" height="756" src="https://www.lemonary.cn/wp-content/uploads/2024/12/image-73.png" alt="" class="wp-image-1089" srcset="https://www.lemonary.cn/wp-content/uploads/2024/12/image-73.png 829w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-73-300x274.png 300w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-73-768x700.png 768w" sizes="auto, (max-width: 829px) 100vw, 829px" /></figure>



<p class="wp-block-paragraph">如果配置空格，就直接在填框里输入一个空格即可。</p>



<h2 class="wp-block-heading" id="三、总结">三、总结</h2>



<p class="wp-block-paragraph">目前只了解到这三个比较实用的功能，后续使用，如有发现新功能，随时添加到本文章。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/securecrt%e8%bd%af%e4%bb%b6%e7%9a%84%e4%b8%80%e4%ba%9b%e4%be%bf%e6%8d%b7%e7%9a%84%e4%bd%bf%e7%94%a8%e6%8a%80%e5%b7%a7/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Linux如何查看命令执行后哪些文件被修改了</title>
		<link>https://www.lemonary.cn/linux%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8b%e5%91%bd%e4%bb%a4%e6%89%a7%e8%a1%8c%e5%90%8e%e5%93%aa%e4%ba%9b%e6%96%87%e4%bb%b6%e8%a2%ab%e4%bf%ae%e6%94%b9%e4%ba%86/</link>
					<comments>https://www.lemonary.cn/linux%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8b%e5%91%bd%e4%bb%a4%e6%89%a7%e8%a1%8c%e5%90%8e%e5%93%aa%e4%ba%9b%e6%96%87%e4%bb%b6%e8%a2%ab%e4%bf%ae%e6%94%b9%e4%ba%86/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Mon, 16 Dec 2024 02:38:20 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Script]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1072</guid>

					<description><![CDATA[示例 查看dnf makecache;命令修改了哪些文件 验证 延伸方法 查看某脚本script.sh修改的文 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph"><strong>示例</strong></p>



<p class="wp-block-paragraph">查看<code>dnf makecache;</code>命令修改了哪些文件</p>



<pre class="wp-block-code"><code>&#91;root@dameng linuxscript]# T="$(date "+%F %T.%N")"; dnf makecache; find / -xdev -newermt "$T"
CentOS-8.5.2111 - Base - mirrors.aliyun.com                                                                                                                             279 kB/s | 3.9 kB     00:00    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com                                                                                                                           119 kB/s | 1.5 kB     00:00    
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com                                                                                                                        331 kB/s | 4.3 kB     00:00    
Metadata cache created.
/tmp
/var/log/dnf.log
/var/log/dnf.librepo.log
/var/log/dnf.rpm.log
/var/log/hawkey.log
/var/lib/rpm/__db.002
/var/lib/rpm/__db.001
/var/lib/rpm/__db.003
/var/cache/dnf
/var/cache/dnf/extras-e503dfa263573efa/repodata/86501a1d822eea269ca494f23adb73be14166b426a1a2bcdaaacf5cef2859b5e-primary.xml.gz
/var/cache/dnf/AppStream-c40f4caedb6d900a/repodata/d8472d61c5e53a3e9cbffb68e0dddbd04a07c2b7d864b07ddd211c6ad1380c6e-primary.xml.gz
/var/cache/dnf/base-c446c86678567d00/repodata/ca039bbfe8297c592cdc0e7251689f5d597771d39b2ddede01106ad0a7f0ba60-primary.xml.gz
/var/cache/dnf/expired_repos.json</code></pre>



<p class="wp-block-paragraph"><strong>验证</strong></p>



<pre class="wp-block-code"><code>&#91;root@dameng linuxscript]# T="$(date "+%F %T.%N")"; tarthis ;find / -xdev -newermt "$T"
<strong>/root/#linuxscript#-2024-12-16.tgz</strong>
/tmp
/usr/local/uniagent/log/uniagent.log
/var/log/hostguard/hostwatch.log</code></pre>



<p class="wp-block-paragraph"><strong>延伸方法</strong></p>



<p class="wp-block-paragraph">查看某脚本script.sh修改的文件</p>



<pre class="wp-block-code"><code>&#91;root@dameng ~]# T="$(date "+%F %T.%N")"; ./script.sh; find / -xdev -newermt "$T"</code></pre>



<p class="wp-block-paragraph">例如：</p>



<pre class="wp-block-code"><code>&#91;root@dameng linuxscript]# T="$(date "+%F %T.%N")"; ./file_size_distribution.sh /dmbak/; find / -xdev -newermt "$T"
From    To      Count                                                                                                                                                                                  

1KB	10KB	2
10KB	100KB	5
100KB	1MB	13
1MB	10MB	2
10MB	100MB	1
100MB	1GB	1

Total: 281.9 MB in 24 files
/usr/local/hostguard/run/heartbeat.tick
/var/log/hostguard/containers.log
/var/log/hostguard/hostguard.log</code></pre>



<p class="wp-block-paragraph">由于上述脚本file_size_distribution.sh没有操作文件的步骤，所以只列出了系统执行日志变化的文件。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/linux%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8b%e5%91%bd%e4%bb%a4%e6%89%a7%e8%a1%8c%e5%90%8e%e5%93%aa%e4%ba%9b%e6%96%87%e4%bb%b6%e8%a2%ab%e4%bf%ae%e6%94%b9%e4%ba%86/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Linux脚本之快速分析文件大小分布情况</title>
		<link>https://www.lemonary.cn/linux%e8%84%9a%e6%9c%ac%e4%b9%8b%e5%bf%ab%e9%80%9f%e5%88%86%e6%9e%90%e6%96%87%e4%bb%b6%e5%a4%a7%e5%b0%8f%e5%88%86%e5%b8%83%e6%83%85%e5%86%b5/</link>
					<comments>https://www.lemonary.cn/linux%e8%84%9a%e6%9c%ac%e4%b9%8b%e5%bf%ab%e9%80%9f%e5%88%86%e6%9e%90%e6%96%87%e4%bb%b6%e5%a4%a7%e5%b0%8f%e5%88%86%e5%b8%83%e6%83%85%e5%86%b5/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Mon, 16 Dec 2024 02:20:45 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Script]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1067</guid>

					<description><![CDATA[注意：本脚本不计算软链接的真实文件大小 一、脚本内容 二、使用方法 效果图如下 如图，脚本分析结果大于10M的 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">注意：本脚本不计算软链接的真实文件大小</p>
</blockquote>



<h2 class="wp-block-heading" id="一、脚本内容">一、<strong>脚本内容</strong></h2>



<pre class="wp-block-code"><code>#!/bin/sh
set -eu

tabs -8

# 检查输入参数，如果没有指定目录，则默认为根目录
dir=${1:-/}

# 使用find命令统计文件大小，排除指定目录
find "$dir" \( -path "/proc/*" -o -path "/sys/*" -o -path "/boot/*" -o -path "/run/*" -o -path "/dev/*" \) -prune -o -type f -exec du -b -- {} + | awk -vOFS='\t' '
BEGIN {split("KB MB GB TB PB", u); u&#91;0] = "B"}
{
    ++hist&#91;$1 ? length($1) - 1 : -1]
    total += $1
}
END {
    max = -2
    for (i in hist)
        max = (i > max ? i : max)

    print "From", "To", "Count\n"
    for (i = -1; i &lt;= max; ++i)
    {
        if (i in hist)
            {
                if (i == -1)
                    print "0B", "0B", hist&#91;i]
                else
                    print 10 ** (i       % 3) u&#91;int(i       / 3)],
                          10 ** ((i + 1) % 3) u&#91;int((i + 1) / 3)],
                    hist&#91;i]
            }
    }
    base = 1024
    unit = "B"
    if (total >= base) {
        total /= base
        unit = "KB"
    }
    if (total >= base) {
        total /=base
        unit = "MB"
    }
    if (total >= base) { 
       	total /=base
       	unit = "GB"
    }
    if (total >= base) { 
       	total /=base
       	unit = "TB"
    }
    printf "\nTotal: %.1f %s in %d files\n", total, unit, NR
}'</code></pre>



<h2 class="wp-block-heading" id="二、使用方法">二、<strong>使用方法</strong></h2>



<pre class="wp-block-code"><code>&#91;root@dameng linuxscript]# ./file_size_distribution.sh /home/wwwroot/wordpress/
From    To      Count                                                                                                                                                                                  

0B	0B	27
1B	10B	8
10B	100B	296
100B	1KB	3309
1KB	10KB	6629
10KB	100KB	4444
100KB	1MB	1225
1MB	10MB	54
10MB	100MB	1
100MB	1GB	3

Total: 1.8 GB in 15996 files
&#91;root@dameng linuxscript]# find /home/wwwroot/wordpress/ -type f -size +10M
/home/wwwroot/wordpress/wp-content/plugins/yaya-comment-ip/ip-data/qqwry.dat
/home/wwwroot/wordpress/wp-content/backups-dup-lite/WordPress_Backup_202411281540_743e9f6d5a6adcd51101_20241128074043_archive.zip
/home/wwwroot/wordpress/wp-content/backups-dup-lite/WordPress_Backup_202411281540_2d35e6e0f53082cd2170_20241204031044_archive.zip
/home/wwwroot/wordpress/wp-content/backups-dup-lite/WordPress_First_Backup_849864da946d7fcc5140_20241125093438_archive.zip</code></pre>



<p class="wp-block-paragraph">效果图如下</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="335" src="https://www.lemonary.cn/wp-content/uploads/2024/12/image-64-1024x335.png" alt="" class="wp-image-1068" srcset="https://www.lemonary.cn/wp-content/uploads/2024/12/image-64-1024x335.png 1024w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-64-300x98.png 300w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-64-768x251.png 768w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-64.png 1423w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">如图，脚本分析结果大于10M的文件共有1+3=4个，与find命令查找到的文件数一致。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/linux%e8%84%9a%e6%9c%ac%e4%b9%8b%e5%bf%ab%e9%80%9f%e5%88%86%e6%9e%90%e6%96%87%e4%bb%b6%e5%a4%a7%e5%b0%8f%e5%88%86%e5%b8%83%e6%83%85%e5%86%b5/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Linux三剑客之巧用sed转换MAC地址</title>
		<link>https://www.lemonary.cn/linux%e4%b8%89%e5%89%91%e5%ae%a2%e4%b9%8b%e5%b7%a7%e7%94%a8sed%e8%bd%ac%e6%8d%a2mac%e5%9c%b0%e5%9d%80/</link>
					<comments>https://www.lemonary.cn/linux%e4%b8%89%e5%89%91%e5%ae%a2%e4%b9%8b%e5%b7%a7%e7%94%a8sed%e8%bd%ac%e6%8d%a2mac%e5%9c%b0%e5%9d%80/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Mon, 16 Dec 2024 02:06:57 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MAC]]></category>
		<category><![CDATA[sed]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1064</guid>

					<description><![CDATA[原始MAC地址文件 首先，去掉冒号（准备工作） IEEE格式 华为交换机格式 思科交换机格式]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">原始MAC地址文件</p>



<pre class="wp-block-code"><code>&#91;root@dameng linuxscript]# cat maclist 
D7:53:20:B3:E3:FE
1E:91:79:0D:B1:DB
4E:B0:1A:0D:11:D2
BF:59:7F:40:EF:6E
02:2D:F7:1A:90:EF
01:C6:16:66:B8:75
3F:09:9C:35:C4:B8
A0:B2:AC:30:04:31
D9:5D:1D:12:98:7A
9A:EE:FA:CD:39:90</code></pre>



<p class="wp-block-paragraph"><strong>首先，去掉冒号（准备工作）</strong></p>



<pre class="wp-block-code"><code>&#91;root@dameng linuxscript]# sed 's/://g' maclist 
D75320B3E3FE
1E91790DB1DB
4EB01A0D11D2
BF597F40EF6E
022DF71A90EF
01C61666B875
3F099C35C4B8
A0B2AC300431
D95D1D12987A
9AEEFACD3990</code></pre>



<p class="wp-block-paragraph"><strong>IEEE格式</strong></p>



<pre class="wp-block-code"><code>&#91;root@dameng linuxscript]# sed 's/://g' maclist | sed 's/\(..\)/\1-/g;s/-$//'
D7-53-20-B3-E3-FE
1E-91-79-0D-B1-DB
4E-B0-1A-0D-11-D2
BF-59-7F-40-EF-6E
02-2D-F7-1A-90-EF
01-C6-16-66-B8-75
3F-09-9C-35-C4-B8
A0-B2-AC-30-04-31
D9-5D-1D-12-98-7A
9A-EE-FA-CD-39-90</code></pre>



<p class="wp-block-paragraph"><strong>华为交换机格式</strong></p>



<pre class="wp-block-code"><code>&#91;root@dameng linuxscript]# sed 's/://g' maclist | sed 's/\(....\)/\1-/g;s/-$//'
D753-20B3-E3FE
1E91-790D-B1DB
4EB0-1A0D-11D2
BF59-7F40-EF6E
022D-F71A-90EF
01C6-1666-B875
3F09-9C35-C4B8
A0B2-AC30-0431
D95D-1D12-987A
9AEE-FACD-3990</code></pre>



<p class="wp-block-paragraph"><strong>思科交换机格式</strong></p>



<pre class="wp-block-code"><code>&#91;root@dameng linuxscript]# sed 's/://g' maclist | sed 's/\(....\)/\1./g;s/.$//'
D753.20B3.E3FE
1E91.790D.B1DB
4EB0.1A0D.11D2
BF59.7F40.EF6E
022D.F71A.90EF
01C6.1666.B875
3F09.9C35.C4B8
A0B2.AC30.0431
D95D.1D12.987A
9AEE.FACD.3990</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/linux%e4%b8%89%e5%89%91%e5%ae%a2%e4%b9%8b%e5%b7%a7%e7%94%a8sed%e8%bd%ac%e6%8d%a2mac%e5%9c%b0%e5%9d%80/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Linux中如何巧妙恢复被进程锁定的已删除文件</title>
		<link>https://www.lemonary.cn/linux%e4%b8%ad%e5%a6%82%e4%bd%95%e5%b7%a7%e5%a6%99%e6%81%a2%e5%a4%8d%e8%a2%ab%e8%bf%9b%e7%a8%8b%e9%94%81%e5%ae%9a%e7%9a%84%e5%b7%b2%e5%88%a0%e9%99%a4%e6%96%87%e4%bb%b6/</link>
					<comments>https://www.lemonary.cn/linux%e4%b8%ad%e5%a6%82%e4%bd%95%e5%b7%a7%e5%a6%99%e6%81%a2%e5%a4%8d%e8%a2%ab%e8%bf%9b%e7%a8%8b%e9%94%81%e5%ae%9a%e7%9a%84%e5%b7%b2%e5%88%a0%e9%99%a4%e6%96%87%e4%bb%b6/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Fri, 13 Dec 2024 02:17:03 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1045</guid>

					<description><![CDATA[一、模拟场景 （1）编写脚本test_del.sh，并执行 脚本内容 （2）删除执行中的脚本 二、恢复过程 （ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="一、模拟场景">一、模拟场景</h2>



<p class="wp-block-paragraph">（1）编写脚本test_del.sh，并执行</p>



<p class="wp-block-paragraph">脚本内容</p>



<pre class="wp-block-code"><code>#!/bin/bash

while true; do

  sleep 10000000

done</code></pre>



<p class="wp-block-paragraph">（2）删除执行中的脚本</p>



<pre class="wp-block-code"><code>&#91;root@dameng linuxscript]# rm test_del.sh 
rm: remove regular file 'test_del.sh'? yes
&#91;root@dameng linuxscript]#</code></pre>



<h2 class="wp-block-heading" id="二、恢复过程">二、恢复过程</h2>



<p class="wp-block-paragraph">（1）查看进程状态</p>



<pre class="wp-block-code"><code>&#91;root@dameng linuxscript]# lsof | grep -i delete | grep test_del.sh
test_del. 85885                    root  255r      REG              253,1         52     524386 /root/linuxscript/test_del.sh (deleted)</code></pre>



<ul class="wp-block-list">
<li>test_del：进程名</li>



<li>85885：进程号</li>
</ul>



<p class="wp-block-paragraph">（2）寻找进程文件</p>



<pre class="wp-block-code"><code>&#91;root@dameng linuxscript]# cd /proc/85885/fd</code></pre>



<p class="wp-block-paragraph">如图</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="637" height="103" src="https://www.lemonary.cn/wp-content/uploads/2024/12/screenshots-2.gif" alt="" class="wp-image-1046"/></figure>



<p class="wp-block-paragraph">图中能够看到对应deleted状态的程序（闪烁）。</p>



<p class="wp-block-paragraph">（3）恢复进程文件</p>



<pre class="wp-block-code"><code>&#91;root@dameng fd]# cat 255 &gt;~/linuxscript/test_delv2.sh
&#91;root@dameng fd]# ll ~/linuxscript/test_delv2.sh 
-rw-r--r-- 1 root root 52 Dec 13 10:06 /root/linuxscript/test_delv2.sh</code></pre>



<p class="wp-block-paragraph">（4）查看恢复的脚本文件</p>



<pre class="wp-block-code"><code>&#91;root@dameng fd]# cat ~/linuxscript/test_delv2.sh
#!/bin/bash

while true; do

  sleep 10000000

done</code></pre>



<p class="wp-block-paragraph">恢复的脚本文件和初始执行的脚本文件一致，恢复文件成功。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/linux%e4%b8%ad%e5%a6%82%e4%bd%95%e5%b7%a7%e5%a6%99%e6%81%a2%e5%a4%8d%e8%a2%ab%e8%bf%9b%e7%a8%8b%e9%94%81%e5%ae%9a%e7%9a%84%e5%b7%b2%e5%88%a0%e9%99%a4%e6%96%87%e4%bb%b6/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
