User Switching and Login Shells
The objective is "log in and switch users in multi-user targets", and the one thing worth practising is that su user and su - user leave you with different environments. Both are run side by side here, along with the four places the system records logins.
Users and Groups Guide 21 of 67 Beginner
- OSRHEL 10.0
- Kernel6.12.0-55.9.1.el10_0
- dnf4.20.0
- Flatpak1.16.0
- TimeAbout 13 min
sudo -i is the modern equivalent of su - and is preferable: it is authorised by sudoers, logged, and needs your own password rather than the target account's. su - needs the target user's password, which is why root having no usable password does not prevent sudo -i.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| RHCSA-A01 | 192.168.0.31 | RHEL 10.0 | Practice node (graded) - spare /dev/sda | 2 Core | 4 GB | 50 GB + 15 GB |
This guide includes
Use this when su and su - give different results and you need to know why. This matters because one character decides whether you get a login shell - and that decides your environment, your home directory and your PATH.
- finding who you are, and who else is on the machine
- comparing
suwithsu -, which differ by a single character - confirming which kind of shell you actually got
- using the sudo equivalents of both
- finding where logins are recorded, and reading one session in detail
Before you start
- A sudo-capable account.
- The session creates and removes one account.
-
Who am I, and who else is here
-
su versus su dash
-
Confirming which kind of shell you got
-
The sudo equivalents
-
Where logins are recorded
-
A session in detail