Lab 9: Log in and Switch Users
Objective Focus
- Understand and use essential tools
- Log in and switch users in multiuser targets
Official RHCSA EX200 Exam Objectives
Switch Users
Logging in means providing credentials to access a system. During our labs so far, we mostly used the Learner user account and that is fine for fundamental tools and programs.
We are now going to be getting used to switching over to root.
To switch users, we use the su command.
$ su
When su is run without an option it defaults to change into the root account in the current working directory. To get into root’s home directory, we’ll user the “-l” option.
$ su -l
A word of warning, be careful when running commands as the root account. The root can do anything and has access to the entire system.
It is best practice to log in as a normal user and switch to root when necessary.
We also can use su to switch to other users created on the system.
$ su -l learner
We’ll use whoami to confirm the user account we changed into and logname to show us the user who originally logged in.
$ whoami
$ logname
Now, I want explain the meaning of the multiuser targets.
Starting with target, it is a collection of units. Units refer to a collection of files that control and maintain the operating system, in this case RHEL 9.
Now, multiuser targets mean configuration files that are needed to support a multiuser environment.
To see the target of the system you are currently using, whether thats server1 or server2, we use the systemctl get-default command.
$ systemctl get-default
What is server1’s current target settings? Click for answer
- graphical.target
What is server1’s current target settings? Click for answer
- graphical.target
What is server2’s current target settings? Click for answer
- multi-user.target
What is server2’s current target settings? Click for answer
- multi-user.target
There are several targets with each having its purpose and place for use. List them with systemctl list-units –type=target
$ systemctl list-units --type=target
Now to finish this lab, switching between users is a fundamental tool and used daily. Targets are part of the default system programs that run and maintain a RHEL system called systemd (system daemon).
We’ll talk more about systemd in upcoming labs. It is an integral part of a RHEL 9 system and its administration.
That’s it for this lab!