Changing users with the su command
63
Now, we can make the change from root to user:
[root@rhel-instance
]# su user[user@rhel-instance root whoamiuserNow, we have a session as user. We can finish this session by using the exit command:
[user@rhel-instance root exitexit[root@rhel-instance
]# whoamirootAs you may have seen,
when we are logged in as root, we can act as any user without knowing its password. But how can we impersonate root We can do so by running the su command and specifying the root user. In this case, the root user’s password will be requested:
[user@rhel-instance
]$ su rootPassword:[@rhel-instance user whoamirootAs root is the user with the ID 0 and the most important one, when running su without specifying
the user we want to turn into, it will default to turning us into root:
[user@rhel-instance
]$ suPassword:[root@rhel-instance user whoamirootEach user can define several options
in their own environment, such as, for example, their preferred editor. If we want to fully impersonate the other user and take their preferences (orb
environment Share with your friends: