How to log in as a different account?

QuestionsQuestions8 SkillsProYour First Linux LabNov, 16 2025
0113

To log in as a different account in a Linux environment, you can use the su (substitute user) command. Here’s how to do it:

  1. Open your terminal.

  2. Type the following command, replacing username with the account you want to switch to:

    su - username
  3. You will be prompted to enter the password for the specified user account. Enter the password and press Enter.

If you want to switch to the root user, you can simply use:

su -

Alternatively, if you are using a system with sudo privileges, you can also switch users with:

sudo -i -u username

This will log you in as the specified user without needing to know their password, provided you have the necessary permissions.

To return to your original user account, you can type:

exit

This will log you out of the current user session and return you to the previous user.

0 Comments

no data
Be the first to share your comment!