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:
-
To switch to another user (e.g.,
new_user):su new_userYou will be prompted to enter the password for
new_user. -
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, whilesudotypically requires your own password.
Let me know if you have any further questions!
