If the password is correct, a new shell prompt will appear. Once we enter the new shell environment, we can execute commands as super users.
Introduction
The su command starts the shell as another user.
========================================================== ===
The command is generally in the following format:
Su [-[l] [user]
If the "-l" option is included, the shell session interface is used to specify the user's logon shell (login shell) interface.
This means that the running environment of the specified user will be loaded and its working directory will be changed to the main directory of the specified user.
This is often the result we want.
If no user is specified, it is assumed that the user is a super user by default.
Note that-l can be abbreviated as-, and this form is often used.
========================================================== ===
For example
[Allyes_op @ allyes ~] $ Su-
Password:
========================================================== ===
Description
After entering the su command, the system prompts you to enter the password.
If the password is correct, a new shell prompt will appear. Once we enter the new shell environment, we can execute commands as super users.
========================================================== ===
We can also use the su command to execute a single command.
Format: su-c 'command '.
In this format, a single command line is passed to a new shell environment for execution. The command must be enclosed in single quotes and cannot be omitted.