{"id":13266,"date":"2022-01-03T15:09:48","date_gmt":"2022-01-03T15:09:48","guid":{"rendered":"https:\/\/linuxways.net\/?p=13266"},"modified":"2022-01-03T15:09:48","modified_gmt":"2022-01-03T15:09:48","slug":"w-command-explained-with-examples-in-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/w-command-explained-with-examples-in-linux\/","title":{"rendered":"w Command Explained with Examples in Linux"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>w command is used by the system admin to observe the user logged on to the system and the activities carried out by them. It is the tool used to see the username, logged-in information, and the activities carried out by the logged-in users. This w command tool is automatically installed in the Linux system by default. w command is very much similar to <strong>who commands<\/strong>, but with a lot of information about the logged-on users.<\/p>\n<p>In this article, I am going to show you the practical uses of w command.<\/p>\n<h2>The Syntax of w command<\/h2>\n<pre><strong>w[option][username]<\/strong><\/pre>\n<p>Here,the terms option and username are explained below:<\/p>\n<p><strong>[options]<\/strong>: option you want to use to know about the user or print the output<\/p>\n<p><strong>[username]<\/strong>: providing the name of the user to know the specific information<\/p>\n<p>The following figure shows the use of<strong> w command <\/strong>without any option provided:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"830\" height=\"92\" class=\"wp-image-13267\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-449.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-449.png 830w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-449-300x33.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-449-768x85.png 768w\" sizes=\"auto, (max-width: 830px) 100vw, 830px\" \/><\/p>\n<p>You can see the options of w command, using help menu as below:<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"667\" height=\"302\" class=\"wp-image-13268\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-450.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-450.png 667w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-450-300x136.png 300w\" sizes=\"auto, (max-width: 667px) 100vw, 667px\" \/><\/strong><\/p>\n<h2>Explanation of w command in Linux terminal<\/h2>\n<p>The w commands used in the Linux are about to be mentioned below with an example.<\/p>\n<p>Before starting with the example here are some information you should learn before using the w command. Here are the topic explained about the output displayed in the w command.<\/p>\n<p><strong>USER:<\/strong> USER shows the information of the logged in user.<\/p>\n<p><strong>TTY:<\/strong> TTY shows the terminal used by the logged in user.<\/p>\n<p><strong>FROM:<\/strong> FROM shows the IP address of the logged in user.<\/p>\n<p><strong>LOGIN@:<\/strong> LOGIN@ shows the time when the user is logged in.<\/p>\n<p><strong>IDLE:<\/strong> IDLE shows the last time when the logged in user interacted with the terminal.<\/p>\n<p><strong>JCPU:<\/strong> JCPU shows the time taken by the processes with the attachment to the tty.<\/p>\n<p><strong>PCPU:<\/strong> PCPU shows the time taken by the current process .<\/p>\n<p><strong>WHAT: <\/strong>WHAT shows the user&#8217;s current process and the options.<\/p>\n<h2>1. w command without the header<\/h2>\n<p>To display the output without a header containing system details and field labels, use the -h options.<\/p>\n<pre><strong>Sam@linuxways :~$ w -h<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"1031\" height=\"73\" class=\"wp-image-13269\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-451.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-451.png 1031w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-451-300x21.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-451-1024x73.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-451-768x54.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-451-1020x73.png 1020w\" sizes=\"auto, (max-width: 1031px) 100vw, 1031px\" \/><\/strong><\/p>\n<h2>2. w command to ignore name<\/h2>\n<p>When calculating the current process and CPU times, the -u option allows the w command to ignore usernames.<\/p>\n<pre><strong>Sam@linuxways :~$ w -u<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"973\" height=\"131\" class=\"wp-image-13270\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-452.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-452.png 973w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-452-300x40.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-452-768x103.png 768w\" sizes=\"auto, (max-width: 973px) 100vw, 973px\" \/><\/strong><\/p>\n<h2>3. w command to display the short format<\/h2>\n<p>w command can be used with the -s option to display short output format which only displays the USER, TTY, FROM, IDLE, and WHAT fields.<\/p>\n<pre><strong>Sam@linuxways :~$ w -s<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"845\" height=\"95\" class=\"wp-image-13271\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-453.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-453.png 845w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-453-300x34.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-453-768x86.png 768w\" sizes=\"auto, (max-width: 845px) 100vw, 845px\" \/><\/strong><\/p>\n<p>&nbsp;<\/p>\n<h2><a id=\"post-13266-_6dx12f2w7v88\"><\/a>4. w command to show\/hide remote hostname field<\/h2>\n<p>Depending upon the system default output the -f shows the <strong>FROM <\/strong>output or hides the <strong>FROM <\/strong>output.Here in the Ubuntu linux system the <strong>FROM<\/strong> is shown so,to hide the output -f is used.<\/p>\n<p><strong>Sam@linuxways :~$ w -f<\/strong><\/p>\n<p>The Ubuntu linux system shows the <strong>FROM <\/strong>output by default.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"830\" height=\"92\" class=\"wp-image-13272\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-454.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-454.png 830w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-454-300x33.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-454-768x85.png 768w\" sizes=\"auto, (max-width: 830px) 100vw, 830px\" \/><\/p>\n<p>Here, the output <strong>FROM<\/strong> is hidden using the options -f.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"683\" height=\"95\" class=\"wp-image-13273\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-455.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-455.png 683w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-455-300x42.png 300w\" sizes=\"auto, (max-width: 683px) 100vw, 683px\" \/><\/strong><\/p>\n<h2><a id=\"post-13266-_93hiboqj6t3\"><\/a>5. w command to print blank space for idle time<\/h2>\n<p>The -o prints the blank space for the idle time less than one minute.<\/p>\n<p><strong>Sam@linuxways :~$ w -o<\/strong><\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"828\" height=\"92\" class=\"wp-image-13274\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-456.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-456.png 828w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-456-300x33.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-456-768x85.png 768w\" sizes=\"auto, (max-width: 828px) 100vw, 828px\" \/><\/strong><\/p>\n<h2><a id=\"post-13266-_jivd29eoulp6\"><\/a>6. w command to display host name<\/h2>\n<p>The <strong>FROM<\/strong> shows the name of the host or the terminal name by default .Using -i option switches over to the IP address of the user if possible.<\/p>\n<p><strong>Sam@linuxways :~$ w -i<\/strong><\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"830\" height=\"98\" class=\"wp-image-13275\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-457.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-457.png 830w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-457-300x35.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/12\/word-image-457-768x91.png 768w\" sizes=\"auto, (max-width: 830px) 100vw, 830px\" \/><\/strong><\/p>\n<h1>Conclusion<\/h1>\n<p>The above given command and its example is for a better understanding of the w command. Thank you for checking it out!<\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction w command is used by the system admin to observe the user logged on to the system and the activities carried out by them. It is the&hellip;<\/p>","protected":false},"author":1,"featured_media":13546,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,4,5,83,165,2],"tags":[35,798],"class_list":["post-13266","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-debian","category-mint","category-opensuse","category-red-hat","category-ubuntu","tag-linux","tag-w-command"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/13266","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=13266"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/13266\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/13546"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=13266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=13266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=13266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}