I want to know if can safely shutdown my computer at home, by testing to see if my flatmate is using it. Therefore i use the command "w" in terminal. However the Idle time for tty seems strange (note I don't know much about linux or what tty means).

For example, a test of "w" command on my work machine shows that the idle time of my session is 14days? But i am using it now... this is something I don't understand.

3 Answers
3

The idle time is supposed to tell how long it has been since the user typed any input on that terminal. For Xwindows sessions, it is broken since Xwindows never reads input from a terminal, but instead gathers input directly from your mouse and keyboard, so the terminal never gets its timestamp updated since it is never read from.

There are at least 2 helpful hints in your "w" output which indicate that the entry you quote is referring to you logged in directly to the display which is physically connected to your Linux machine at home.

First, under the "TTY" column, you have "tty7". On a Linux machine, "gdm" or "gnome" or X-Windows in general will be running on tty7. When you are physically located at home, touching the keyboard physically connected to your machine, and you cycle through ctrl-alt-f1 up through ctrl-alt-f7, you are correspondingly cycling through tty1 through tty7, and when you get to tty7, you'll see X-Windows/gnome running.

Second, under the "FROM" column, you have ":0". When you see that, that always indicates the X-Windows running on the display which is physically connected to the machine.

The third clue is "gnome-session" under "WHAT", which in all probability would not be running on any display other than the one physically connected to your home machine.

So, 14 days ago you sat down at your machine at home and started an X-Windows/gnome session, and that's what you're seeing in the "w" output.

We also can deduce that you did not list the full output of "w", because you did not include the line of output which indicates that you're logged in to your home machine from work, which might list, for example, a "TTY" of "pts/0", a "FROM" of the IP address or name of your work machine, and "-bash" or "-tcsh" or some shell under "WHAT".