Hello everyone,
Yesterday, I came across a very useful command that I thought
it's very helpful/useful to share with everybody if you don't know it already.
The command is called "w". Yes, just w.
w shows who is logged on the server or machine and what they are doing. Referring to Figure 1, I
just ran w command and it shows me that currently two persons logged in to
server. Under USER column, the second user is me "ktaraghi" that ran
w command and you can see it under WHAT column.
Let me explain in more details:
The first row, as you see in Figure 1, shows useful information
about machine, users and processes. So, the first item in the first row shows
the current time and the second item shows how long the system has been
running. The third item shows how many users are currently logged on and the
last item shows the system load averages for the past 1, 5, and 15 minutes.
The second row, shows column headers which are (from left to
right): Usernames currently logged in, the tty name or terminal name, the login
time, idle time, JCPU and PCPU. According to man page, the JCPU time is the
time used by all processes attached to the tty and it doesn't include past
background jobs, but does include currently running background jobs.
The PCPU time is the time used by the current process, named in
the "WHAT" column.
There are some switches that is used with this command.
w -h :Don't print the headers
Figure 2
w -s :Short format. Don't print the login name, JCPU, and PCPU.
Figure 3
w -f :Adds another column "FROM" which shows remote
hostname or IP
Figure 4
and finally, -V which shows the version of w command.
Hopefully you enjoyed,
Regards,
Khosro Taraghi