3

I know the general idea of console, tty as here explains https://unix.stackexchange.com/questions/4126/what-is-the-exact-difference-between-a-terminal-a-shell-a-tty-and-a-con

But when run who (using iTerm2) I got these and I don't understand the difference here. BTW, I open 2 tabs in iTerms

ws ➤ who                                                                                                              
qiulang  console  Dec  5 17:47
qiulang  ttys002  Dec  5 17:48
qiulang  ttys004  Dec  6 10:41
1

The console is your physical computer and the various tty are virtual terminals.

Each tab or window of a terminal emulator like iTerm2.app or Terminal.app will connect to a different tty. MacOS works the same as this quote from one of the answers on your linked question:

So when you look to a "text window" on your linux system (under X11) you are looking to: a terminal emulator, connected to a virtual terminal, identified by a tty file, inside which runs a shell.

It is more clear what is happening if you run who with who -a (to show all details) and if you also use the tty command (which returns the current terminal).


An example

Here I rebooted at 13:20, left it on the FileVault password entry screen until 13:25 then opened a Terminal.app session at 13:29.

Last login: Fri Dec  6 13:25:54 on console
A1398% tty
/dev/ttys000
A1398% 

You can see the last logon was 13:25:54 on console (when FileVault unlocked startup disk) and Terminal.app is running on /dev/ttys000.

Next at 13:30 opened a iTerm2.app session:

Last login: Fri Dec  6 13:29:06 on ttys000
A1398% tty
/dev/ttys001
A1398% who -a
reboot   ~        Dec  6 13:25   .           1
hali     console  Dec  6 13:25 00:04        97
hali     ttys000  Dec  6 13:29 00:01       577
hali     ttys001  Dec  6 13:30   .         600
   .       run-level 3
A1398% 

You can see the last logon is shown to be 13:29:06 on ttys000 (when Terminal.app was opened) and iTerm2.app connected at 13:30 to /dev/ttys001.

who -a shows

  • console connecting at 13:25 (when password was entered and FileVault unlocked startup disk).
  • ttys000 connecting at 13:29 (when Terminal.app was opened).
  • ttys001 connecting at 13:30 (when this session of iTerm2 was opened).

If you boot into single user mode and type tty you will see the result /dev/console (who is not available)

You must log in to answer this question.

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