How do I change the current user?

QuestionsQuestions8 SkillsProYour First Linux LabDec, 03 2025
065

To change the current user in a Linux environment, you can use the su (substitute user) command or the sudo command, depending on your needs and permissions.

Using su Command

The su command allows you to switch to another user account. If you want to switch to the username, you would use:

su - username

You will be prompted to enter the password for the specified user. The - option ensures that you also switch to the user's environment.

Using sudo Command

If you want to execute a command as another user (usually root), you can use sudo. For example, to run a command as the root user:

sudo command

You will need to enter your password, and you must have the necessary permissions to use sudo.

Returning to the Original User

If you switched users using su, you can return to the original user by typing:

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!