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
loginso that each user can login.
The init process is owned byroot, and does the userroothave to log in before starting theinitprocess? See Why is there a `systemd` process owned by each user that is logged in? -
When using
sshto 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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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
initprocess, thankfully (imagine handling a fleet of thousands of servers and millions of VMs otherwise); - connecting using SSH counts as logging in.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0