Read a sample: 1. Identity on a Linux System
When you open a file on a Linux computer, the system does not ask whether you are a trustworthy person. It evaluates a request made by a running program. That program operates with an identity, and Linux uses that identity—along with permissions and other security controls—to help decide whether the request should succeed.
This distinction is the foundation of user and group administration. A person may know an account by a convenient name such as maya, but the system also associates that name with numerical identifiers. Files have owners and groups. Processes carry user and group credentials. Administrative authority can depend on which identity is active and what local policy permits.
This chapter introduces those ideas without asking you to change a real account. It also establishes a fictional lab and a way to read the examples throughout the book.
A Linux user account is a collection of identity information that allows the system and its programs to recognize a user. An account has a user name and a user ID, commonly abbreviated UID. It is also associated with a primary group ID, or GID, and may be associated with supplementary groups.
An account is not necessarily a person. A system may have accounts intended for services or other system functions, as well as accounts used interactively by people. Conversely, a person can have more than one account: perhaps an ordinary account for daily work and a separate account for a specialized administrative role.
For the examples in this book, imagine a small Linux lab with these fictional accounts:
- maya is an ordinary user who works with shared project files.
- leo is another ordinary user who works on the same project.
- root is the superuser account, associated with UID 0.
- A service account may appear in examples when a program needs its own identity.
The shared project group is named projects. Maya and Leo may both belong to it, depending on the example. Their account names, group names, and numerical identifiers are illustrative; they are not claims about the accounts on your computer.
A login name is the name supplied or selected when starting a session, such as maya. Authentication is the process of establishing that the person or program is entitled to use an identity. A password may be involved, but authentication methods vary. Once a session begins, programs launched from it generally run with credentials derived from that session.
It helps to separate three questions:
1. Identification: Which account is being requested?
2. Authentication: Is the requester allowed to use that account?
3. Authorization: Is the resulting identity permitted to perform a particular action?
For example, Maya might authenticate successfully and start a session, yet still be denied access to a file owned by someone else. Logging in and being allowed to read every file are different matters.
A process is a running instance of a program. A text editor, a shell, and a web server can each run as processes. When a process requests access to a file or another protected resource, the system evaluates the request using the process’s credentials and the relevant access controls.
Suppose Maya signs in and starts a text editor. The editor normally runs with Maya’s user and group credentials. If she asks it to open a project file, the editor makes the request. Linux does not inspect Maya’s real-world job title; it evaluates the credentials of the process and the protections on the file.
A process can carry more than one user or group identifier for different purposes. Programs can also be designed to change credentials under particular conditions. For now, focus on the central idea: the identity used for an access decision belongs to the process making the request. It is not simply a label typed at a login screen.
This helps explain why two programs can have different access even when the same person started or interacts with both. Maya might have an ordinary shell and, separately, run an approved administrative command under a different identity. A service, meanwhile, can act without a person at a keyboard, using credentials associated with its own process.
User and group names make administration readable. Linux also uses numerical identifiers to represent identities and ownership. Consider this fictional mapping:
text
User name: maya User ID: 1001
Group name: projects Group ID: 2200
A command may display maya for a file owned by UID 1001 when it can resolve the number to that name. If the name changes, the numerical ownership can remain the same. Chapter 2 explores UIDs and ownership in more detail.
A group can support shared access: an administrator can arrange for a file’s group and permissions to allow access to members of projects. Chapter 3 examines primary and supplementary groups and how to inspect them.
Names and numbers do not explain every access decision by themselves. File permission bits, access control lists, security policies, and other controls can also matter.
The examples use a fictional Linux computer called labhost. Maya is the ordinary user at its command line. Unless a section says otherwise, assume that she has opened a terminal in a practice environment and is not working as root.
A command example may look like this:
console
maya@labhost:~$ whoami
maya
The parts have distinct roles:
- maya@labhost identifies the illustrative user and computer shown in the prompt. - ~ represents Maya’s home directory in this…