Is it normal to have same user logged in twice but from another TTY? I don't know if this is something that is in macOS, but in Linux I normally see only one user if I run the who and w command.

Is it normal to have same user logged in twice but from another TTY?

I don't know where the second account with the same username came from.

jen-air:~ jen$ who
jen     console  Aug 22 20:56 
jen     ttys000  Aug 23 08:39 

jen-air:~ jen$ w
 8:43  up 11:47, 2 users, load averages: 1.51 1.60 1.70
USER     TTY      FROM              LOGIN@  IDLE WHAT
jen     console  -                Wed20   11:46 -
jen     s000     -                 8:39       - w
Here's a little more information about what is happening, from a lower level Unix perspective. It's long and goes beyond what you asked, but might be interesting to you or someone else passing this page.

If you look at the w command's manual (man w), it says that "The w utility prints a summary of the current activity on the system, including what each user is doing." That's a little vague, and a little misleading. Specifically what w does is to tell you about current logins. Logins are recorded in a file named /var/run/utmpx. There are common library methods for updating utmpx entries, so that every program that needs to record or remove a login uses the same procedure.

w reads the utmpx file using those common library routines and displays information about current login sessions, along with the foreground process. A login session can be doing many things at once, but only one program is in the foreground. All others are background, which is what happens when you put an &amp; on your command or press control-Z while a program runs in a terminal.

A login session is created when you log in to your computer on the built-in display. If you have user switching enabled, a login is recorded for each user, and remains active until logout. And if you remote login (e.g. with ssh), a login is recorded for that. Each of these should appear in w's output.

Most terminal applications, including Terminal.app and iTerm, as well as xterm if you're using X11.app, are able to create login shells in a window or tab. When you create a new window in one of these applications, you can get another login session, which appears as another line in w. But these applications don't necessarily create login shells! Whether a new window/tab is a login shell is usually controlled in the preferences. For example, in iTerm2, you can choose in Preferences > Profiles > General > Command whether to launch a login shell or some other program. If you just put "bash" there, you'll get a shell, but it won't be a login shell.

So what's the difference? It's subtle, but useful to know about.

There's a good discussion of login shells vs. regular shells here: https://unix.stackexchange.com/questions/38175/difference-between-login-shell-and-non-login-shell. But we can summarize as: a login shell is started as the first process after something sets up a login in utmpx. A non-login shell can be run any time by any program, but is not the first process after an entry in utmpx. (More technically, a login shell is the lead process in a process group. The fact that it usually has a utmpx entry is descriptive, not necessary.)

If your shell is bash, as most are, every instance of it reads and runs the .bashrc file. When bash runs as a login shell, it also reads and runs the .bash_profile and .profile files. Those files can contain instructions that should happen only for all new sessions. That's the main practical thing to know about login shells. That, and login shells appear in w.

Here's an experiment to illustrate. Open a new Terminal window, and run w. You should see something like:

11:57  up 7 days, 59 mins, 5 users, load averages: 3.58 3.53 3.91
USER     TTY      FROM              LOGIN@  IDLE WHAT
dgc      console  -                16Aug18 7days -
dgc      s000     -                11:57       - w


s000 is the name of the terminal that you're running w in. It exists on the filesystem at /dev/ttys000. Usually there's a one to one relation between login shells and terminals, but not always.

Now open a new Terminal window. Switch back to the first one, and run w again.

12:09  up 7 days,  1:11, 5 users, load averages: 5.35 4.35 4.05
USER     TTY      FROM              LOGIN@  IDLE WHAT
dgc      console  -                16Aug18 7days -
dgc      s000     -                11:38       - w
dgc      s001     -                11:57       - -bash


You see a new login on s001 — /dev/ttys001 — that's running -bash. That hyphen at the beginning is a convention telling you that bash is running as a login shell. There's no foreground program in that terminal, so w shows you the shell itself.

Now switch back to your second window and run bash. What do you expect to happen?

12:13  up 7 days,  1:14, 5 users, load averages: 5.61 5.07 4.41
USER     TTY      FROM              LOGIN@  IDLE WHAT
dgc      console  -                16Aug18 7days -
dgc      s000     -                11:38       - w
dgc      s001     -                11:57       - bash


The hyphen is gone. That's because the same login session (terminal) is now running, in the foreground, a shell that isn't a login shell. It's a child of the original -bash. If you flip back and type exit to quit the child bash, you'll see the -bash again.

Finally, note the console login. That one will never change in ordinary use. It's running the desktop/window system usually. If you turn on your Mac and don't log in, but then you ssh in from another computer, you won't see that line at all. It will always appear idle, and will always appear to be running nothing — except with the hyphen, because it's a login session.

When a program that created a login session ends that login, it goes back and removes the entry from utmpx using the common library methods for it. And because utmpx resides in the /var/run directory, it gets automatically removed whenever your computer reboots — so if you suddenly powered off your Mac while logged in, you don't continue to see fake logins forever.