1

Currently, I am learning some UNIX command and encountered several unexplained questions. Thanks for your answering.

  1. When I run the command w from the terminal, I got some messages shown in the picture below. I know s000 stands for the terminal in which I typed the command w. But I am confused about the tty whose name is console and by which, it said, I logged into the system. And it said that console had been idle for some time. Can I switch to console to activate this tty to make it no longer idle?

  2. I also did another experiment trying to kick off the guest user who was logging in. I knew I can kill the bash process that the guest was running, but somehow I am having a problem killing the console the guest was running. How can I completely kick off the guest without rebooting the computer? I can not kill the console. The root of this problem is pretty much the same as the first one: what does "console" stand for? Absolutely it does not stand for the terminal in which I typed the command w.

  3. This problem can also be found on Linux system such as Ubuntu 14.04 with the latter naming the console with number such as 0 or 1. I wonder what 0 or 1 in tty column means. But I can be sure that they have similar meaning with console.

here is the image

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
Han XIAO
  • 155
  • 1
  • 5
  • How did the guest user log in? – Scott - Слава Україні Oct 01 '17 at 01:37
  • @Scott : Me,the super user, login through the graphical interface provided by Mac when it boots,not through command line,or not through distant login. The guest logins the same way I login(by login interface) : I switch the account and use the same graphical interface to login the guest, not through terminal. From G-Man's answer, the console stands for the process that maintain window interface. Is it possible for me to shut down the window interface of the guest? When I tried it on ubuntu,when I kill the user-init process for guest, it also kill the user-init process for superuser as well. – Han XIAO Oct 01 '17 at 10:11

1 Answers1

1

I’m not familiar with macOS, but I expect the concepts are pretty similar to those in Linux.  This is somewhat of an oversimplification, but basically, in this context, the “console” refers to the entire computer.  Or, to be somewhat more specific, the display and the human input devices (keyboard, pointing device(s), etc.)   (Network logins are excluded from the “console”.)

When you login to your computer (locally, not via the network), you are logging in to the console.

Now you’re obviously familiar with terminals — windows in which you can run commands, like ls and w.  When you log in to the console, it automagically runs a command (or a group of commands) that gives you the windowed interface that you’re accustomed to.  Some operating systems make the mechanism by which this happens visible, and sometimes even adjustable; others do it entirely “under the hood”.

Since the console doesn’t run any commands, except for the window system itself, it appears to be idle.  On most operating systems (and I expect that macOS is one of them), the only was to switch to the console is to exit from the window system — but that returns you to the console, which then automagically logs you out.

There’s another wrinkle:

  • The w command reads a system file, formats the data nicely for a person to look at it, and writes it to the standard output.
  • An entry gets written to the file whenever anybody logs in at the console or over the network.  Some (most? all?) systems also write an entry when the user at the console starts a new terminal window.
  • Entries normally get erased when a user logs out or closes a terminal window.
  • The key word in the above bullet is “normally”.  In some cases, if you kill a process (especially if you do it as superuser), you may interfere with the mechanism that erases the old data.  Thus, w might report information that is no longer valid.

If you don’t know how to use ps, you should learn.  You can use it instead of w, but it’s probably better to use them together.  Use w to give you a road map of what to look for in the ps output.  Don’t blindly believe everything w tells you; believe only the information that you can verify with ps.  For example, if you have killed all the “guest” processes, and w still says that “guest” is logged in, it’s probably giving you stale, invalid information.


You might find What is the difference between shell, console, and terminal? and What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'? to be worthwhile reading.

  • Thanks. Interestingly, when I tried it on Ubuntu, I guess it may work to kill the user-init process. When I killed it, I ,the super user,was forced to logout as well and returned to the graphical login interface when system boots. Then I logged in as the super user again, run the w command, and still found the "console" or number-named tty for guest is still running, which means the guest is still logged in, and the process of windowed interface for the guest is still working. It seemed that the windowed interface process for user and guest is bound together. I just want to kill that of guest. – Han XIAO Oct 01 '17 at 10:18