<?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/feed/" rel="self" type="application/rss+xml" />
	<link>https://sugublog.org</link>
	<description>ブログ運営について発信中</description>
	<lastBuildDate>Sun, 02 Jun 2024 08:04:26 +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】ユーザー一覧をコマンドで表示し確認する方法</title>
		<link>https://sugublog.org/linux-user-list-display/</link>
					<comments>https://sugublog.org/linux-user-list-display/?noamp=mobile#respond</comments>
		
		<dc:creator><![CDATA[suguru]]></dc:creator>
		<pubDate>Tue, 14 May 2024 15:00:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[サーバ]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ユーザー]]></category>
		<guid isPermaLink="false">https://sugublog.org/?p=6779</guid>

					<description><![CDATA[<p><img src="https://sugublog.org/wp-content/uploads/2021/11/user1114-1024x620.jpg" class="webfeedsFeaturedVisual" /></p>Linuxサーバーでユーザーを一覧表示したいと思った事はないでしょうか？ サーバー管理者でユーザー管理する事は大切な業務の一つです。 その中でLinuxサーバーでユーザー一覧を表示して確認するにはコマンドを使用するのが一 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://sugublog.org/wp-content/uploads/2021/11/user1114-1024x620.jpg" class="webfeedsFeaturedVisual" /></p>
<p><strong>Linuxサーバー</strong>で<strong><span class="swl-inline-color has-swl-deep-01-color">ユーザーを一覧表示</span></strong>したいと思った事はないでしょうか？</p>



<p>サーバー管理者でユーザー管理する事は大切な業務の一つです。</p>



<p>その中でLinuxサーバーでユーザー一覧を表示して確認するにはコマンドを使用するのが一番です。</p>



<p><span class="swl-marker mark_orange"><strong>Linuxサーバー</strong>で<strong><span class="swl-inline-color has-swl-deep-01-color">ユーザー一覧をコマンドで表示するやり方</span></strong>を、現役エンジニアの筆者が教えます。</span></p>


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


<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="512" src="https://sugublog.org/wp-content/uploads/2021/11/access1114-1024x512.jpg" alt="user" class="wp-image-4500" srcset="https://sugublog.org/wp-content/uploads/2021/11/access1114-1024x512.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/11/access1114-300x150.jpg 300w, https://sugublog.org/wp-content/uploads/2021/11/access1114-768x384.jpg 768w, https://sugublog.org/wp-content/uploads/2021/11/access1114.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p><strong>Linuxサーバー</strong>で<strong>ユーザーを作成</strong>すると<strong><span class="swl-inline-color has-swl-deep-01-color">「etc/passwd」のファイル</span></strong>に追記されます。このファイルを参照する事でユーザー一覧を表示し、確認する事が可能です。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
ftp-user:x:1000:1000::/home/ftp-user:/bin/bash
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
mailman:x:41:41:GNU Mailing List Manager:/usr/lib/mailman:/sbin/nologin
ftpuser:x:1001:1001::/home/ftpuser:/bin/bash
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
rdpuser:x:1002:1002::/home/rdpuser:/bin/bash
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
colord:x:998:995:User for colord:/var/lib/colord:/sbin/nologin
geoclue:x:997:994:User for geoclue:/var/lib/geoclue:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/false
testuser1:x:1003:1003::/home/testuser1:/bin/bash
testuser2:x:1004:1004::/home/testuser2:/bin/bash</code></pre></div>



<p>ファイルの中身は「:」で区切られています。それぞれの意味は以下にまとめます。</p>



<p class="has-border -border02">ユーザー名:パスワード:ユーザーID:グループID:コメント:ホームディレクトリ:シェルの場所</p>



<h3 class="wp-block-heading">ユーザー名一覧のみを抽出する方法</h3>



<p><strong><span class="swl-inline-color has-swl-deep-01-color">ユーザー名一覧のみ</span></strong>を提出したい場合もあるかと思います。ユーザー名は1項目目にあるのでそこだけを抽出すれば効率化できます。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>cut -d 区切り文字 -f 項目番号 /etc/passwd</code></pre></div>



<p>cutコマンドを使用します。dオプションは区切り文字を指定します。fオプションは項目番号を指定します。</p>



<p class="is-style-icon_info">※区切り文字は１文字のみです。</p>



<p>今回は区切り文字は「:」で１項目目のユーザー名一覧が欲しいので１を指定します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>cut -d : -f 1 /etc/passwd</code></pre></div>



<p>Linuxのcutコマンドを実行します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# cut -d : -f 1 /etc/passwd
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
operator
games
ftp
nobody
systemd-network
dbus
polkitd
sshd
postfix
ftp-user
apache
mailman
ftpuser
tss
rdpuser
rtkit
colord
geoclue
pulse
gdm
mysql
testuser1
testuser2</code></pre></div>



<p class="has-border -border01">１項目目の<strong><span class="swl-inline-color has-swl-deep-01-color">ユーザー名一覧</span></strong>が表示されました。</p>



<h3 class="wp-block-heading">特定のユーザーのみ表示する方法</h3>



<p><strong><span class="swl-inline-color has-swl-deep-01-color">特定のユーザーのみを表示</span></strong>する場合はgrepで検索します。</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/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>


<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>cat /etc/passwd | grep 表示したいユーザー名</code></pre></div>



<p>ユーザー一覧表示させて、パイプでつなぎ、grepコマンドで抽出します。</p>



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



<p class="has-border -border01"><strong><span class="swl-inline-color has-swl-deep-01-color">指定したユーザーのみ</span></strong>表示されています。</p>



<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>



<h3 class="wp-block-heading">現在ログインしているユーザーを表示する方法</h3>



<p><strong><span class="swl-inline-color has-swl-deep-01-color">現在ログインしているユーザー</span></strong>を確認するコマンドは２つあります。</p>



<div class="swell-block-capbox cap_box is-style-onborder_ttl"><div class="cap_box_ttl"><span>現在ログインしているユーザーを確認するコマンド２選</span></div><div class="cap_box_content">
<ul class="wp-block-list">
<li>whoコマンド</li>



<li>usersコマンド</li>
</ul>
</div></div>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# who
root     pts/0        2024-05-12 15:26 (192.168.0.11)
testuser1 pts/1        2024-05-12 16:23 (192.168.0.11)</code></pre></div>



<p><span class="swl-marker mark_blue">whoコマンドでは<strong><span class="swl-inline-color has-swl-deep-02-color">現在ログインしているユーザー</span></strong>と<span class="swl-inline-color has-swl-deep-02-color">ログインした日時</span>や<span class="swl-inline-color has-swl-deep-02-color">IPアドレス</span>などが表示されています。</span></p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>[root@localhost ~]# users
root testuser1</code></pre></div>



<p><span class="swl-marker mark_green">usersコマンドでは<span class="swl-inline-color has-swl-deep-03-color"><strong>ログインしているユーザー名のみ</strong></span>が表示されています。</span></p>



<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/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>]]></content:encoded>
					
					<wfw:commentRss>https://sugublog.org/linux-user-list-display/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
