Two methods to quickly switch users in Linux: 1. Use the "su" command to switch to another user and enter the password. 2. Use the "sudo" command to execute a single command with superuser privileges and enter the current user password.
Two methods to quickly switch users in Linux
In Linux systems, quickly switching users can improve work efficiency and keep different workspaces isolated. There are two simple ways to do this.
Method 1: su command
The "su" command allows you to temporarily switch to another user. Perform the following steps:
- Enter "su" in the terminal, followed by the target username. For example: "su username".
- Enter the password of the target user.
- After a successful switch, the terminal prompt will change to indicate that you are now running as the target user.
Method 2: sudo command
The "sudo" command allows you to execute a single command with superuser privileges without switching users. Perform the following steps:
- Enter "sudo" in the terminal, followed by the command you want to execute. For example: "sudo apt update".
- Enter your current user password.
- This command will be executed with superuser privileges, but you will still remain logged in as the current user.
Note:
- Before switching users, make sure you have access to the target user's account.
- The su command will switch to the root user, while the sudo command only grants superuser permissions to execute a single command.
- After exiting the target user, you will be returned to your own user.
The above is the detailed content of How to quickly switch users in linux. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn