Speaking about Linux and in particular Ubuntu (from 14.04) systems:
Case 1 – As pointed out in this answer, processes that allocate a pseudo-terminal don't need to make a login: for example, cups
. Anyway they are not listed in the who
command output.
Case 2 – If I make a GUI login, the executable gnome-terminal
(or xfce4-terminal
, according to the desktop environment) can open a lot of pseudo-terminals, with my user already logged in, and for each opened pseudo-terminal a new line in the who
command output will appear.
So,
1) Both a process and a user can open a terminal, so they must have some common features (because they can act in a similar way) and some differences. From the point of view of the system shell, what is the difference between a user (who obviously needs to login when opens a terminal and is listed in the who
command) and a process (who does not need to login to use a terminal and who is not listed in the who
command)? My doubt is about the fact that a process can open a terminal when he wants and without any check by the system, while a user must always make a login.
2) How can the unique login in the GUI "unlock" all the logins for the pseudo-terminals opened by the terminal emulator? This is not valid if I open /dev/tty1
through CtrlAltF1.
Best Answer
Processes are running instances of executable binaries. Each process, similarly to each file etc., belongs to a certain user. (It's a bit more complicated because there are various user IDs for a process, but most of the time they are the same.)
A terminal line (tty) can be opened by any process at any time, just as a process can open/create a file, a TCP socket and so on. There's nothing special in terminals in this regard.
It's an ancient user-level concept that there exists an utmp/wtmp database keeping track of logins. Graphical login managers update the records beloging to the entire graphical login (makes sense more-or-less), and terminal emulators voluntarily update (or not) the records belonging to the given terminal line (this, in my opinion, as detailed in https://bugzilla.gnome.org/show_bug.cgi?id=747046, doesn't make any sense whatsoever). This comes from the days when terminal were real terminals instead of graphical emulators, sure it made sense to keep track of who's logged in from where.
It's in my opinion an obsolete, bad tradition to say that opening a graphical terminal emulator means "logging in", or that a log entry should be created for open terminal windows/tabs and that
who
and similar utilities should report this.Utilities like
who
print the information based on these more-or-less properly maintained utmp/wtmp files, which is again of pretty limited usability and reliability.