3.2 Log In and Switch Users in Multiuser Targets
Key Takeaways
- multiuser.target is the typical multi-user, networked, non-graphical default on RHEL servers; graphical.target adds a GUI session stack on top of multi-user services.
- whoami and id show your effective identity; who and w list logged-in users and sessions on the system.
- su username switches user but often keeps much of the prior environment; su - username (or su -l) starts a login shell that more fully loads the target user's profile and home.
- Virtual consoles (tty1, tty2, …) and remote SSH sessions both provide logins into the same multiuser environment when the system is running a multi-user target.
- Default boot target is persistent: systemctl get-default / set-default control which target is reached after reboot.
RHEL is a multiuser operating system: many users and services can be active at once. The RHCSA objective to log in and switch users in multiuser targets means you must understand systemd targets that define the system’s operating mode, how interactive logins work, and how to change identity with su (and related tools) without losing track of environment, home directory, and privileges.
Multiuser Targets vs Graphical Targets
systemd boots the machine into a target—a synchronization point that pulls in a set of units (services, sockets, mounts).
| Target | Typical use | What you get |
|---|---|---|
| multiuser.target | Servers, most exam VMs | Multi-user networking, text logins, no full GUI stack required |
| graphical.target | Desktop/workstation style | Multi-user features plus display manager / GUI |
| rescue.target / emergency.target | Recovery | Minimal environment for repair (covered more under boot objectives) |
On many RHEL servers the default target is multiuser.target. Confirm with:
systemctl get-default
Change the persistent default (survives reboot):
sudo systemctl set-default multiuser.target
sudo systemctl set-default graphical.target
Switch the running system without permanently changing the default:
sudo systemctl isolate multiuser.target
Isolating is immediate operational change; set-default is what EX200 cares about when the grader reboots. Remember the exam rule: if the requirement is “after reboot the system comes up multi-user without a GUI,” set-default multiuser.target is the durable fix—not only a temporary isolate.
multiuser.target still allows multiple simultaneous logins: local virtual terminals, serial consoles, and SSH sessions. “Multiuser” does not mean “only one person at a time”; it means the system is fully up for concurrent users and services.
Logging In
Local text logins
On a console, a getty presents a login prompt on a tty (for example tty1). Enter username, then password. A successful login starts a shell according to the account’s settings in /etc/passwd (shell field) and profile files.
Switch virtual consoles with Ctrl+Alt+F1, Ctrl+Alt+F2, and similar combinations on physical or many hypervisor consoles (exact key mapping can depend on the virtualization client). Each tty can host a different logged-in user—classic multiuser behavior.
Remote logins
SSH logins (previous section) also land you in the multiuser environment. From the system’s point of view, an SSH session is another login session associated with a pseudo-terminal (pts), visible in tools like who and w.
Identifying who you are
Always verify identity before changing system files:
whoami # current effective username
id # uid, gid, and supplementary groups
id student # inspect another account without switching
Session inventory:
who # logged-in users, terminals, login times
w # who + load and what each session is running
logname # original login name in some session types
These commands prevent costly mistakes—editing as the wrong user, writing into the wrong home directory, or assuming you still have root when you do not.
Switching Users with su
su (“substitute user” / “switch user”) changes the active user of your shell session. Default with no username is to switch to root (password required unless already root).
su username vs su - username
This distinction is exam-critical:
su student
su - student
su -l student # same idea as su - student (login shell)
| Form | Shell type (typical) | Environment / cwd behavior |
|---|---|---|
su student | Non-login shell | Often keeps much of the prior environment; may stay in previous directory |
su - student or su -l student | Login shell | Loads target user’s login profile; home and env closer to a real login |
When you need the target user’s full login environment—correct $HOME, path, and profile scripts—use su -. Administrators who only run su without the dash sometimes see missing variables, wrong cwd, or tools not on PATH, then waste time debugging “broken” software that is really an environment problem.
Examples:
su - # become root with login shell (root password)
su - bob # become bob with login shell
su -c 'id' alice # run one command as alice, then return
Exit the switched shell with exit to return to the previous user.
Password prompts
- Switching to root with
sugenerally requires the root password (unless policy/tools differ). - Switching to another ordinary user requires that user’s password when you are not already privileged.
- sudo (covered more under security/user admin topics) can allow permitted commands as another user using your password and sudoers policy—different mechanism from
su.
For this objective, master su / su - behavior and know when a login shell is required.
Root vs Ordinary Users and Home Directories
| Account | Typical home | Notes |
|---|---|---|
| Regular user | /home/username | Owned by the user; SSH keys under ~/.ssh |
| root | /root | Not /home/root on RHEL; configs and keys for root live here |
The shell expands ~ to the current user’s home. After su - alice, ~ is alice’s home. After su - to root, ~ is /root. Writing “into home” while still in an old directory or wrong user is a frequent source of “file not found” and permission errors.
Check:
echo $HOME
pwd
ls -ld ~
Why Multiuser Targets Matter for Admin Work
In multiuser.target:
- Network services (including
sshdwhen enabled) can run - Multiple users can log in and switch identities to test permissions
- You can validate that a service runs without relying on a GUI
RHCSA labs often assume text-mode multiuser operation. If a system is stuck in a rescue-like target or failed units prevent multiuser, logins and network services may be incomplete—tie that mental model to later boot-troubleshooting objectives.
Practical Workflows for the Exam
- Confirm default target:
systemctl get-default→ set if the task requires multiuser or graphical after reboot. - Log in as a specified user (console or SSH).
- Verify with
whoami/idbefore editing restricted paths. - Switch to root or another account with
su -when you need a proper login environment. - Run the administrative task; exit nested shells cleanly so you know which identity is active.
- Reboot only when required—and ensure default target and enabled services match the specification so the state persists.
Common Pitfalls
- Using
suwithout-and then wondering why$HOMEorPATHis wrong - Assuming root’s home is under
/home - Changing the running target with
isolatebut forgettingset-defaultwhen persistence is required - Losing track of nested
susessions (runwhoamioften) - Expecting graphical tools when the system is correctly left on
multiuser.target
If you can log in locally and remotely, prove identity, switch users with correct login-shell semantics, and set a default multiuser target that survives reboot, you have met this objective’s intent.
Which command shows the systemd target the system will enter by default after a reboot?
You are logged in as student and need a shell as user operator that closely matches a fresh login for operator (home and profile environment). Which command is the best fit?
On a typical RHEL system, where is the root user's home directory?
Which statement best describes multiuser.target on RHEL?