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

<channel>
	<title>ユーザー名変更 &#8211; スグブログ</title>
	<atom:link href="https://sugublog.org/tag/%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BC%E5%90%8D%E5%A4%89%E6%9B%B4/feed/" rel="self" type="application/rss+xml" />
	<link>https://sugublog.org</link>
	<description>ブログ運営について発信中</description>
	<lastBuildDate>Sun, 02 Jun 2024 08:25:27 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://sugublog.org/wp-content/uploads/2021/07/icon_20210703-min-150x150.png</url>
	<title>ユーザー名変更 &#8211; スグブログ</title>
	<link>https://sugublog.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【Linux基礎】ユーザー名などを変更する方法！usermodコマンドを使用</title>
		<link>https://sugublog.org/linux-usermod-username-change/</link>
					<comments>https://sugublog.org/linux-usermod-username-change/?noamp=mobile#respond</comments>
		
		<dc:creator><![CDATA[suguru]]></dc:creator>
		<pubDate>Sat, 25 May 2024 07:54:14 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[サーバ]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[usermod]]></category>
		<category><![CDATA[ユーザー名変更]]></category>
		<guid isPermaLink="false">https://sugublog.org/?p=6811</guid>

					<description><![CDATA[<p><img src="https://sugublog.org/wp-content/uploads/2021/09/jump0907-4-1024x768.jpg" class="webfeedsFeaturedVisual" /></p>Linuxサーバーでユーザ―名など情報を変更したい場合はないでしょうか？ ユーザーを削除して再作成などしてないでしょうか？ という事で今回はLinuxサーバーで、ユーザー変更する方法を教えます。 ユーザー作成したけど、ユ [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://sugublog.org/wp-content/uploads/2021/09/jump0907-4-1024x768.jpg" class="webfeedsFeaturedVisual" /></p>
<p>Linuxサーバーで<strong><span class="swl-inline-color has-swl-deep-01-color">ユーザ―名など情報を変更</span></strong>したい場合はないでしょうか？</p>



<p>ユーザーを削除して再作成などしてないでしょうか？</p>



<p>という事で今回はLinuxサーバーで、<strong><span class="swl-inline-color has-swl-deep-01-color">ユーザー変更する方法</span></strong>を教えます。</p>


<div class="p-blogParts post_content" data-partsID="5908">
<p>筆者はWindowsサーバーやLinuxサーバーの運用構築を11年間以上おこなってきました。その経験を元に知識を公開していきます！</p>
</div>


<p>ユーザー作成したけど、<span class="swl-inline-color has-swl-deep-01-color">ユーザー名やホームディレクトリを変更したい人</span>はこの記事を読んでください。</p>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle ads" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-9330904718533231" data-ad-slot="6086594686"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<h2 class="wp-block-heading">Linuxサーバーでユーザー名を変更する方法</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="683" src="https://sugublog.org/wp-content/uploads/2021/12/diet1205-7-1024x683.jpg" alt="ユーザー名変更" class="wp-image-4698" srcset="https://sugublog.org/wp-content/uploads/2021/12/diet1205-7-1024x683.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/12/diet1205-7-300x200.jpg 300w, https://sugublog.org/wp-content/uploads/2021/12/diet1205-7-768x512.jpg 768w, https://sugublog.org/wp-content/uploads/2021/12/diet1205-7.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>Linuxサーバーで<strong><span class="swl-inline-color has-swl-deep-01-color">ユーザーを変更するコマンド</span></strong>の基礎構文を以下に示します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>usermod オプション ユーザー名</code></pre></div>



<p>これでユーザーの情報を変更できます。</p>



<h2 class="wp-block-heading">Linuxサーバーでユーザーを変更する時のオプション</h2>



<p>Linuxサーバーで<strong><span class="swl-inline-color has-swl-deep-01-color">ユーザーを変更する時のオプション</span></strong>をまとめます。</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>usermodコマンドのオプション</th><th>効果</th></tr></thead><tbody><tr><td>-l ユーザー名</td><td>ユーザー名を変更する</td></tr><tr><td>-d ホームディレクトリのパス</td><td>ホームディレクトリのパス変更</td></tr><tr><td>-m</td><td>ホームディレクトリを変更する時に中身も移動させる</td></tr><tr><td>-g グループID</td><td>1次グループIDの変更</td></tr><tr><td>-G グループID</td><td>2次グループIDの変更</td></tr><tr><td>-s シェルのパス</td><td>ログインシェルの変更</td></tr></tbody></table><figcaption class="wp-element-caption">ユーザー変更コマンドのオプション一覧</figcaption></figure>



<h2 class="wp-block-heading">ユーザー名を変更する</h2>


<div class="wp-block-image is-style-photo_frame">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="683" src="https://sugublog.org/wp-content/uploads/2021/11/programing_1122-6-1024x683.jpg" alt="ユーザー名変更" class="wp-image-4563" srcset="https://sugublog.org/wp-content/uploads/2021/11/programing_1122-6-1024x683.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/11/programing_1122-6-300x200.jpg 300w, https://sugublog.org/wp-content/uploads/2021/11/programing_1122-6-768x512.jpg 768w, https://sugublog.org/wp-content/uploads/2021/11/programing_1122-6.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p><span class="swl-marker mark_orange">Linuxで<strong><span class="swl-inline-color has-swl-deep-01-color">ユーザー名を変更</span></strong>するにはlオプション</span>を使用します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>usermod -l 新ログイン名 変更したいユーザー名</code></pre></div>



<p>まずは「userchange」というユーザーを作成してみます。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>useradd userchange</code></pre></div>



<p class="is-style-icon_pen">ユーザーを作成する「useradd」コマンドについては、以下の記事で詳しく説明しています。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/11/running_1128-3-300x225.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/linux-useradd/">【Linux初心者向け】ユーザー作成の方法とオプション一覧</a>
						<span class="p-blogCard__excerpt">Linuxサーバーでユーザーの作成方法をまとめます。 Linuxサーバーを運用していてroot権限で操作する事はセキュリティ上よくありません。ログインするエンジニアのユーザ&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p>ユーザーが作成されたか一覧で確認します。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/11/user1114-300x182.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/linux-user-list-display/">【Linux】ユーザー一覧をコマンドで表示し確認する方法</a>
						<span class="p-blogCard__excerpt">Linuxサーバーでユーザーを一覧表示したいと思った事はないでしょうか？ サーバー管理者でユーザー管理する事は大切な業務の一つです。 その中でLinuxサーバーでユーザ&#8230;</span>					</div>
				</div>
			</div>
		</div>


<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# cat /etc/passwd | grep userchange
userchange:x:1027:1027::/home/userchange:/bin/bash</code></pre></div>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-6-300x250.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/shellscript-grep/">【シェルスクリプト】grepで文字列を抽出する方法！正規表現も使用します</a>
						<span class="p-blogCard__excerpt">Linuxでシェルスクリプトのgrepのやり方がよくわかりません。オプションや正規表現を使用した文字列抽出を行いたいです。 そういった声が多いので今回はシェルスクリプ&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p>ユーザーが作成されています。</p>



<p>ではこの<strong><span class="swl-inline-color has-swl-deep-01-color">ユーザー名を変更</span></strong>してみます。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>usermod -l userchange-after userchange</code></pre></div>



<p>ユーザー名が変更されているか確認します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# cat /etc/passwd | grep userchange-after
userchange-after:x:1027:1027::/home/userchange:/bin/bash</code></pre></div>



<p class="has-border -border01"><span class="swl-marker mark_orange"><strong><span class="swl-inline-color has-swl-deep-01-color">ユーザー名が変更</span></strong>されています。</span></p>



<h2 class="wp-block-heading">ホームディレクトリのパス変更</h2>



<p>先程確認してユーザー名は変更されていますが、<span class="swl-marker mark_yellow">ホームディレクトリは変更されていない</span>事に気が付いたでしょうか？</p>



<p><span class="swl-marker mark_blue"><strong><span class="swl-inline-color has-swl-deep-02-color">ホームディレクトリを変更</span></strong>するにはdオプション</span>を使用します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>usermod -d /home/userchange-after userchange-after</code></pre></div>



<p>ユーザーのホームディレクトリが変更されたか確認します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# cat /etc/passwd | grep userchange-after
userchange-after:x:1027:1027::/home/userchange-after:/bin/bash</code></pre></div>



<p class="has-border -border01"><strong><span class="swl-inline-color has-swl-deep-02-color">ホームディレクトリが変更</span></strong>されています。</p>



<h2 class="wp-block-heading">ホームディレクトリを変更する時に中身も移動させる</h2>


<div class="wp-block-image is-style-photo_frame">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="640" src="https://sugublog.org/wp-content/uploads/2021/11/running_1128-6-1024x640.png" alt="移動" class="wp-image-4643" srcset="https://sugublog.org/wp-content/uploads/2021/11/running_1128-6-1024x640.png 1024w, https://sugublog.org/wp-content/uploads/2021/11/running_1128-6-300x188.png 300w, https://sugublog.org/wp-content/uploads/2021/11/running_1128-6-768x480.png 768w, https://sugublog.org/wp-content/uploads/2021/11/running_1128-6.png 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>先程ユーザーのホームディレクトリを変更しました。</p>



<p>実際のホームディレクトリの中身を確認してみましょう！「userchange」という名前がつくディレクトリがあるか確認しています。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# ls /home/ | grep userchange
userchange</code></pre></div>



<p class="is-style-icon_bad">「userchange-after」というディレクトリがありません。</p>



<p class="is-style-big_icon_caution">ホームディレクトリを指定しただけでは、以前のホームディレクトリを引き継ぐ事はできません。</p>



<p>そんな時はdオプションと共にmオプションをつけましょう！</p>



<p>そうする事で<strong><span class="swl-inline-color has-swl-deep-03-color">ホームディレクトリも移動</span></strong>できます。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>usermod -d /home/userchange-after -m userchange-after</code></pre></div>



<p>ホームディレクトリも移動しているか確認します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# ls /home/ | grep userchange-after
userchange-after</code></pre></div>



<p class="has-border -border01"><strong><span class="swl-inline-color has-swl-deep-03-color">ホームディレクトリも移動</span></strong>されています。</p>



<h2 class="wp-block-heading">グループIDの変更</h2>



<p><strong><span class="swl-inline-color has-swl-deep-04-color">グループIDを変更</span></strong>できます。グループIDを確認します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# cat /etc/passwd | grep userchange-after
userchange-after:x:1027:1027::/home/userchange-after:/bin/bash</code></pre></div>



<p>グループIDが確認できました。1027になっています。</p>



<p><span class="swl-bg-color has-swl-deep-04-background-color">グループIDを１００に変更</span>してみます。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>usermod -g 100 userchange-after</code></pre></div>



<p>確認します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# cat /etc/passwd | grep userchange-after
userchange-after:x:1027:100::/home/userchange-after:/bin/bash</code></pre></div>



<p class="has-border -border01"><strong><span class="swl-inline-color has-swl-deep-04-color">グループIDが１００に変更</span></strong>されています。</p>



<p class="is-style-icon_info">その他にもオプションは沢山ありますが、ほとんどがパスワードを変更する為の「passwd」コマンドでも可能です。</p>



<p class="is-style-icon_pen">「passwd」コマンドの方が一般的なので、割愛します。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/08/DB0804-1-1-300x188.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/linux-password-change/">【Linux初心者向け】ユーザーのパスワードを変更する方法</a>
						<span class="p-blogCard__excerpt">Linuxのユーザー管理でパスワードを変更する方法をお伝えします。 パスワードを変更した後の確認や、強制的に削除したりするオプションも実例を用いて解説します。 pass&#8230;</span>					</div>
				</div>
			</div>
		</div>


<h2 class="wp-block-heading">Linuxサーバーでユーザー管理に関するその他の記事について</h2>



<p>ユーザーを一覧表示して確認する方法について</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/11/user1114-300x182.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/linux-user-list-display/">【Linux】ユーザー一覧をコマンドで表示し確認する方法</a>
						<span class="p-blogCard__excerpt">Linuxサーバーでユーザーを一覧表示したいと思った事はないでしょうか？ サーバー管理者でユーザー管理する事は大切な業務の一つです。 その中でLinuxサーバーでユーザ&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p>ユーザー作成する方法について</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/11/running_1128-3-300x225.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/linux-useradd/">【Linux初心者向け】ユーザー作成の方法とオプション一覧</a>
						<span class="p-blogCard__excerpt">Linuxサーバーでユーザーの作成方法をまとめます。 Linuxサーバーを運用していてroot権限で操作する事はセキュリティ上よくありません。ログインするエンジニアのユーザ&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p>ユーザー削除する方法について</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/12/結婚1209-1-300x199.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/linux-userdel-command/">【Linux基礎】ユーザーを削除するコマンド！ホームディレクトリも完全に削除します</a>
						<span class="p-blogCard__excerpt">Linuxでユーザーを削除する時のコマンドを教えます。 Linuxでユーザーを削除する時に、ホームディレクトリが残って完全に削除できない事はないでしょうか？ そういった&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p>ユーザー名変更する方法について</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/09/jump0907-4-300x225.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/linux-usermod-username-change/">【Linux基礎】ユーザー名などを変更する方法！usermodコマンドを使用</a>
						<span class="p-blogCard__excerpt">Linuxサーバーでユーザ―名など情報を変更したい場合はないでしょうか？ ユーザーを削除して再作成などしてないでしょうか？ という事で今回はLinuxサーバーで、ユーザー&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p>ユーザーのパスワード管理について</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/08/DB0804-1-1-300x188.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/linux-password-change/">【Linux初心者向け】ユーザーのパスワードを変更する方法</a>
						<span class="p-blogCard__excerpt">Linuxのユーザー管理でパスワードを変更する方法をお伝えします。 パスワードを変更した後の確認や、強制的に削除したりするオプションも実例を用いて解説します。 pass&#8230;</span>					</div>
				</div>
			</div>
		</div>


<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9330904718533231"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-format="autorelaxed"
     data-ad-client="ca-pub-9330904718533231"
     data-ad-slot="8455594968"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<h2 class="wp-block-heading">まとめ：Linuxでユーザー名を変更するコマンドについて</h2>


<div class="wp-block-image is-style-photo_frame">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="683" src="https://sugublog.org/wp-content/uploads/2021/11/programing_1122-1-1024x683.jpg" alt="ユーザー名変更" class="wp-image-4558" srcset="https://sugublog.org/wp-content/uploads/2021/11/programing_1122-1-1024x683.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/11/programing_1122-1-300x200.jpg 300w, https://sugublog.org/wp-content/uploads/2021/11/programing_1122-1-768x512.jpg 768w, https://sugublog.org/wp-content/uploads/2021/11/programing_1122-1.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>Linuxサーバーで<strong><span class="swl-inline-color has-swl-deep-01-color">ユーザーを変更するコマンド</span></strong>の基礎構文は以下でした。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>usermod オプション ユーザー名</code></pre></div>



<p><strong><span class="swl-inline-color has-swl-deep-01-color">ユーザーを変更する時のオプション</span></strong>をまとめます。</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>usermodコマンドのオプション</th><th>効果</th></tr></thead><tbody><tr><td>-l ユーザー名</td><td>ユーザー名を変更する</td></tr><tr><td>-d ホームディレクトリのパス</td><td>ホームディレクトリのパス変更</td></tr><tr><td>-m</td><td>ホームディレクトリを変更する時に中身も移動させる</td></tr><tr><td>-g グループID</td><td>1次グループIDの変更</td></tr><tr><td>-G グループID</td><td>2次グループIDの変更</td></tr><tr><td>-s シェルのパス</td><td>ログインシェルの変更</td></tr></tbody></table><figcaption class="wp-element-caption">ユーザー変更コマンドのオプション一覧</figcaption></figure>



<p>ユーザー名を変更しただけでは、ホームディレクトリもホームディレクトリの中身も変更前のままです。</p>



<p>どちらも変更するにはdオプションとmオプションを使用します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>usermod -l 新ユーザー名 -d 新ディレクトリのパス -m 既存のユーザー名</code></pre></div>



<p>これでユーザー名とディレクトリのパスと中身を変更できます。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sugublog.org/linux-usermod-username-change/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
