Last update: 2018/07/22 02:04 
Linux STARTUP for Users / Capter 2 (who)

Section Next | Prev


2.6.2 ログインユーザの表示 - who, w

who コマンド

【機能説明】
コマンド who は、現在ログインしているユーザのログイン名、 使用端末名、ログイン時刻を表示します。
また w コマンドは各ユーザが起動しているプログラム名も表示します。

【入力フォーマット】
who [am i][-Hu]

【主なオプション】
am i
自分自身のログインユーザ名を表示します。
-u
回線利用状況(端末入出力がない状態が続いた時間)、PID を表示。
-H
各項目の名称を表示します。(ヘッダ表示)

【実行例】
  1. 現在のログインユーザ一覧表示
    左より、ユーザ名、使用端末名、ログイン日時、リモートホスト
    	[student@h006 ~]$ who
    	student  :0           2018-07-22 09:30 (:0)
    	student  pts/0        2018-07-22 09:31 (192.168.10.39)
    	student  pts/1        2018-07-22 09:32 (:0)
    
  2. 自分自身(コマンドを投入している端末)のログイン名を表示
    	[student@h006 ~]$ who am i
    	student  pts/0        2018-07-22 09:31 (192.168.10.39)
    	[student@h006 ~]$ who are you
    	student  pts/0        2018-07-22 09:31 (192.168.10.39)
    	# 余談ですが、引数が2つあれば何でも who am i 動作になります。
    
  3. ヘッダと、さらに詳しい情報を表示
    左より、ユーザ名、端末名、ログイン日時、回線アイドル時間、 ログインプロセスの PID
    	[student@h006 ~]$ who -Hu
    	名前	端末	時間		IDLE	PID	コメント
    	student  :0	2018-07-22 09:30   ?	1679	(:0)
    	student  pts/0	2018-07-22 09:31  昔	2818	(192.168.10.39)
    	student  pts/1	2018-07-22 09:32  昔	3093	(:0)
    


w コマンド

【機能説明】
コマンド w は各ユーザが起動しているプログラム名も表示します。

【入力フォーマット】
w [-shf] [ユーザ名]

【主なオプション】
-s
表示する内容を省略する。
-h
ヘッダ、システム負荷を表示しない
-f
リモートホスト名(From欄)を表示しない

【実行例】
  1. ユーザ名、システム負荷、実行コマンド等をまとめて表示
    w コマンドはシステムの稼働状況の概略を知る場合に有効。
    出力の1行目は uptime と同じで、CPUの負荷を表す。
    	[student@h006 ~]$ w
    	 11:02:40 up  1:33,  4 users,  load average: 0.00, 0.03, 0.05
    	USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
    	student  :0       :0               09:30   ?xdm?   2:18   0.19s /usr/libexec/gn
    	student  pts/0    192.168.10.39    09:31    0.00s  0.49s  0.01s w
    	student  pts/1    :0               09:32   48.00s  0.05s  0.05s bash
    	root     tty2                      11:02    8.00s  0.03s  0.03s -bash
    
  2. ヘッダ情報、FROM欄、ログイン時刻、CPU時間の非表示
    	[student@h006 ~]$ w -shf
    	student  :0        ?xdm?  /usr/libexec/gnome-session-binary --session gnome-c
    	student  pts/0      4.00s w -shf
    	student  pts/1     52.00s bash
    	root     tty2      12.00s -bash
    
  3. 特定のユーザ情報を出力
    	[student@h006 ~]$ w root
    	 11:02:46 up  1:33,  4 users,  load average: 0.00, 0.03, 0.05
    	USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
    	root     tty2                      11:02   14.00s  0.03s  0.03s -bash
    

Section Next | Prev

Copyright 2007-2018 ycosSystems Monitor/Body262.html