{"id":6161,"date":"2021-05-02T22:14:56","date_gmt":"2021-05-02T22:14:56","guid":{"rendered":"https:\/\/linuxways.net\/?p=6161"},"modified":"2021-05-02T22:14:56","modified_gmt":"2021-05-02T22:14:56","slug":"how-to-use-the-who-command-in-debian-10","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/debian\/how-to-use-the-who-command-in-debian-10\/","title":{"rendered":"How to Use the Who Command in Debian 10"},"content":{"rendered":"<p>As a system administrator working in a multi-user environment, you should know who is logged in to your system. Luckily, the Linux OS allows you to achieve this using a simple and built-in command known as \u201c<em>who\u201d<\/em>. <em>Who<\/em> command is one of the GNU Core Utilities that uses the <strong>\/var\/log\/utmp<\/strong> file to provide information about who is logged in to the system, which time they have logged in and from where they have logged in. It is similar to the \u201cw\u201d command and displays the same information along with some other information as well such as the last time when the system was booted and in which run level the system is in and a little more.<\/p>\n<p>In this article, we will explain how to use the <em>who <\/em>command in Linux OS along with some of the command-line options.<\/p>\n<p>Note: The commands discussed in this article have been tested on a Debian 10 Buster system.<\/p>\n<h2>Find who is on the system<\/h2>\n<p>When <em>who <\/em>command is used without any command line options, it displays the following information:<\/p>\n<ul>\n<li>Who is Logged in to the system<\/li>\n<li>How they have logged in (User\u2019s Terminal)<\/li>\n<li>Date and Time of login<\/li>\n<li>From where they have logged in (Hostname or IP address of the remote server)<\/li>\n<\/ul>\n<h2><img loading=\"lazy\" decoding=\"async\" width=\"674\" height=\"99\" class=\"wp-image-6162\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-400.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-400.png 674w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-400-300x44.png 300w\" sizes=\"auto, (max-width: 674px) 100vw, 674px\" \/><\/h2>\n<p>The above output shows that 3 users are logged in to our system. First user in the list is logged in directly to the system and the other two are logged in from the remote systems. It also displays the date and time when they logged in, and the IP addresses of the servers from where they are logged in.<\/p>\n<h2>Commonly used options<\/h2>\n<p>Here we will discuss some of the commonly used <em>who <\/em>command line options:<\/p>\n<h3>Display Date and time of last system boot<\/h3>\n<p>To display date and time of last system boot, use <em>who <\/em>command with the -b or &#8211;boot option like this:<\/p>\n<pre>$ who -b<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"465\" height=\"51\" class=\"wp-image-6163\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-401.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-401.png 465w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-401-300x33.png 300w\" sizes=\"auto, (max-width: 465px) 100vw, 465px\" \/><\/p>\n<h3>Display column headings in who command<\/h3>\n<p><em>Who <\/em>command without any command line option displays information in columns without any headings. It is often difficult to remember what each column is about. However, using the -h or &#8211;heading option with <em>who <\/em>command, you can display headings on the top of each column.<\/p>\n<pre>$ who \u2013H<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"660\" height=\"122\" class=\"wp-image-6164\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-402.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-402.png 660w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-402-300x55.png 300w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><\/p>\n<h3>Display user\u2019s idle time<\/h3>\n<p>Idle time is the time that has passed without any user\u2019s activity during the user\u2019s session. In order to view the idle time for each user, use <em>who <\/em>command with the -u or &#8211;users option:<\/p>\n<pre>$ who -u<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"874\" height=\"100\" class=\"wp-image-6165\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-403.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-403.png 874w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-403-300x34.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-403-768x88.png 768w\" sizes=\"auto, (max-width: 874px) 100vw, 874px\" \/><\/p>\n<p>If we see the above output, (old) in the first user\u2019s line shows the user has been inactive since the last 24 hrs, (00:11) in the second user\u2019s line shows that the second user has been inactive since the last 11 minutes. The (.) in the third user\u2019s line shows the user is currently active.<\/p>\n<h3>Display quick count and name of current users<\/h3>\n<p>If you want brief information about logged in users, use <em>who <\/em>command with the -q or &#8211;count option. It will display the name and the number of users logged in to the system.<\/p>\n<pre>$ who -q<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"343\" height=\"76\" class=\"wp-image-6166\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-404.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-404.png 343w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-404-300x66.png 300w\" sizes=\"auto, (max-width: 343px) 100vw, 343px\" \/><\/p>\n<h2>Display Login Processes<\/h2>\n<p>To display the current login processes on the system, use who command with the -l or &#8211;login option like this:<\/p>\n<pre>$ who -l<\/pre>\n<h3>Display message status<\/h3>\n<p>You can also display the messages status of the currently logged in users. Use who command with either of -T, -w or &#8211;message option:<\/p>\n<pre>$ who \u2013T<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"686\" height=\"99\" class=\"wp-image-6167\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-405.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-405.png 686w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-405-300x43.png 300w\" sizes=\"auto, (max-width: 686px) 100vw, 686px\" \/><\/p>\n<p>After each user\u2019s name, you will see the message status as \u201c<strong>+<\/strong>\u201d or \u201c<strong>&#8211;<\/strong>\u201d based on whether the messaging is turned on or off respectively. In the above output, you can see that the messaging is on for the first two users while it is off for the third user.<\/p>\n<h2>Display Dead Processes<\/h2>\n<p>You can also display the dead processes in Linux. To do so, use <em>who <\/em>command with -d or &#8211;dead option like this:<\/p>\n<pre>$ who -d<\/pre>\n<h3>Display current run level<\/h3>\n<p>Run level is a mode in Linux that the system uses for performing different functions. There are seven run levels (0-6) on the system which are categorized based on the available services.<\/p>\n<pre>$ who -r<\/pre>\n<p>To view the current run level of the system, use <em>who <\/em>command with -r option as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"518\" height=\"51\" class=\"wp-image-6168\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-406.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-406.png 518w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-406-300x30.png 300w\" sizes=\"auto, (max-width: 518px) 100vw, 518px\" \/><\/p>\n<h2>Display All Information<\/h2>\n<p>All the command line options we have discussed above provide different informations. To view all the information in a single output, use <em>who<\/em> command the -a or &#8211;all option as follows:<\/p>\n<pre>$ who -a<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"909\" height=\"149\" class=\"wp-image-6169\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-407.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-407.png 909w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-407-300x49.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-407-768x126.png 768w\" sizes=\"auto, (max-width: 909px) 100vw, 909px\" \/><\/p>\n<h3>Use multiple options with who command<\/h3>\n<p><em>Who<\/em> command can also be used with multiple command line options. Use <em>who<\/em> command followed by multiple options using a single hyphen.<\/p>\n<p>For example, to display all the information along with column headings, the command would be:<\/p>\n<pre>$ who -aH<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"909\" height=\"169\" class=\"wp-image-6170\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-408.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-408.png 909w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-408-300x56.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-408-768x143.png 768w\" sizes=\"auto, (max-width: 909px) 100vw, 909px\" \/><\/p>\n<h3>Find Help<\/h3>\n<p>Following commands can provide you some help related to <em>who <\/em>command.<\/p>\n<p>To view brief information about <em>who <\/em>command, use whatis command as follows:<\/p>\n<pre>$ whatis who<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"539\" height=\"51\" class=\"wp-image-6171\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-409.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-409.png 539w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-409-300x28.png 300w\" sizes=\"auto, (max-width: 539px) 100vw, 539px\" \/><\/p>\n<p>To view <em>who <\/em>command man page, use the following command:<\/p>\n<pre>$ man who<\/pre>\n<p>Use the &#8211;help option with <em>who <\/em>command to display help.<\/p>\n<pre>$ who \u2013help<\/pre>\n<p><strong>Tip:<\/strong><\/p>\n<p>To save the output of <em>who <\/em>command in a file for record purpose, type <em>who <\/em>followed by the redirector <strong>(&gt;)<\/strong> symbol and the filename where you want to save the output.<\/p>\n<pre>$ who &gt; file_name<\/pre>\n<p>The output of <em>who<\/em> command will be saved in the file rather than displaying on the terminal.<\/p>\n<p>In this article, we have discussed <em>who <\/em>command along with its some of the useful command line options. You have seen that <em>who <\/em>command can do a lot more than just providing the logged in user information.<\/p>","protected":false},"excerpt":{"rendered":"<p>As a system administrator working in a multi-user environment, you should know who is logged in to your system. Luckily, the Linux OS allows you to achieve this&hellip;<\/p>","protected":false},"author":1,"featured_media":6238,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[17,304],"class_list":["post-6161","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-debian","tag-debian-10","tag-who-command"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/6161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=6161"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/6161\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/6238"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=6161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=6161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=6161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}