Linux Process – Does a User Have to Log In to Run a Process and Become Its Owner?

linuxprocessrootusers

In general, does a user have to log in to run a process and become its owner (ruid, or euid)? Does this apply to any user or any non-root user?
For example:

  • In the boot sequence of Linux, the kernel starts the init system as the first process, and then the init process runs login so that each user can login.
    The init process is owned by root, and does the user root have to log in before starting the init process? See Why is there a `systemd` process owned by each user that is logged in?

  • When using ssh to run a command without starting an interactive shell, do we have to log in first or not to run the command?

If I don't need to log in to run a process as its owner, how can I do that?

Thanks.

Best Answer

No, you don’t need to log in to start a process running as a given user. 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.

To address your specific questions:

  • no, root doesn’t need to log in to start the init process, thankfully (imagine handling a fleet of thousands of servers and millions of VMs otherwise);
  • connecting using SSH counts as logging in.
Related Question