In this tutorial you will learn:
- How to login as a regular user or root
- How to switch user in multiuser target
Software Requirements and Conventions Used
|Category||Requirements, Conventions or Software Version Used|
|System||Red Hat Enterprise Linux 8|
|Other||Privileged access to your Linux system as root or via the |
|Conventions|| # - requires given linux commands to be executed with root privileges either directly as a root user or by use of |
How to verify multi-user targetFirst, verify that your system is running in the
multi-userlevel of operation.
- To do so execute the following
$ systemctl get-default
- In case your system does not currently boot into
multi-userrunlevel by default execute the following command to change the default boot target.
# systemctl set-default multi-user
- Reboot your system
Log in and switch usersBy now you should have a login prompt in front of you running the
- Login into the system as a regular user. During the RHEL installation you have created at least one user so use the user credentials and log in. After successful login your should see a prompt similar to the one below:
[linuxconfig@rhcsa ~]$The prefix before the actual
$sign on your prompt will be different. However, by default it displays a user name of the user which is currently logged in and the RHEL system's hostname.
The most important part to note here, however, is the actual
$sign. There are only two possible characters which might be displayed at the end of your shell prompt and they are the
$sign indicates that you are logged in as a non-privileged regular user and will not be able to perform any administrative tasks. On the other hand the
#denotes that you have gained a root administrative access allowing you to perform any administrative and non-administrative tasks.
DID YOU KNOW?
That it is a good Linux system administrator practice to perform any tasks which do not require privileged administrative access as a regular user. It is possible to perform any given task as a administrative root user, however, your risk to inadvertently damage your system, or delete data as a result of mistake or accident. It is highly recommended to gain administrative access only in case that the task ahead requires it!
- Gain root access by using the
sucommand and using
-as an argument and provide the appropriate root password. Follow this tutorial in case you need to reset your root password:
[linuxconfig@rhcsa ~]$ su -
- Confirm that your have gained root access by execution of the
whoamicommand. Seeing the
#sign at the end of your shell prompt is also a good indication that your have gained a privileged system access.
[root@rhcsa ~]# whoami root [root@rhcsa ~]#
- Login back as a regular user. Since we have already logged in as a regular user all we have to the is to exit the root shell session gained in the previous step by executing the
exitcommand or pressing the
[root@rhcsa ~]# whoami root [root@rhcsa ~]# exit logout [linuxconfig@rhcsa ~]$ whoami linuxconfig [linuxconfig@rhcsa ~]$Yet, another alternative exists and that is to create another regular user session by using the
su -command with an argument of the user we wish to login as. Example:
[root@rhcsa ~]# whoami root [root@rhcsa ~]# su - linuxconfig [linuxconfig@rhcsa ~]$ whoami linuxconfig [linuxconfig@rhcsa ~]$
When using the
sucommand from a root privileged shell the user does not need to enter the appropriate regular user password. However, accessing root shell from a regular user shell session by using the
sucommand, the user is required to enter the appropriate root or regular user password.
- Change your default boot target unit to
graphical.target. Is there any difference when switching users from a terminal command line in comparison to the
- What is the difference between execution of the following to commands?
$ su linuxconfigAND
$ su - linuxconfig