5

I'm trying to get to grips with UNIX.

If I open up a Terminal in Mac OS X and run w, I see

USER       TTY
myusername console
myusername s001

(I don't know if "session" is the right term)

  • I assume that s001 is my Terminal session. Does console represent the entire Mac OS X GUI's session?

  • The GUI session is obviously fancier and more complex, but is it a peer to the Terminal session conceptually?

  • What are the GUI session's stdin / stdout / stderr hooked up to?

1

2 Answers 2

3

Someone with more knowledge about this can feel free to correct me here!

  • s001 is your TTY. It's the terminal you're connected to the machine via.

  • The GUI is, as you said, a means of logging on to the server, and therefore it shows as console. It does have stdin, stdout, and stderr

  • stdin is typically NULL. stdout and stderr go to the console log, in /Library/Logs/Console/*your_uid*/console.log

3
  • So does console "own" ttys001 or are they peers as far as the UNIXy core is concerned?
    – xyz
    Nov 5, 2009 at 13:02
  • 1
    @f100: No. console and ttys001 are both device names, listed in /dev. The first line in the w output is indicating that there's a login session with /dev/console as its "controlling terminal". The second line indicates there's a login session with /dev/ttys001 as its controlling terminal. tty devices are normally opened in order, starting at ttys000. If you close all open terminals and open a new one, it will usually get ttys000, since it's free again.
    – Chris Page
    Aug 21, 2011 at 9:56
  • @f100: i.e., "no, console doesn't own ttys001". I suppose the answer to the second part of your question is "yes," insofar as they are both "merely" terminal devices connected to login sessions. However, the login session that has console as its controlling terminal is special in that that login session is created when you login at the Mac OS X login window.
    – Chris Page
    Aug 21, 2011 at 10:23
2

The "console" does indeed refer to the primary session of an OS X machine. It doesn't need to be graphical. Try entering >console as your username at the login window some time.

3
  • So does "console" mean the first session? Or is it a special session reserved for the keyboard/screen that are physically attached to the computer? In UNIX in general, must there always be a "console" session open?
    – xyz
    Nov 5, 2009 at 12:58
  • 2
    In OSX it's the physical terminal. I believe it's the same in some other UNIXes such as Solaris, but not so in linux. There you are allocated tty# depending on which of the physical terminals you log in to.
    – Kamil Kisiel
    Nov 5, 2009 at 16:06
  • 1
    console is the name of the /dev/console device. The first line of w output is indicating that there's a login session with /dev/console as its controlling terminal. According to sudo lsof /dev/console, launchd has it open. I was under the impression that writing to /dev/console just wrote to the console log file, but I haven't been able to verify it produces changes in any logs I examined.
    – Chris Page
    Aug 21, 2011 at 10:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .