<?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>System User &amp; System Privilege (系统用户 &amp; 系统权限) &#8211; Eternal Center</title>
	<atom:link href="https://eternalcenter-sep-2022.github.io/category/system/system-user-system-privilege/feed/" rel="self" type="application/rss+xml" />
	<link>https://eternalcenter-sep-2022.github.io/</link>
	<description></description>
	<lastBuildDate>Mon, 15 Aug 2022 03:05:01 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>[命令] Linux 命令 gpasswd （管理组）</title>
		<link>https://eternalcenter-sep-2022.github.io/gpasswd/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 29 Jul 2022 07:38:45 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Privilege Security (系统权限安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=27450</guid>

					<description><![CDATA[内容一：组的成员管理 1.1 把用户添加到组里 1.1.1 把某个用户添加到某个组 或者： 或者： 或者： 1.1.2 把多个用户添加到某个组 或者： 或者： 或者： 2.2 把用户从组里删除 2.2.1 把某个用户从某个组里删除 或者： 2.2.2 把多个用户添加到某个组 或者： 2.3 将某个用户设置为组的管理员 或者： 内容三：组的密码管理 3.1 给某个组设置密码 3.2 删除某个组的密码 或者： 内容四：组的登录管理 限制某个组登录 或者： 内容五：显示帮助信息 或者：]]></description>
										<content:encoded><![CDATA[
<h3>内容一：组的成员管理</h3>



<h4>1.1 把用户添加到组里</h4>



<h5>1.1.1 把某个用户添加到某个组</h5>



<pre class="wp-block-code"><code># gpasswd -a &lt;user&gt; &lt;group&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># gpasswd –add &lt;user&gt; &lt;group&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># gpasswd -M &lt;group&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># gpasswd –members &lt;group&gt;</code></pre>



<h5>1.1.2 把多个用户添加到某个组</h5>



<pre class="wp-block-code"><code># gpasswd -a &lt;user1&gt;,&lt;user2&gt; &lt;group&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># gpasswd –add &lt;user1&gt;,&lt;user2&gt; &lt;group&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># gpasswd -M &lt;user1&gt;,&lt;user2&gt; &lt;group&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># gpasswd –members &lt;user1&gt;,&lt;user2&gt; &lt;group&gt;</code></pre>



<h4>2.2 把用户从组里删除</h4>



<h5>2.2.1 把某个用户从某个组里删除</h5>



<pre class="wp-block-code"><code># gpasswd -d &lt;user&gt; &lt;group&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># gpasswd –delete &lt;user&gt; &lt;group&gt;</code></pre>



<h5>2.2.2 把多个用户添加到某个组</h5>



<pre class="wp-block-code"><code># gpasswd -d &lt;user1&gt;,&lt;user2&gt; &lt;group&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># gpasswd –delete &lt;user1&gt;,&lt;user2&gt; &lt;group&gt;</code></pre>



<h4>2.3 将某个用户设置为组的管理员</h4>



<pre class="wp-block-code"><code># gpasswd -A &lt;user&gt; &lt;group&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># gpasswd –administrators &lt;user&gt; &lt;group&gt;</code></pre>



<h3>内容三：组的密码管理</h3>



<h4>3.1 给某个组设置密码</h4>



<pre class="wp-block-code"><code># gpasswd &lt;group&gt;</code></pre>



<h4>3.2 删除某个组的密码</h4>



<pre class="wp-block-code"><code># gpasswd –r &lt;group&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># gpasswd –remove-password &lt;group&gt;</code></pre>



<h3>内容四：组的登录管理</h3>



<p>限制某个组登录</p>



<pre class="wp-block-code"><code># gpasswd -R &lt;group&gt;</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># gpasswd –restrict &lt;group&gt;</code></pre>



<h3>内容五：显示帮助信息</h3>



<pre class="wp-block-code"><code># gpasswd -h</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># gpasswd -help</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] Linux 文件 profile 和 bashrc （用户登录环境的设置）</title>
		<link>https://eternalcenter-sep-2022.github.io/profile-bashrc/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 29 Jul 2022 06:43:12 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System File (系统文件)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System Storage & System Directory & System File (系统存储 & 系统目录 & 系统文件)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=27441</guid>

					<description><![CDATA[内容一：profile 文件 1.1 profile 全局文件的位置 （影响所有用户） 1.2 profile 局部文件的位置 （只影响单个用户） 或者： 或者： 1.3 profile 文件的作用 在用户登录时设置用户的环境变量，只在用户登录时才会生效 1.4 登录 Linux 时执行 profile 文件的顺序 第一步，执行： 第二步，按以下顺序一一尝试执行以下 3 个文件中的 1 个，当执行成功后则停止尝试下 1 个文件： 第三步：开始调用解释器 （如果是调用 bash 解释器，则继续执行登录 bash 时执行 bashrc 文件的顺序） 内容二：bashrc 文件 2.1 bashrc 全局文件的位置 （影响所有用户） 或者： 2.2 bashrc 局部文件的位置 （只影响单个用户） 2.3 bashrc 文件的作用 在用户使用 bash 解释器或登录 &#8230; <p class="link-more"><a href="https://eternalcenter-sep-2022.github.io/profile-bashrc/" class="more-link">Continue reading<span class="screen-reader-text"> "[内容] Linux 文件 profile 和 bashrc （用户登录环境的设置）"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h3>内容一：profile 文件</h3>



<h4>1.1 profile 全局文件的位置 （影响所有用户）</h4>



<pre class="wp-block-code"><code>/etc/profile</code></pre>



<h4>1.2 profile 局部文件的位置 （只影响单个用户）</h4>



<pre class="wp-block-code"><code>~/.bash_profile</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code>~/.bash_login</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code>~/.profile</code></pre>



<h4>1.3 profile 文件的作用</h4>



<p>在用户登录时设置用户的环境变量，只在用户登录时才会生效</p>



<h4>1.4 登录 Linux 时执行 profile 文件的顺序</h4>



<p>第一步，执行：</p>



<pre class="wp-block-code"><code>/etc/profile</code></pre>



<p>第二步，按以下顺序一一尝试执行以下 3 个文件中的 1 个，当执行成功后则停止尝试下 1 个文件：</p>



<pre class="wp-block-code"><code>~/.bash_profile
~/.bash_login
~/.profile</code></pre>



<p>第三步：开始调用解释器</p>



<p>（如果是调用 bash 解释器，则继续执行登录 bash 时执行 bashrc 文件的顺序）</p>



<h3>内容二：bashrc 文件</h3>



<h4>2.1 bashrc 全局文件的位置 （影响所有用户）</h4>



<pre class="wp-block-code"><code>/etc/bashrc</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code>/etc/bash.bashrc</code></pre>



<h4>2.2 bashrc 局部文件的位置 （只影响单个用户）</h4>



<pre class="wp-block-code"><code>~/.bashrc</code></pre>



<h4>2.3 bashrc 文件的作用</h4>



<p>在用户使用 bash 解释器或登录 bash 解释器时设置用户的环境变量，每次调用 bash 解释器时都会生效</p>



<h4>2.4 使用 bash 或登录 bash 时执行 bashrc 文件的顺序</h4>



<p>第一步，执行以下 2 个文件中的 1 个：</p>



<pre class="wp-block-code"><code>/etc/bashrc
/etc/bash.bashrc</code></pre>



<p>第二步，执行：</p>



<pre class="wp-block-code"><code>~/.bashrc</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[命令] Linux 命令 su （切换用户）</title>
		<link>https://eternalcenter-sep-2022.github.io/su/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Mon, 25 Jul 2022 08:33:37 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Operation (系统操作)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=27201</guid>

					<description><![CDATA[案例一：切换用户，切换后保持当前用户所在的目录，并使用当前用户的环境变量 案例二：切换用户，切换后进入被切换用户的家目录，并使用被切换用户的环境变量]]></description>
										<content:encoded><![CDATA[
<h3>案例一：切换用户，切换后保持当前用户所在的目录，并使用当前用户的环境变量</h3>



<pre class="wp-block-code"><code># su &lt;user&gt;</code></pre>



<h3>案例二：切换用户，切换后进入被切换用户的家目录，并使用被切换用户的环境变量</h3>



<pre class="wp-block-code"><code># su - &lt;user&gt;</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[排错] 解决 Linux 普通用户执行 ping 命令时报错 “ping: socket: Address family not supported by protocol” 或者 “Error: ping: socket: Operation not permitted”</title>
		<link>https://eternalcenter-sep-2022.github.io/ping-socket-address-family-not-supported-by-protocol-or-error-ping-socket-operation-not-permitted/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 15 Jul 2022 07:07:51 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Network (系统网络)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation (系统操作)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=26796</guid>

					<description><![CDATA[解决方法一：修改 net.ipv4.ping_group_range 参数 1.1 确认文件功能没有参数 （补充：确认没有输出结果） 1.2 修改 net.ipv4.ping_group_range 参数 解决方法二：设置文件功能参数 2.1 设置文件功能参数 2.2 确认文件功能参数已经设置]]></description>
										<content:encoded><![CDATA[
<h3>解决方法一：修改 net.ipv4.ping_group_range 参数</h3>



<h4>1.1 确认文件功能没有参数</h4>



<pre class="wp-block-code"><code># getcap /usr/bin/ping</code></pre>



<p>（补充：确认没有输出结果）</p>



<h4>1.2 修改 net.ipv4.ping_group_range 参数</h4>



<pre class="wp-block-code"><code># sysctl net.ipv4.ping_group_range="0 2147483647"</code></pre>



<h3>解决方法二：设置文件功能参数</h3>



<h4>2.1 设置文件功能参数</h4>



<pre class="wp-block-code"><code># setcap cap_net_raw+eip /usr/bin/ping</code></pre>



<h4>2.2 确认文件功能参数已经设置</h4>



<pre class="wp-block-code"><code># getcap /usr/bin/ping
/usr/bin/ping = cap_net_raw+eip</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] Linux 非 root 用户 ping 命令使用的禁止和允许</title>
		<link>https://eternalcenter-sep-2022.github.io/non-root-user-ping-diable-enable/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 15 Jul 2022 07:00:36 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network (系统网络)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=26794</guid>

					<description><![CDATA[步骤一：禁止非 root 用户使用 ping 步骤二：允许非 root 用户使用 ping 补充：当禁止禁止非 root 用户使用 ping 时，非 root 用户使用 ping 命令的报错 如果是 Rocky Linux &#38; RHEL： 如果是 openSUSE &#38; SLE：]]></description>
										<content:encoded><![CDATA[
<h3>步骤一：禁止非 root 用户使用 ping</h3>



<pre class="wp-block-code"><code>#  sysctl net.ipv4.ping_group_range="1 0"</code></pre>



<h3>步骤二：允许非 root 用户使用 ping</h3>



<pre class="wp-block-code"><code># sysctl net.ipv4.ping_group_range="0 2147483647"</code></pre>



<h3>补充：当禁止禁止非 root 用户使用 ping 时，非 root 用户使用 ping 命令的报错</h3>



<p>如果是 Rocky Linux &amp; RHEL：</p>



<pre class="wp-block-code"><code>ping: socket: Address family not supported by protocol</code></pre>



<p>如果是 openSUSE &amp; SLE：</p>



<pre class="wp-block-code"><code>Error: ping: socket: Operation not permitted</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] 文件或目录的监控 （audit 版）</title>
		<link>https://eternalcenter-sep-2022.github.io/monitor-directory-file-audit/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Tue, 05 Jul 2022 10:18:15 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Directory (系统目录)]]></category>
		<category><![CDATA[System File (系统文件)]]></category>
		<category><![CDATA[System File Security (系统文件安全)]]></category>
		<category><![CDATA[System General Log (系统普通日志)]]></category>
		<category><![CDATA[System Log (系统日志)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Privilege Security (系统权限安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Security Log (系统安全日志)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System Storage (系统存储)]]></category>
		<category><![CDATA[System Storage & System Directory & System File (系统存储 & 系统目录 & 系统文件)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=26264</guid>

					<description><![CDATA[步骤一：使用 audit 监控文件或目录 1.1 在 audit 的策略里添加要监控的目录或文件 1.1.1 案例一：监控某个目录以及目录下的目录和文件 添加以下内容： （补充：这里以监控目录 /tmp 里的目录和文件为例） 1.1.2 案例二：监控某个文件 添加以下内容： （补充：这里以监控目录 /dev/null 文件为例） 1.2 让监控目录或文件的配置生效 步骤二：显示 audit 监控记录 （补充：记录里的1) nametype=CREATE 字段代表创建2) nametype=NORMAL 字段代表普通3) nametype=DELETE 字段代表删除） 或者： （补充：这里以显示文件被修改的记录为例）]]></description>
										<content:encoded><![CDATA[
<h3>步骤一：使用 audit 监控文件或目录</h3>



<h4>1.1 在 audit 的策略里添加要监控的目录或文件</h4>



<h5>1.1.1 案例一：监控某个目录以及目录下的目录和文件</h5>



<pre class="wp-block-code"><code># vim /etc/audit/rules.d/audit.rules</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
-a exit,always -F dir=/tmp -F perm=rwxa</code></pre>



<p>（补充：这里以监控目录 /tmp 里的目录和文件为例）</p>



<h5>1.1.2 案例二：监控某个文件</h5>



<pre class="wp-block-code"><code># vim /etc/audit/rules.d/audit.rules</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
-a exit,always -S unlink -S unlinkat -S rmdir -S rename -S renameat -F path=/dev/null</code></pre>



<p>（补充：这里以监控目录 /dev/null 文件为例）</p>



<h4>1.2 让监控目录或文件的配置生效</h4>



<pre class="wp-block-code"><code># service auditd restart</code></pre>



<h3>步骤二：显示 audit 监控记录</h3>



<pre class="wp-block-code"><code># cat /var/log/audit</code></pre>



<p>（<br>补充：记录里的<br>1) nametype=CREATE 字段代表创建<br>2) nametype=NORMAL 字段代表普通<br>3) nametype=DELETE 字段代表删除<br>）</p>



<p>或者：</p>



<pre class="wp-block-code"><code># sudo ausearch -i -k user-modify</code></pre>



<p>（补充：这里以显示文件被修改的记录为例）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[命令] Linux 命令 lsof （显示进程）</title>
		<link>https://eternalcenter-sep-2022.github.io/lsof/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Thu, 23 Jun 2022 10:06:50 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Directory (系统目录)]]></category>
		<category><![CDATA[System File (系统文件)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation (系统操作)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Performance (系统性能)]]></category>
		<category><![CDATA[System Process (系统进程)]]></category>
		<category><![CDATA[System Process & System Performance (系统进程 & 系统性能)]]></category>
		<category><![CDATA[System Process Security (系统进程安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Storage (系统存储)]]></category>
		<category><![CDATA[System Storage & System Directory & System File (系统存储 & 系统目录 & 系统文件)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=26135</guid>

					<description><![CDATA[内容一：lsof 命令输出结果 内容二：lsof 命令输出结果简介 1) COMMAND 进程名2) PID （Process Id） PID 号3) USER 用户4) FD 文件描述信息（补充：cwd 代表当前目录，txt 代表 txt 文件，rtd 代表 root 目录，mem 代表内存映射文件）5) TYPE 文件类型（补充：DIR 代表当前目录，REG 代表普通文件，CHR 代表字符，a_inode 代表 Inode 文件，FIFO 代表管道或者 socket文件，netlink 代表网络，unkonwn 代表未知）6) DEVICE 设备 ID7) SIZE/OFF 进程大小8) NODE 文件的 Inode 号9) NAME 路径或链接 内容三：lsof 使用案例 3.1 案例一：显示已经被删除的文件 3.2 案例二：显示用户已打开的案例 3.2.1 显示某用户已打开的文件 &#8230; <p class="link-more"><a href="https://eternalcenter-sep-2022.github.io/lsof/" class="more-link">Continue reading<span class="screen-reader-text"> "[命令] Linux 命令 lsof （显示进程）"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h3>内容一：lsof 命令输出结果</h3>



<pre class="wp-block-code"><code># lsof | more
COMMAND     PID   TID    USER   FD      TYPE             DEVICE  SIZE/OFF       NODE NAME
systemd       1          root  cwd       DIR              251,1      4096          1 /
......</code></pre>



<h3>内容二：lsof 命令输出结果简介</h3>



<p>1) COMMAND 进程名<br>2) PID （Process Id） PID 号<br>3) USER 用户<br>4) FD 文件描述信息<br>（补充：cwd 代表当前目录，txt 代表 txt 文件，rtd 代表 root 目录，mem 代表内存映射文件）<br>5) TYPE 文件类型<br>（补充：DIR 代表当前目录，REG 代表普通文件，CHR 代表字符，a_inode 代表 Inode 文件，FIFO 代表管道或者 socket文件，netlink 代表网络，unkonwn 代表未知）<br>6) DEVICE 设备 ID<br>7) SIZE/OFF 进程大小<br>8) NODE 文件的 Inode 号<br>9) NAME 路径或链接</p>



<h3>内容三：lsof 使用案例</h3>



<h4>3.1 案例一：显示已经被删除的文件</h4>



<pre class="wp-block-code"><code># lsof | grep deleted</code></pre>



<h4>3.2 案例二：显示用户已打开的案例</h4>



<h5>3.2.1 显示某用户已打开的文件</h5>



<pre class="wp-block-code"><code># lsof -u zhumingyu mingyuzhu</code></pre>



<p>（补充：这里以显示用户 zhumingyu 和 mingyuzhu 已打开的文件为例）</p>



<h5>3.2.2 不显示某用户已打开的文件</h5>



<pre class="wp-block-code"><code># lsof -u mingyuzhu</code></pre>



<p>（补充：这里以不显示用户 mingyuzhu 已打开的文件为例）</p>



<h4>3.3 案例三：显示进程已打开的文件</h4>



<h5>3.3.1 显示某进程已打开的文件</h5>



<pre class="wp-block-code"><code># lsof -p 1024</code></pre>



<p>（补充：这里以显示 PID 号是 1024 已打开的文件为例）</p>



<h5>3.3.2 不显示某进程已打开的所有文件</h5>



<pre class="wp-block-code"><code># lsof -p ^1024</code></pre>



<p>（补充：这里以不显示 PID 号是 1024 已打开的文件为例）</p>



<h5>3.3.3 显示某几个进程已打开的文件</h5>



<pre class="wp-block-code"><code># lsof -p 1,2,3</code></pre>



<p>（补充：这里以显示 PID 号是 1、2 和 3 已打开的文件为例）</p>



<h4>3.4 案例四：显示已打开的网络文件</h4>



<h5>3.4.1 显示所有已打开的网络文件</h5>



<pre class="wp-block-code"><code># lsof -i</code></pre>



<h5>3.4.2 显示所有 IPv4 协议已打开的文件</h5>



<pre class="wp-block-code"><code># lsof -i 4</code></pre>



<h5>3.4.3 显示所有 IPv6 协议已打开的文件</h5>



<pre class="wp-block-code"><code># lsof -i 6</code></pre>



<h5>3.4.4 显示所有 TCP 协议已打开的文件</h5>



<pre class="wp-block-code"><code># lsof -i TCP</code></pre>



<h5>3.4.5 显示所有 TCP 协议已打开的文件</h5>



<pre class="wp-block-code"><code># lsof -i UDP</code></pre>



<h5>3.4.6 显示某个 TCP 端口或者 UDP 端口已打开的文件</h5>



<pre class="wp-block-code"><code># lsof -i:22</code></pre>



<p>（补充：这里以显示 TCP 或者 UPD 的 22 端口已打开的文件为例）</p>



<h5>3.4.7 显示某个 TCP 端口已打开的文件</h5>



<pre class="wp-block-code"><code># lsof -i TCP:22</code></pre>



<p>（补充：这里以显示 TCP 的 22 端口已打开的文件为例）</p>



<h5>3.4.8 显示某几个 TCP 端口打开的文件</h5>



<pre class="wp-block-code"><code># lsof -i TCP:1-1024</code></pre>



<p>（补充：这里以显示 TCP 的 1 端口到 1024 端口打开的文件为例）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] Linux 环境变量 （$PATH） 的设置</title>
		<link>https://eternalcenter-sep-2022.github.io/environment-variable/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 17 Jun 2022 06:23:44 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=24425</guid>

					<description><![CDATA[内容一：临时设置环境变量 （$PATH） 1.1 查看当前环境变量 （$PATH） 值 1.2 临时设置环境变量 （$PATH） 值 内容二：永久设置环境变量 （$PATH） 2.1 给某个用户设置永久环境变量 2.1.1 切换到要永久设置环境变量 （$PATH）的用户 （补充：这里以切换到 root 用户为例） 2.1.2 配置 ~/.bashrc 配置文件 添加以下内容： （补充： 这里以将环境变量 （$PATH） 设置为 /usr/locar/new/bin 为例） 2.1.3 让环境变量 （$PATH） 设置生效 2.2 全局永久设置环境变量 2.2.1 配置 /etc/profile 配置文件 添加以下内容： （补充： 这里以将环境变量 （$PATH） 设置为 /usr/locar/new/bin 为例） 2.2.2 让环境变量 （$PATH） 设置生效]]></description>
										<content:encoded><![CDATA[
<h3 class="has-text-align-left">内容一：临时设置环境变量 （$PATH）</h3>



<h4 class="has-text-align-left">1.1 查看当前环境变量 （$PATH） 值</h4>



<pre class="wp-block-code"><code># echo $PATH</code></pre>



<h4>1.2 临时设置环境变量 （$PATH） 值</h4>



<pre class="wp-block-code"><code># export PATH=$PATH:/usr/locar/new/bin</code></pre>



<h3>内容二：永久设置环境变量 （$PATH）</h3>



<h4>2.1 给某个用户设置永久环境变量</h4>



<h5>2.1.1 切换到要永久设置环境变量 （$PATH）的用户</h5>



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



<p>（补充：这里以切换到 root 用户为例）</p>



<h5>2.1.2 配置 ~/.bashrc 配置文件</h5>



<pre class="wp-block-code"><code># vim ~/.bashrc</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
export PATH=$PATH:/usr/locar/new/bin</code></pre>



<p>（补充： 这里以将环境变量 （$PATH） 设置为 /usr/locar/new/bin 为例）</p>



<h5>2.1.3 让环境变量 （$PATH） 设置生效</h5>



<pre class="wp-block-code"><code># source ~/.bashrc</code></pre>



<h4>2.2 全局永久设置环境变量</h4>



<h5>2.2.1 配置 /etc/profile 配置文件</h5>



<pre class="wp-block-code"><code># vim /etc/profile</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
export PATH=$PATH:/usr/locar/new/bin</code></pre>



<p>（补充： 这里以将环境变量 （$PATH） 设置为 /usr/locar/new/bin 为例）</p>



<h5>2.2.2 让环境变量 （$PATH） 设置生效</h5>



<pre class="wp-block-code"><code># source /etc/profile</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] Linux sudo 命令安全的加强</title>
		<link>https://eternalcenter-sep-2022.github.io/sudo-secure-enhance/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 17 Jun 2022 03:20:21 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=24376</guid>

					<description><![CDATA[仅让 use pty 可以使用 sudo 命令 （避免后台进程使用 sudo 命令） 或者： 添加以下内容：]]></description>
										<content:encoded><![CDATA[
<p>仅让 use pty 可以使用 sudo 命令 （避免后台进程使用 sudo 命令）</p>



<pre class="wp-block-code"><code># vim /etc/sudoers</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># visudo</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
Defaults use_pty</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] Linux sudo 日志的开启</title>
		<link>https://eternalcenter-sep-2022.github.io/sudo-log/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 17 Jun 2022 03:14:07 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Log (系统日志)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Security Log (系统安全日志)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=24372</guid>

					<description><![CDATA[步骤一：开启 sudo 日志 或者： 添加以下内容： 步骤二：显示 sudo 日志 2.1 退出后重新登录 （步骤略） 2.2 显示 sudo 日志]]></description>
										<content:encoded><![CDATA[
<h3>步骤一：开启 sudo 日志</h3>



<pre class="wp-block-code"><code># vim /etc/sudoers</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># visudo</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
Defaults logfile="/var/log/sudo.log"</code></pre>



<h3>步骤二：显示 sudo 日志</h3>



<h4>2.1 退出后重新登录</h4>



<p>（步骤略）</p>



<h4>2.2 显示 sudo 日志</h4>



<pre class="wp-block-code"><code># cat /var/log/sudo.log</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[工具] Shell 显示可以无密码登录系统的用户 （以 1 行的形式显示）</title>
		<link>https://eternalcenter-sep-2022.github.io/shell-login-check/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Sat, 11 Jun 2022 13:33:07 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[Language (语言)]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Shell Monitor (监控)]]></category>
		<category><![CDATA[Shell Tools (工具)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation (系统操作)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=23846</guid>

					<description><![CDATA[介绍 基本信息 作者：朱明宇名称：显示可以登录系统的用户 （以 1 行到形式显示）作用：显示可以登录系统的用户 （以 1 行到形式显示） 使用方法 1. 给此脚本添加执行权限2. 执行此脚本 脚本]]></description>
										<content:encoded><![CDATA[
<h2>介绍</h2>



<h3>基本信息</h3>



<p>作者：朱明宇<br>名称：显示可以登录系统的用户 （以 1 行到形式显示）<br>作用：显示可以登录系统的用户 （以 1 行到形式显示）</p>



<h3>使用方法</h3>



<p>1. 给此脚本添加执行权限<br>2. 执行此脚本</p>



<h2>脚本</h2>



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

userlist=
n=`cat /etc/passwd | wc -l`
i=1

while &#91; $i -le $n ]
do
	line=`sed -n "$&#91;i]p" /etc/passwd`
	echo $line | egrep "nologin$|false$" &amp;&gt; /dev/null
	if &#91; $? -ne 0 ];then
                userlist="$userlist `echo $line | awk -F: '{print $1}'`"
	fi
	let i++
done

echo $userlist</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[排错] 解决 Linux 执行 crontab -e 命令时报错 “You (&#8230;&#8230;) are not allowed to use this program (crontab)”</title>
		<link>https://eternalcenter-sep-2022.github.io/debug-you-are-not-allowed-to-use-this-program-crontab/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 10 Jun 2022 10:07:51 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System File Security (系统文件安全)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation (系统操作)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Performance (系统性能)]]></category>
		<category><![CDATA[System Port Security (系统端口安全)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Process (系统进程)]]></category>
		<category><![CDATA[System Process & System Performance (系统进程 & 系统性能)]]></category>
		<category><![CDATA[System Process Security (系统进程安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=23780</guid>

					<description><![CDATA[解决方法 如果在系统中没有 /etc/cron.deny 配置文件，在 /etc/cron.allow 配置文件中添加要使用 crontab -e 命令的用户 添加以下内容： （补充：这里以添加用户 zhumingyu 为例） 如果在系统中没有 /etc/cron.allow 配置文件，在 /etc/cron.allow 配置文件中删除要使用 crontab -e 命令的用户 删除以下内容： （补充：这里以删除用户 zhumingyu 为例）]]></description>
										<content:encoded><![CDATA[
<h2>解决方法</h2>



<p>如果在系统中没有 /etc/cron.deny 配置文件，在 /etc/cron.allow 配置文件中添加要使用 crontab -e 命令的用户</p>



<pre class="wp-block-code"><code># vim /etc/cron.allow</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
zhumingyu</code></pre>



<p>（补充：这里以添加用户 zhumingyu 为例）</p>



<p>如果在系统中没有 /etc/cron.allow 配置文件，在 /etc/cron.allow 配置文件中删除要使用 crontab -e 命令的用户</p>



<pre class="wp-block-code"><code># vim /etc/cron.allow</code></pre>



<p>删除以下内容：</p>



<pre class="wp-block-code"><code>......
zhumingyu
......</code></pre>



<p>（补充：这里以删除用户 zhumingyu 为例）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] Linux 某个所属组里有哪些用户的显示</title>
		<link>https://eternalcenter-sep-2022.github.io/group-display/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Wed, 08 Jun 2022 02:50:05 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System File (系统文件)]]></category>
		<category><![CDATA[System File Security (系统文件安全)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation (系统操作)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Privilege Security (系统权限安全)]]></category>
		<category><![CDATA[System Process Security (系统进程安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Storage (系统存储)]]></category>
		<category><![CDATA[System Storage & System Directory & System File (系统存储 & 系统目录 & 系统文件)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=23715</guid>

					<description><![CDATA[方法一：通过 /etc/group 配置文件显示某个附属所属组里有哪些用户 （注意：此方法并不能显示出把这些所属组当作主要所属组的用户） 方法二：通过 /etc/passwd 配置文件和 id 命令等显示主要所属组和附属所属组 （补充：可以通过肉眼比对此命令的输出结果来判断其主要所属组和附属所属组）]]></description>
										<content:encoded><![CDATA[
<h3>方法一：通过 /etc/group 配置文件显示某个附属所属组里有哪些用户</h3>



<pre class="wp-block-code"><code># cat /etc/group</code></pre>



<p>（注意：此方法并不能显示出把这些所属组当作主要所属组的用户）</p>



<h3>方法二：通过 /etc/passwd 配置文件和 id 命令等显示主要所属组和附属所属组</h3>



<pre class="wp-block-code"><code># for i in `cat /etc/passwd | egrep -v "nologin$|false$|half|sync|shutdown|halt" | awk -F: '{print $1}'`; do id $i; done | sort -k2</code></pre>



<p>（补充：可以通过肉眼比对此命令的输出结果来判断其主要所属组和附属所属组）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] sudo 提权的实现 （sudo 提权的同时可以使用代理） （openSUSE &#038; SLE）</title>
		<link>https://eternalcenter-sep-2022.github.io/sudo-self-proxy-opensuse-sle/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Sat, 15 Jan 2022 14:47:45 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Setting (系统设置)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=21217</guid>

					<description><![CDATA[步骤一：给用户添加相应的 sudo 权限 或者： 添加以下内容： （补充：这里以给用户 zhumingyu 添加 /usr/bin/mysql 命令为例） 步骤二：设置用户使用自己的密码实现 sudo 提权 在 这一行下面添加： （补充：这里以允许用户在进行 sudo 提权的同时也能使用 http_proxy、https_proxy 为例）]]></description>
										<content:encoded><![CDATA[
<h3>步骤一：给用户添加相应的 sudo 权限</h3>



<pre class="wp-block-code"><code># vim /etc/sudoers</code></pre>



<p>或者：</p>



<pre class="wp-block-code"><code># visudo</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>……
zhumingyu ALL=(ALL) /usr/bin/mysql</code></pre>



<p>（补充：这里以给用户 zhumingyu 添加 /usr/bin/mysql 命令为例）</p>



<h3>步骤二：设置用户使用自己的密码实现 sudo 提权</h3>



<pre class="wp-block-code"><code># vim /etc/sudoers</code></pre>



<p>在</p>



<pre class="wp-block-code"><code>......
env_reset
......</code></pre>



<p>这一行下面添加：</p>



<pre class="wp-block-code"><code>......
Defaults env_keep += "http_proxy https_proxy"
......</code></pre>



<p>（补充：这里以允许用户在进行 sudo 提权的同时也能使用 http_proxy、https_proxy 为例）</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[工具] Shell 批量修改多个远程服务器某个用户的密码 （精致版）</title>
		<link>https://eternalcenter-sep-2022.github.io/shell-password-change-refined-version/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Sun, 10 Oct 2021 13:08:50 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[Language (语言)]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Shell Deployment (部署)]]></category>
		<category><![CDATA[Shell Others (其它)]]></category>
		<category><![CDATA[Shell Tools (工具)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=18100</guid>

					<description><![CDATA[介绍 基本信息 作者：朱明宇名称：批量修改多个远程服务器某个用户的密码作用：批量修改多个远程服务器某个用户的密码 使用方法 1. 将此脚本和清单 $list 文件放在同一目录下2. 清单 $list 里每服务器名占用 1 行3. 给脚本分割线里的变量赋值4. 给此脚本添加执行权限5. 执行此脚本 脚本分割线里的变量 1. list=”list.txt” #指定清单的目录和名称2. user=eternalcenter #指定要修改密码的用户3. password=eternalcenter #指定要修改的密码 注意 此脚本执行前必须要先保证执行本脚本的用户能无密码 ssh 远程这些远程服务器，并且可以通过 sudo 获得 su 的 root 权限 脚本]]></description>
										<content:encoded><![CDATA[
<h2>介绍</h2>



<h3>基本信息</h3>



<p>作者：朱明宇<br>名称：批量修改多个远程服务器某个用户的密码<br>作用：批量修改多个远程服务器某个用户的密码</p>



<h3>使用方法</h3>



<p>1. 将此脚本和清单 $list 文件放在同一目录下<br>2. 清单 $list 里每服务器名占用 1 行<br>3. 给脚本分割线里的变量赋值<br>4. 给此脚本添加执行权限<br>5. 执行此脚本</p>



<h3>脚本分割线里的变量</h3>



<p>1. list=”list.txt” #指定清单的目录和名称<br>2. user=eternalcenter #指定要修改密码的用户<br>3. password=eternalcenter #指定要修改的密码</p>



<h3>注意</h3>



<p>此脚本执行前必须要先保证执行本脚本的用户能无密码 ssh 远程这些远程服务器，并且可以通过 sudo 获得 su 的 root 权限</p>



<h2>脚本</h2>



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

####################### Separator ########################

list="list.txt"
user=eternalcenter
password=eternalcenter

####################### Separator ########################

num=1

cat $list
for i in `cat $list`
do
        echo $num
        echo $i

	ssh -t $i "type lsb_release" &amp;&gt; /dev/null
        if &#91; $? -ne 0 ]; then
              distribution=`ssh -t $i "cat /etc/*release | grep '^NAME'"`
	      if &#91; $? -ne 0 ];then
		      distribution=`ssh -t $i "cat /etc/*release"`
	      fi
        else
              distribution=`ssh -t $i "lsb_release -i | grep 'ID' | grep -v 'n/a'"`
        fi;

        echo $distribution

	case $distribution in
		*"RedHat"* | *"Red Hat"*)
		ssh -t $i "sudo -u root su - root -c \"echo $password | passwd --stdin $user\""
		if &#91; $? -eq 0 ];then
			echo -e "\033&#91;32m$i is success\033&#91;0m"
		else
			echo -e "\033&#91;31m$i is fail\033&#91;0m"
		fi
		;;

		*"CentOS"*)
		ssh -t $i "sudo -u root su - root -c \"echo $password | passwd --stdin $user\""
		if &#91; $? -eq 0 ];then
			echo -e "\033&#91;32m$i is success\033&#91;0m"
		else
			echo -e "\033&#91;31m$i is fail\033&#91;0m"
		fi
		;;

		*"SUSE"* | *"SLES"*)
		ssh -t $i "sudo -u root su - root -c \"echo $user:$password | chpasswd\""
		if &#91; $? -eq 0 ];then
			echo -e "\033&#91;32m$i is success\033&#91;0m"
		else
			echo -e "\033&#91;31m$i is fail\033&#91;0m"
		fi
		;;
               
		*"openSUSE"*)
		ssh -t $i "sudo -u root su - root -c \"echo $user:$password | chpasswd\""
		if &#91; $? -eq 0 ];then
			echo -e "\033&#91;32m$i is success\033&#91;0m"
		else
			echo -e "\033&#91;31m$i is fail\033&#91;0m"
		fi
		;;

		*)
                echo -e "\033&#91;31m$i is fail \033&#91;0m" 
		;;
        esac

        let num++

        echo
done</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[工具] Shell 批量修改多个远程服务器某个用户的密码 （简单版）</title>
		<link>https://eternalcenter-sep-2022.github.io/shell-password-change-simple-version/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Wed, 09 Jun 2021 10:37:59 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[Language (语言)]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Shell Deployment (部署)]]></category>
		<category><![CDATA[Shell Others (其它)]]></category>
		<category><![CDATA[Shell Tools (工具)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=14638</guid>

					<description><![CDATA[介绍 基本信息 作者：朱明宇名称：批量修改多个远程服务器某个用户的密码作用：批量修改多个远程服务器某个用户的密码，并显示密码更新时间 使用方法 1. 将此脚本和清单 $list 文件放在同一目录下2. 清单 $list 里每个服务器名占用 1 行3. 给脚本分割线里的变量赋值4. 给此脚本添加执行权限5. 执行此脚本 脚本分割线里的变量 1. list=&#8221;list.txt&#8221; #指定清单的目录和名称2. user=eternalcenter #指定要修改密码的用户3. password=eternalcenter #指定要修改的密码 注意 此脚本执行前必须要先保证执行本脚本的用户能无密码 ssh 远程这些远程服务器，并且可以通过 sudo 获得 su 的 root 权限 脚本]]></description>
										<content:encoded><![CDATA[
<h2 id="介绍">介绍</h2>



<h3>基本信息</h3>



<p>作者：朱明宇<br>名称：批量修改多个远程服务器某个用户的密码<br>作用：批量修改多个远程服务器某个用户的密码，并显示密码更新时间</p>



<h3>使用方法</h3>



<p>1. 将此脚本和清单 $list 文件放在同一目录下<br>2. 清单 $list 里每个服务器名占用 1 行<br>3. 给脚本分割线里的变量赋值<br>4. 给此脚本添加执行权限<br>5. 执行此脚本</p>



<h3>脚本分割线里的变量</h3>



<p>1. list=&#8221;list.txt&#8221; #指定清单的目录和名称<br>2. user=eternalcenter #指定要修改密码的用户<br>3. password=eternalcenter #指定要修改的密码</p>



<h3>注意</h3>



<p>此脚本执行前必须要先保证执行本脚本的用户能无密码 ssh 远程这些远程服务器，并且可以通过 sudo 获得 su 的 root 权限</p>



<h2 id="脚本">脚本</h2>



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

####################### Separator ########################

list="list.txt"
user=eternalcenter
password=eternalcenter

####################### Separator ########################

num=1

cat $list
for i in `cat $list`
do
        echo $num
        echo $i
        ssh -t $i "sudo -u root su - root -c \"echo $password | passwd --stdin $user\""
        ssh -t $i "sudo -u root su - root -c \"echo $user:$password | chpasswd\""
        ssh -t $i sudo -u root su - root -c \"chage -l $user\"
        let num++

        echo
done</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[命令] Linux 命令 sshpass （密码非交互式 ssh） （转载）</title>
		<link>https://eternalcenter-sep-2022.github.io/sshpass/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 15 Jan 2021 06:55:05 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Login Security (系统登录安全)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Operation (系统操作)]]></category>
		<category><![CDATA[System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=13214</guid>

					<description><![CDATA[注明：所有转载内容皆直接从被转载文章网页的标题和内容的文本中复制而来]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-code"><code>sshpass的安装使用
 
1：sshpass下载与安装
     yum安装：

    yum install sshpass

     若yum安装不上，则用下面方法

        https:&#47;&#47;sourceforge.net/projects/sshpass/files/
          or
        https://pan.baidu.com/s/1pLNxeLd
         or
        wget http://sourceforge.net/projects/sshpass/files/latest/download -O sshpass.tar.gz



 
2：下载后，解压，安装

      

        tar -zxvf sshpass-1.06.tar.gz
        cd sshpass-1.06
        ./configure
        make
        make install


3：使用命令

         

    sshpass -p 123456 scp /home/file.txt root@10.0.0.37:/home/copy



      后面这个是 “Are you sure you want to continue connecting (yes/no)”使得这个自动接受，若不加，则成功不了
 
4：脚本

    复制代码

          #!/bin/bash
            password=123456
            user=root
            ip=10.0.0.37
            file=/home/file.txt
           sshpass -p $password scp file $user@$ip:/home/copy/


————————————————
版权声明：本文为CSDN博主「totoroKing」的原创文章，遵循 CC 4.0 BY-SA 版权协议，转载请附上原文出处链接及本声明。
原文链接：https://blog.csdn.net/qq_30553235/article/details/78711491</code></pre>



<p>注明：所有转载内容皆直接从被转载文章网页的标题和内容的文本中复制而来</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img width="1012" height="209" src="https://eternalcenter-sep-2022.github.io/wp-content/uploads/2021/01/版权申明证明-sshpass.png" alt="" class="wp-image-13216" srcset="https://eternalcenter-sep-2022.github.io/wp-content/uploads/2021/01/版权申明证明-sshpass.png 1012w, https://eternalcenter-sep-2022.github.io/wp-content/uploads/2021/01/版权申明证明-sshpass-300x62.png 300w, https://eternalcenter-sep-2022.github.io/wp-content/uploads/2021/01/版权申明证明-sshpass-768x159.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /><figcaption><em>CC 4.0 BY-SA 版权协议网址：https://creativecommons.org/licenses/by-sa/4.0/deed.z</em></figcaption></figure></div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[步骤] Linux 文件或目录的查找 （特殊权限）</title>
		<link>https://eternalcenter-sep-2022.github.io/special-privilege-find/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Fri, 07 Aug 2020 03:02:56 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Directory (系统目录)]]></category>
		<category><![CDATA[System File (系统文件)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Privilege Security (系统权限安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System Storage & System Directory & System File (系统存储 & 系统目录 & 系统文件)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=10429</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-code"><code># find / -type f \( -perm -1000 -o -perm -2000 -o -perm -4000 \) -print</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[工具] Shell 批量修改多个远程服务器某个用户的过期密码</title>
		<link>https://eternalcenter-sep-2022.github.io/shell-expired-password-change/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Thu, 06 Aug 2020 08:42:43 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[Language (语言)]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Shell Deployment (部署)]]></category>
		<category><![CDATA[Shell Others (其它)]]></category>
		<category><![CDATA[Shell Tools (工具)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System User (系统用户)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=10423</guid>

					<description><![CDATA[介绍 基本信息 作者：朱明宇名称：批量修改多个远程服务器某个用户的过期密码作用：批量修改多个远程服务器某个用户的过期密码 使用方法 1. 将此脚本和清单 $list 文件放在同一目录下2. 清单 $list 里每个远程服务器名或 IP 地址占用 1 行3. 在此脚本的分割线内写入相应的内容4. 在执行此脚本的系统上安装 expect5. 给此脚本添加执行权限6. 执行此脚本 脚本分割线里的变量 1. oldpassword=123 #原密码2. newpassword=abc #新密码3. user=root #要修改密码的用户4. list=servers.txt #指定服务器清单 脚本]]></description>
										<content:encoded><![CDATA[
<h2>介绍</h2>



<h3>基本信息</h3>



<p>作者：朱明宇<br>名称：批量修改多个远程服务器某个用户的过期密码<br>作用：批量修改多个远程服务器某个用户的过期密码</p>



<h3>使用方法</h3>



<p>1. 将此脚本和清单 $list 文件放在同一目录下<br>2. 清单 $list 里每个远程服务器名或 IP 地址占用 1 行<br>3. 在此脚本的分割线内写入相应的内容<br>4. 在执行此脚本的系统上安装 expect<br>5. 给此脚本添加执行权限<br>6. 执行此脚本</p>



<h3>脚本分割线里的变量</h3>



<p>1. oldpassword=123 #原密码<br>2. newpassword=abc #新密码<br>3. user=root #要修改密码的用户<br>4. list=servers.txt #指定服务器清单</p>



<h2>脚本</h2>



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

####################### Separator ########################

oldpassword=123
newpassword=abc
user=root
list=servers.txt

####################### Separator ########################

set timeout 5

for i in `cat $list`
do
        echo $i
        ssh $i "whoami"

        if &#91; $? -eq 0 ];then
                continue
        fi

        expect &lt;&lt; EOF
        spawn ssh $user@$i
        expect "Current password:"    {send "$oldpassword\r"}
        expect "New password:"        {send "$newpassword\r"}
        expect "Retype new password:" {send "$newpassword\r"}
        expect "&gt;"                    {send "\r"}
        EOF

       echo

done</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[内容] Linux Umask 的设置</title>
		<link>https://eternalcenter-sep-2022.github.io/umask/</link>
		
		<dc:creator><![CDATA[Mingyu Zhu]]></dc:creator>
		<pubDate>Sat, 01 Aug 2020 08:54:22 +0000</pubDate>
				<category><![CDATA[Chinese (中文)]]></category>
		<category><![CDATA[System (系统)]]></category>
		<category><![CDATA[System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志)]]></category>
		<category><![CDATA[System Privilege (系统权限)]]></category>
		<category><![CDATA[System Privilege Security (系统权限安全)]]></category>
		<category><![CDATA[System Security (系统安全)]]></category>
		<category><![CDATA[System User & System Privilege (系统用户 & 系统权限)]]></category>
		<guid isPermaLink="false">https://eternalcenter-sep-2022.github.io/?p=10411</guid>

					<description><![CDATA[内容一：Umask 值的含义 如果 Umask 的值是 0022：创建的新目录的默认权限是：777 &#8211; 022 = 755创建的新文件的默认权限是：666 &#8211; 022 = 644 内容二：临时设置 Umask 2.1 查看当前 Umask 值 2.2 临时设置 Umask 值 2.2.1 方法一：使用权限数字设置默认权限值 2.2.2 方法二：使用权限标志设置默认权限值 内容三：永久设置 umask 3.1 给某个用户单独永久设置 Umask 3.1.1 切换到要永久设置 Umask 的用户 （补充：这里以切换到 root 用户为例） 3.1.2 给某个用户单独添加 Umask 参数 添加以下内容： （补充：这里以将 Umask 设置为 022 为例） 3.1.3 让 Umask 设置生效 3.2 &#8230; <p class="link-more"><a href="https://eternalcenter-sep-2022.github.io/umask/" class="more-link">Continue reading<span class="screen-reader-text"> "[内容] Linux Umask 的设置"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<h3>内容一：Umask 值的含义</h3>



<p>如果 Umask 的值是 0022：<br>创建的新目录的默认权限是：777 &#8211; 022 = 755<br>创建的新文件的默认权限是：666 &#8211; 022 = 644</p>



<h3>内容二：临时设置 Umask</h3>



<h4>2.1 查看当前 Umask 值</h4>



<pre class="wp-block-code"><code># umask
0022</code></pre>



<h4>2.2 临时设置 Umask 值</h4>



<h5>2.2.1 方法一：使用权限数字设置默认权限值</h5>



<pre class="wp-block-code"><code># umask 0002</code></pre>



<h5>2.2.2 方法二：使用权限标志设置默认权限值</h5>



<pre class="wp-block-code"><code># umask -S u=rwx,g=rwx,o=rw</code></pre>



<h3>内容三：永久设置 umask</h3>



<h4>3.1 给某个用户单独永久设置 Umask</h4>



<h5>3.1.1 切换到要永久设置 Umask 的用户</h5>



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



<p>（补充：这里以切换到 root 用户为例）</p>



<h5>3.1.2 给某个用户单独添加 Umask 参数</h5>



<pre class="wp-block-code"><code># vim ~/.bashrc </code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
umask 022</code></pre>



<p>（补充：这里以将 Umask 设置为 022 为例）</p>



<h5>3.1.3 让 Umask 设置生效</h5>



<pre class="wp-block-code"><code># source ~/.bashrc</code></pre>



<h4>3.2 全局永久设置 Umask 的方法</h4>



<h5>3.2.1 在 /etc/login.defs 配置文件里设置默认 Umask 参数</h5>



<pre class="wp-block-code"><code># vim /etc/login.defs</code></pre>



<p>将以下内容：</p>



<pre class="wp-block-code"><code>UMASK ......</code></pre>



<p>修改为：</p>



<pre class="wp-block-code"><code>UMASK           022</code></pre>



<p>（补充：这里以将 Umask 的默认值设置为 022 为例）</p>



<h5>3.2.2 在 /etc/profile 配置文件里设置全局 Umask 参数</h5>



<pre class="wp-block-code"><code># vim /etc/profile</code></pre>



<p>将以下内容：</p>



<pre class="wp-block-code"><code>......
if &#91; $UID -gt 199 ] &amp;&amp; &#91; "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
    umask ......
else
    umask ......
fi
......</code></pre>



<p>修改为：</p>



<pre class="wp-block-code"><code>......
if &#91; $UID -gt 199 ] &amp;&amp; &#91; "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
    umask 002
else
    umask 022
fi
......</code></pre>



<p>（补充：这里以将 UID 小于 199 的用户 Umask 设置为 002，UID 大于等于 199 的用户 Umask 设置为 022 为例）</p>



<p>（注意：openSUSE &amp; SLE 的 /etc/profile 配置文件里没有这些内容，所以如果是对 openSUSE &amp; SLE 进行操作时则需要手动创建这些内容）</p>



<p>或者：</p>



<pre class="wp-block-code"><code># vim /etc/profile</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
umask 022</code></pre>



<p>（补充：这里以将所有用户的全局 Umask 设置为 022 为例）</p>



<h5>3.2.3 在 /etc/bashrc 配置文件里设置全局 Umask 参数</h5>



<pre class="wp-block-code"><code># vim /etc/bashrc</code></pre>



<p>将以下内容：</p>



<pre class="wp-block-code"><code>......
if &#91; $UID -gt 199 ] &amp;&amp; &#91; "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
    umask ......
else
    umask ......
fi
......</code></pre>



<p>修改为：</p>



<pre class="wp-block-code"><code>......
if &#91; $UID -gt 199 ] &amp;&amp; &#91; "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
    umask 002
else
    umask 022
fi
......</code></pre>



<p>（补充：这里以将 UID 小于 199 的用户 Umask 设置为 002，UID 大于等于 199 的用户 Umask 设置为 022 为例）</p>



<p>（注意： openSUSE &amp; SLE 没有 /etc/bashrc 配置文件，所以如果是对 openSUSE &amp; SLE 进行操作时则需要手动创建此文件和这些内容）</p>



<p>或者：</p>



<pre class="wp-block-code"><code># vim /etc/bashrc</code></pre>



<p>添加以下内容：</p>



<pre class="wp-block-code"><code>......
umask 022</code></pre>



<p>（补充：这里以将所有用户的全局 Umask 设置为 022 为例）</p>



<p>（注意： openSUSE &amp; SLE 没有 /etc/bashrc 配置文件，所以如果是对 openSUSE &amp; SLE 进行操作时则需要手动创建此文件）</p>



<h5>3.2.4 让永久设置的 Umask 设置生效</h5>



<pre class="wp-block-code"><code># source /etc/bashrc ; source /etc/profile</code></pre>



<p>（<br>注意：<br>1) 当永久设置的 Umask 生效后，用户必须要重新登录后才会刷新 Umask<br>2) 当 /etc/login.defs 配置文件、/etc/bashrc 配置文件和 /etc/profile 配置文件里设置的 Umask 值不一致时，会以 /etc/profile 文件里设置的为准<br>3) 当同一个文件里设置了多个 Umask 个值时，会以最后一个值为准<br>）</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
