su Command Generator
Generate su commands to switch user identity and run commands
Getting Started with su
## What is su?
`su` (substitute user) switches to another user account by starting a new shell as that user. With no username it defaults to root. It prompts for the target user's password.
## How to Use
1. **Enter Username**: Provide the account to switch to (defaults to `root`). 2. **Pick Options**: Use `-l` for a login shell, `-c` to run a single command, or `-s` to choose a shell. 3. **Provide Command** (optional): With `-c`, give the command string to execute. 4. **Copy & Run**: Copy the generated command into your terminal.
Common Options
### `-l` (or `-`) Login shell Start a login shell as the target user — it resets the environment (`$PATH`, `$HOME`, etc.) as if the user had just logged in.
### `-c` Run a command Pass a command string to execute as the target user, then return to the original shell.
### `-s` Shell Specify a particular shell to use (e.g. `/bin/zsh`).
### `-m` / `-p` Preserve environment Keep the current environment variables instead of resetting them. Implied to be used carefully, as some variables can affect behavior.
### `-f` Fast Start the shell as a login shell but skip reading startup files (equivalent to passing `-f` to the shell).
### User argument The positional argument is the target username. Omit it to switch to root.
▶What is the difference between 'su' and 'su -'?
▶How do I run a single command as another user?
▶How do I switch to root?
If this tool has been helpful to you, consider buying me a coffee.
Buy me a coffee