Home  >  Article  >  System Tutorial  >  What is the command to switch users in Linux?

What is the command to switch users in Linux?

下次还敢
下次还敢Original
2024-04-12 13:09:15680browse

To switch users in Linux, you can use the su command. This command supports the following options: -: Specify the identity of the user to run a single command. -c: Run the specified command as the specified user. -l: Run as the login shell of the specified user. -s: Specifies the shell to use.

What is the command to switch users in Linux?

Linux user switching command: su

The command used to switch users in Linux is su.

su command syntax:

<code>su [选项] [用户]</code>

Options:

  • -: with Run a single command as a specified user.
  • -c: Run the specified command as the specified user.
  • -l: Runs as the login shell of the specified user.
  • -s: Specifies the shell to use.

Usage:

To switch to another user, you can enter the following command:

<code>su 用户名</code>

You will be prompted to enter the password of the target user . After entering the password, you will switch to that user's shell.

Example:

To switch to a user named "john", you can enter the following command:

<code>su john</code>

You will be prompted to enter "john" " password. After entering the password, you will switch to "john"'s shell.

Tip:

  • If you do not specify a user, you will switch to the root user.
  • If you run the su command as root, you can switch users without a password.
  • Use the su command with caution as it allows you to access restricted resources.

The above is the detailed content of What is the command to 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