Home >System Tutorial >LINUX >What is the password for the linux switch user command?

What is the password for the linux switch user command?

下次还敢
下次还敢Original
2024-04-11 20:54:17678browse

To use the su command to switch user identities in a Linux system, you need to provide the password of the target user, which is set when the user is created.

What is the password for the linux switch user command?

Linux switch user command and password

In Linux system, you can use su Command to switch user identity. This command requires the target user password to be executed.

The following is the syntax of the su command:

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

Options:

  • -c < Command>:Execute the specified command after switching users.
  • -m: Retain the user environment variables before switching.
  • -s : Use the specified shell to log in to the switched user.

User:

Specify the target user to switch to. If not specified, switches to the root user.

Password:

When executing the su command, the system will prompt you to enter the password of the target user. This password is the password set when the target user is created.

Example:

Switch to user "john":

<code>su john</code>

Switch to root user:

<code>su</code>

Switch to user" john" and execute the "ls" command:

<code>su -c "ls" john</code>

Switch to user "john" and retain the environment variables before switching:

<code>su -m john</code>

Switch to user "john" and log in using Z shell:

<code>su -s /bin/zsh john</code>

Note:

  • Only users with root permissions can switch to other users.
  • If the entered password is incorrect, the user switching operation will fail.
  • Use the su command with caution as it can grant advanced access to the system.

The above is the detailed content of What is the password for the linux switch user command?. 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