i---login Verified current stable Not installed? System Operations

I Login / Launch Shell As Specific User Login

Launch Shell As Specific User Login

Open a login shell for a specified user to perform actions on their behalf, primarily for scripting or administration.

$
Terminal
sudo -i -u <user>

When To Use

When targeting user-specific configurations or environments in multi-user systems.

Pro Tip

Set `-m` to preserve the environment of the specific user when switching.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
sudo -i -u <user>

Anatomy of Output

Understanding the result

user@hostname:~$ sudo -iu user Command Executed

Runs a login shell as the specified user.

user@hostname:~$ env | grep USER Environment Variables Check

Displays current user variables to confirm switch.

user's custom prompt# User Shell Prompt

Indicates successful user switch.

Troubleshooting

Common pitfalls

sudo: user does not exist

Solution: Verify the username before executing the command.

sudo: service is not running

Solution: Ensure the target service is active and reachable if starting commands.

bash: command not found

Solution: Ensure the command or path is correct for the user.

Command Breakdown

What each part is doing

sudo
Base Command
The executable that performs this operation. Here it runs I Login before the shell applies any redirect operators.
-i
i| login
The value supplied for i| login.
-u
u| user
The user value supplied to this command.
<user>
user
The user value supplied to this command.
-i
Command Option
Tool-specific option used by this command invocation.
-u
Command Option
Tool-specific option used by this command invocation.

Alternative Approaches

Comparable commands in other tools

Alternative system operations tools for the same job.