uTools-Manuals/docs/linux/usermod.html
2019-04-21 11:50:48 +08:00

35 lines
2.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 id="usermod">usermod</h1>
<p>用于修改用户的基本信息</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>usermod命令</strong> 用于修改用户的基本信息。usermod 命令不允许你改变正在线上的使用者帐号名称。当 usermod 命令用来改变user id必须确认这名user没在电脑上执行任何程序。你需手动更改使用者的 crontab 档。也需手动更改使用者的 at 工作档。采用 NIS server 须在server上更动相关的NIS设定。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">usermod(选项)(参数)</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-c&lt;备注&gt;:修改用户帐号的备注文字;
-d&lt;登入目录&gt;:修改用户登入时的目录;
-e&lt;有效期限&gt;:修改帐号的有效期限;
-f&lt;缓冲天数&gt;:修改在密码过期后多少天即关闭该帐号;
-g&lt;群组&gt;:修改用户所属的群组;
-G&lt;群组&gt;;修改用户所属的附加群组;
-l&lt;帐号名称&gt;:修改用户帐号名称;
-L锁定用户密码使密码无效
-s&lt;shell&gt;修改用户登入后所使用的shell
-u&lt;uid&gt;修改用户ID
-U:解除密码锁定。</code></pre>
<h3 id="参数">参数</h3>
<p>登录名:指定要修改信息的用户登录名。</p>
<h3 id="实例">实例</h3>
<p>将 newuser2 添加到组 staff 中:</p>
<pre><code class="language-bash">usermod -G staff newuser2</code></pre>
<p>修改newuser的用户名为newuser1</p>
<pre><code class="language-bash">usermod -l newuser1 newuser</code></pre>
<p>锁定账号newuser1</p>
<pre><code class="language-bash">usermod -L newuser1</code></pre>
<p>解除对newuser1的锁定</p>
<pre><code class="language-bash">usermod -U newuser1</code></pre>
<p>增加用户到用户组中:</p>
<pre><code class="language-bash">apk add shadow # 安装 shadow 包, usermod 命令包含在 usermod 中
usermod -aG group user # 添加用户到用户组中</code></pre>
<p><code>-a</code> 参数表示附加,只和 <code>-G</code> 参数一同使用,表示将用户增加到组中。</p>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->