1

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.

  • Newer gnome-terminal versions no longer update the utmp records and in turn the terminals no longer show up in who's output, see bugzilla.gnome.org/show_bug.cgi?id=747046. – egmont May 10 '16 at 9:17
  • Could you please clarify your first question: Basically you're asking what's the difference between a user and a process. A user is a user, a process is a process, these are two completely different notions. Do you really ask for further clarification on this? – egmont May 10 '16 at 9:18
  • @egmont I tried to clarify the question. – BowPark May 10 '16 at 9:24
1

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.

  • Thank you for both your answers (I suggest you to merge them into a unique one). You have been very clear about my first question. I may understand that the only action which really needs to be logged is the GUI login, in your opinion. I also understand that a process can open a terminal: but in the GUI case there's more. A process is opening a terminal and automatically logs a user in that terminal; and this is my second question. How can it be possibile and why it is possible only from the GUI? – BowPark May 10 '16 at 13:25
  • That is: if I click on the terminal icon from GUI I get a terminal with my user already logged in. If I run a script on /dev/tty1 (for example) which creates a new shell, I must insert the password, so make a new login. – BowPark May 10 '16 at 13:28
  • 1
    /dev/tty1 is opened/created by a getty process running as root. It asks for your username and password, and upon successful validation changes the ownership to you, logs to utmp/wtmp/lastlog, and launches up a shell inside that terminal. On graphical systems, you perform the login (authentication) in a display managed (gdm, kdm, lightdm etc.) and from then onwards any app that you launch is automatically running on your behalf. This app can be e.g. a firefox which opens hundreds of network connections, or gimp opening pictures, or gnome-terminal which opens a terminal in each of its tabs. – egmont May 10 '16 at 19:55
1

Based on the clarification, I'm quite certain you use the words user and process incorrectly. It looks to me that you believe something is either a user, or a process (exactly one of them). This is absolutely not the case.

Every running instance of an executable program code (no matter if it's started "automatically" (e.g. as part of the boot process) or via user interaction (e.g. clicking with the mouse)) is called a process. Each and every process has a user associated with it (for boot processes these are often the superuser called root).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.