Are the Mac OS X GUI and a Terminal session peers?

5,961

Solution 1

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

Solution 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.

Share:
5,961

Related videos on Youtube

xyz
Author by

xyz

Updated on September 17, 2022

Comments

  • xyz
    xyz over 1 year

    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?

  • xyz
    xyz over 14 years
    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
    xyz over 14 years
    So does console "own" ttys001 or are they peers as far as the UNIXy core is concerned?
  • macsit
    macsit over 14 years
    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.
  • Chris Page
    Chris Page over 12 years
    @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
    Chris Page over 12 years
    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
    Chris Page over 12 years
    @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.