Linux is the first choice of developers, and sometimes newcomers often get confused with switch another user to root user.
Linux is really Sudo (su) command is a superuser privilege which grants you to perform tasks with administration rights, su can bypass any security privileges and helps you to avoid specific security measures to install the desired programmes or to make necessary changes.
Sometimes people face problem switching to root user and not able to perform the tasks actively. We will discuss how easy it’s to change to root user and any other user.
Switching to root user is different depending on the distribution you’re on, for example, Ubuntu, Linux, Kubuntu, Xubuntu and Lubuntu. Here’s the command:
And, If you’re on a distribution which allows you to set a root user password when you’re installing a new distribution then you can use the below command:
To understand this simply if you will run the Sudo command then you will be asked to put the password, but if you use the su you will need to enter the root password.
To confirm which username you’re currently on type the following command:
Now you know about root let’s discuss other users and adapt their environment.
Su command is powerful, and you can easily switch to any other user, it is useful if you’re testing the user-account privileges and provisioning.
If you need to switch from root user to another user, for example, your other user is Sara then issue this command:
Now whatever you do on your system will be logged under the Sara and not in the default home folder but to if you need to log in as Sara and to adapt the full environment use this command:
su – Sara
I hope this clarifies your fundamental doubts and please comment below if you face any problem and need to suggest something.