Switching User in Linux Operating System
As multi-user operating system, many users can log in to the operating system at the same time. But not only limited to that aspect, even a user can switch to other user after that user successfully logged in to the operating system.
How can you even switch to another user after you successfully logged in to the Linux operating system ?. You can use the following command to do that :
username@hostname:~ $ su
It can be recognized which is the short abbreviation of switch user, substitute user or super user. It is actually depends on the purpose of the command’s execution. We can describe several functions of the command as follows :
- Switch or substitute to another user.
We can switch to another user by using this command. Below is the image of executing the command :
We are logging in with ‘root’ as the username. And following that, we are switching or substitution our user to another user. In the above case, we are switching to ‘james’.
- Gaining super user access.
We are gaining access as super user by switch ourselves to root. It can be also done by executing the command ‘su’. The following image shown it :
Another thing that is actually important following the command as an additional parameter is the dash or hyphen sign (-). The function of this additional parameter is described as follows :
- Changing the working directory to default directory of the user whom we are switching to. So, if switch ourselves to ‘root’, we will be automatically directed to /root/ as the current working active directory.
- The other thing is acquiring a new environment condition of the user whom we are switching to including all of the environment variables which is defined for the user whom we succeeded on logging into.