How to Switch to the Specific User by Using su Command
To switch to a different user, specify the username as an argument:
su username
Replace ‘username’ with the actual username you want to switch to. You’ll be prompted to enter the password for that user.
For example: If we want to switch to a user name “shivansh260” we will use the following command
su shivansh260
Switch Users on Linux with the su Command
Switching users on a Linux system is a fundamental aspect of system administration, allowing users to perform tasks with different privileges. The ‘su’ command, short for “switch user” or “substitute user,” is a powerful tool that facilitates this transition. This article will delve into the intricacies of the ‘su’ command, exploring its various options and providing practical examples to demonstrate its usage.
Table of Content
- Understanding the su Command
- Basic Syntax of su Command
- Options Available in su Command
- How to Switch to the Root User by Using su Command
- How to Switch to the Specific User by Using su Command
- How to Execute a Command as Another User by Using su Command
- How to Preserve Environment Variables while Switching User
- How to Simulate a Login Shell