From https://unix.stackexchange.com/a/489913/674

Logging in is a user-space construct; the kernel doesn’t care about that.

There are multiple examples of this; for example, cron jobs can run as any user, without that user being logged in. ... connecting using SSH counts as logging in.

Since there are examples which have and which don't have logging in, may I ask what logging in is? What activities counts as logging in and what not?

Let me guess. Is any activity involving asking for user name and its password, and checking that information in /etc/passwd and /etc/shadow counted as logging in? Otherwise, not logging in?

Is running su logging in?

Is running sudo logging in? Or not, because it doesn't ask for the target user's password?

What are some other educational examples?


  • From Wikipedia: 'In computer security, logging in (or logging on or signing in or signing on) is the process by which an individual gains access to a computer system by identifying and authenticating themselves. ' – Haxiel Dec 20 '18 at 13:12
  • As my understanding, logging in means that the kernel will handle a process, which creates a TTY. The TTY allows user to communicate with the OS through some kind of shell, such as bash, csh, zsh etc. – Yves Dec 20 '18 at 13:13
  • @arochester comments should only be used to ask for clarification. Please don't leave useless comments. – terdon Dec 20 '18 at 15:12

At the most basic level, it can be considered "authenticating to a service to obtain resources from that service".

But, in Unix, the term isn't so strictly defined. Different services can interpret in different ways.

Where terminology gets confused is when you think of "logging into Unix" and getting a "login session", rather than "accessing a service".

So, for example, ssh remotemachine is considered logging in, but ssh remotemachine cat /etc/passwd may not be (sshd will perform different actions, log different data, update different files); they're both authenticating to a service and getting resources... but the second version is not considered a "login session".

Also note that authentication need not be using the passwd and shadow files (e.g. an FTP server could use a different authentication database, or SSH public keys may be used, or a kerberos ticket, or...).

  • Is it safe to say that "logging in" == "starting a login shell"? Or can you log in without starting a shell? – terdon Dec 20 '18 at 15:13
  • @terdon FTP, IMAP and other services may have a login process, but don't provide a shell. Conversely, ssh host /bin/sh -i will provide a prompt, but not a login session. – Stephen Harris Dec 20 '18 at 22:14

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.