{"id":13189,"date":"2019-04-01T07:09:25","date_gmt":"2019-04-01T07:09:25","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13189"},"modified":"2019-04-01T07:09:25","modified_gmt":"2019-04-01T07:09:25","slug":"10-who-command-examples-for-linux-newbies","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/01\/10-who-command-examples-for-linux-newbies\/","title":{"rendered":"10 \u2018who\u2019 Command Examples for Linux Newbies"},"content":{"rendered":"<p>One of the various commands we mentioned was the\u00a0<strong>who command<\/strong>\u00a0which displays users who are currently logged on to a Linux system, including the terminals they are connecting from.<\/p>\n<p>This article will explain some useful examples of who command for Linux newbies.<\/p>\n<p>The basic syntax for using\u00a0<strong>who command<\/strong>\u00a0is as follows.<\/p>\n<pre>$ who who [OPTION]... [ FILE | ARG1 ARG2 ]\r\n<\/pre>\n<p><strong>1.<\/strong>\u00a0If you run\u00a0<strong>who<\/strong>\u00a0command without any arguments, it will display account information (user login name, user\u2019s terminal, time of login as well as the host the user is logged in from) on your system similar to the one shown in the following output.<\/p>\n<pre><strong>$ who<\/strong>\r\n\r\nravi\t\ttty1\t        2018-03-16\t19:27\r\ntecmint\t        pts\/0\t\t2018-03-16\t19:26\t(192.168.56.1)\r\nroot\t\tpts\/1\t\t2018-03-16\t19:27\t(192.168.56.1)\r\n<\/pre>\n<p><strong>2.<\/strong>\u00a0To print the heading of the columns displayed, use the\u00a0<code>-H<\/code>\u00a0flag as shown.<\/p>\n<pre><strong>$ who -H<\/strong>\r\n\r\nNAME            LINE                   TIME             COMMENT\r\nravi\t\ttty1\t        2018-03-16   19:27\r\ntecmint\t        pts\/0\t\t2018-03-16   19:26\t(192.168.56.1)\r\nroot\t\tpts\/1\t\t2018-03-16   19:27\t(192.168.56.1) \r\n<\/pre>\n<p><strong>3.<\/strong>\u00a0To print the login names and total number of logged on users, use the\u00a0<code>-q<\/code>\u00a0flag.<\/p>\n<pre><strong>$ who -q<\/strong>\r\n\r\nravi   tecmint    root\r\n# users=3\r\n<\/pre>\n<p><strong>4.<\/strong>\u00a0In case you want to show only\u00a0<strong>hostname<\/strong>\u00a0and user associated with\u00a0<strong>stdin<\/strong>, use the\u00a0<code>-m<\/code>\u00a0switch.<\/p>\n<pre><strong>$ who -m<\/strong>\r\n\r\ntecmint\t        pts\/0\t\t2018-03-16\t19:26\t(192.168.56.1)\r\n<\/pre>\n<p><strong>5.<\/strong>\u00a0Next, to add user\u2019s message status as\u00a0<code>+<\/code>,\u00a0<code>-<\/code>\u00a0or\u00a0<code>?<\/code>, use the\u00a0<code>-T<\/code>\u00a0option.<\/p>\n<pre><strong>$ who -T<\/strong>\r\n\r\nravi\t      +  tty1\t        2018-03-16\t19:27\r\ntecmint\t      +  pts\/0\t\t2018-03-16\t19:26\t(192.168.56.1)\r\nroot\t      +  pts\/1\t\t2018-03-16\t19:27\t(192.168.56.1)\r\n<\/pre>\n<p>The who command also helps you to view some useful system information such as\u00a0<strong>last boot time<\/strong>,\u00a0<strong>current runlevel<\/strong>\u00a0(<strong>target<\/strong>\u00a0under\u00a0<strong>systemd<\/strong>), print dead processes as well as processes spawned by\u00a0<strong>init<\/strong>.<\/p>\n<p><strong>6.<\/strong>\u00a0To view the time of last system boot, use the\u00a0<code>-b<\/code>\u00a0flag and adding the\u00a0<code>-u<\/code>\u00a0option allows for listing of logged on users in the same output.<\/p>\n<pre><strong>$ who -b<\/strong>\r\n\r\nsystem boot  2018-01-19 02:39\r\n<\/pre>\n<pre><strong>$ who -bu<\/strong>\r\n\r\n                system boot  2018-03-16 19:25\r\nravi\t\ttty1\t\t2018-03-16\t\t19:27  00:33\t\t2366\r\ntecmint\t        pts\/0\t        2018-03-16\t        19:26\t .              2332     (192.168.56.1)\r\nroot\t\tpts\/1\t\t2018-03-16\t\t19:27\t00:32           2423     (192.168.56.1)\r\n<\/pre>\n<p><strong>7.<\/strong>\u00a0You can check the current runlevel with the\u00a0<code>-r<\/code>\u00a0option.<\/p>\n<pre><strong>$ who -r<\/strong>\r\n\r\nrun-level 3  2018-03-16 02:39\r\n<\/pre>\n<p><strong>8.<\/strong>\u00a0The following command will print dead processes.<\/p>\n<pre><strong>$ who -d<\/strong>\r\n\r\npts\/1        2018-03-16 11:10              9986 id=ts\/1  term=0 exit=0\r\n<\/pre>\n<p><strong>9.<\/strong>\u00a0Furthermore, to see active processes spawned by init, use the\u00a0<code>-p<\/code>\u00a0option.<\/p>\n<pre><strong>$ who -p<\/strong>\r\n<\/pre>\n<p><strong>10.<\/strong>\u00a0Last but not least, the\u00a0<code>-a<\/code>\u00a0flag allows for printing of default output combined with information from some of the options we have covered.<\/p>\n<pre><strong>$ who -a<\/strong>\r\n \r\nsystem boot  2018-06-16 02:39\r\n           run-level 3  2018-01-19 02:39\r\nLOGIN      tty1         2018-01-19 02:39              3258 id=1\r\nLOGIN      ttyS0        2018-01-19 02:39              3259 id=S0\r\ntecmnt   + pts\/0        2018-03-16 05:33   .          20678 (208.snat-111-91-115.hns.net.in)\r\n           pts\/1        2018-03-14 11:10              9986 id=ts\/1  term=0 exit=0\r\n<\/pre>\n<p>You can find more options by consulting the\u00a0<strong>who man<\/strong>\u00a0page.<\/p>\n<pre>$ man who \r\n<\/pre>\n<p>In this article, we have explained\u00a0<strong>10 who command<\/strong>\u00a0examples for Linux newbies. Use the comment section below to ask any questions or give us your feedback.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/linux-who-command-examples\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the various commands we mentioned was the\u00a0who command\u00a0which displays users who are currently logged on to a Linux system, including the terminals they are connecting from. This article will explain some useful examples of who command for Linux newbies. The basic syntax for using\u00a0who command\u00a0is as follows. $ who who [OPTION]&#8230; [ FILE &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/01\/10-who-command-examples-for-linux-newbies\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;10 \u2018who\u2019 Command Examples for Linux Newbies&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13189","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13189"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13189\/revisions"}],"predecessor-version":[{"id":13190,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13189\/revisions\/13190"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}