try running:
su -c "Your command right here" -s /bin/sh username
This will run the command as username given that you have permissions to sudo as that user.
More Related Contents:
- How do you find the original user through multiple sudo and su commands?
- How do I use sudo to redirect output to a location I don’t have permission to write to? [closed]
- Use sudo with password as parameter [closed]
- Command not found when using sudo
- Use sudo without password INSIDE a script
- Identify user in a Bash script called by sudo
- sh: 1: Syntax error: "(" unexpected error
- How to compare two strings in dot separated version format in Bash?
- How do I write standard error to a file while using “tee” with a pipe?
- Convert date formats in bash
- Syntax error in shell script with process substitution
- Pipe to/from the clipboard in a Bash script
- What is the best way to ensure only one instance of a Bash script is running? [duplicate]
- How to kill all processes with a given partial name? [closed]
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- Extract file basename without path and extension in bash [duplicate]
- How can I remove the last character of a file in unix?
- How to check if a file is empty in Bash?
- How to preserve line breaks when storing command output to a variable?
- How to use sed to remove the last n lines of a file
- What does the ‘-‘ (dash) after variable names do here?
- Filename not printing correctly with underscore “_” in Bash [duplicate]
- Should PATH contain directories or full paths to binaries?
- Execute a command without keeping it in history [closed]
- In bash, how to store a return value in a variable?
- How do I run multiple background commands in bash in a single line?
- Multithreading in Bash [duplicate]
- Simple Socket Server in Bash?
- Difference between shell and environment variables
- How do I get the difference between two dates under bash [duplicate]