Users in RHEL
Introduction
In this article you can learn about working with users in RHEL Linux
su
The difference between su and su -l
First let us check the $USER variable under a regular
[andrei@host113 ~]$ echo $USER
andrei
The expected result. Now let us run su and check what happens to $USER
[andrei@host113 ~]$ su
Password:
[root@host113 andrei]# echo $USER
andrei
[root@host113 andrei]# pwd
/home/andrei
$USER is still andrei and the current directory is andrei's home directory
Let us log in again, this time through su -l (you can just use su -)
[root@host113 andrei]# exit
exit
[andrei@host113 ~]$ su -l
Password:
Last login: Mon Sep 13 10:35:05 EEST 2021 on pts/0
[root@host113 ~]# echo $USER
root
[root@host113 ~]# pwd
/root
Now both the user and the current directory have changed.
Logging in
Article author: Andrei Olegovich