In Linux, use the su command to switch user names: 1. Enter su, 2. Enter the target user name, 3. Enter the target user password.
How to use commands to switch user names in Linux
In Linux systems, switching user names is a common operate. You can do this using the following steps:
Step 1: Type the su command
Type the following command to start su Command:
<code class="shell">su</code>
Step 2: Enter the username you want to switch to
You will be prompted to enter the username you want to switch to. Enter your username and press Enter:
<code class="shell">user_name</code>
Step 3: Enter your password
You will be prompted to enter the password for the user you want to switch to. Enter the password and press Enter:
<code class="shell">password</code>
If you enter the correct password, you will successfully switch to the specified user's shell. You can see the username of the switched user in the command prompt.
For example, if you switch from userA to userB, your command prompt will change from:
<code class="shell">[userA@hostname]$</code>
to:
<code class="shell">[userB@hostname]$</code>
The above is the detailed content of How to use command to switch username in linux. For more information, please follow other related articles on the PHP Chinese website!