How to change the current user?

To change the current user in a terminal session, you can use the su (substitute user) command or sudo (superuser do) command, depending on your needs.

Using su:

  1. To switch to another user (e.g., new_user):

    su new_user

    You will be prompted to enter the password for new_user.

  2. To switch to the root user:

    su -

    This will also prompt for the root password.

Using sudo:

If you want to run a command as another user without switching the entire session, you can use:

sudo -u new_user command

Replace command with the command you want to run as new_user.

Note:

  • You need to have the appropriate permissions to switch users, and the target user must exist on the system.
  • If you are using su, you may need the password of the target user, while sudo typically requires your own password.

Let me know if you have any further questions!

0 Comments

no data
Be the first to share your comment!