The su command stands for "substitute user" or "switch user." It allows a user to switch to another user account during a login session. Here are the common usages of the su command:
-
Basic Usage:
su username: Switches to the specified user while keeping the current environment variables.
-
Login Shell:
su - username: Switches to the specified user and loads that user's environment, making it feel like a full login session.
When you run the su command, you will be prompted to enter the password for the target user account. If the authentication is successful, your command prompt will change to indicate that you are now operating as that user.
The su command is commonly used for administrative tasks, allowing users to gain root privileges or switch to other user accounts as needed.
