A web server starts as a process. Linux associates each process with an identity that helps determine what the program can read or change. A service account is an identity set aside for a program.
Linux Hardening · Lesson 2
Service Accounts
Learn to identify the account a Linux process runs under and reason about its access.
Reading the Process Identity
In a normal terminal, $$ gives the shell's process ID. Use it to see the identity of your own shell. The -p option selects that process and -o chooses the displayed columns. The equals signs omit the column headings.
$ ps -p "$$" -o user=,comm=
On a LabEx terminal the account might be labex. The command column names the shell program. The corresponding fields for a service process tell you which account it uses, regardless of who launched it.
Which field tells you the account associated with the selected process?

Choosing a Dedicated Identity
Consider a web service whose only jobs are reading pages and writing its own log. A dedicated site-web account can be given those permissions. Running it with an administrator's broader access would give the program more ways to change the host than it needs.
Which access plan fits that service's work?
Checking Multiple Processes
Some services use separate processes for different responsibilities. Check the process that handles the request before explaining which permissions apply to it. If you change the running identity, confirm the service can still read its inputs and write only what it needs.
A maintenance tool reports a supervisor as root. What tells you which account serves the web requests?
Lesson complete
You finished Service Accounts
You can now connect a Linux process to its runtime identity.
Find a process's user in ps output.
Choose permissions that fit a service's job.
Inspect the relevant process in a multi-process service.
Keep your learning progress
Create a free account to save this lesson and continue learning on any device.
Create a free account