--- tags: - bash --- [[Bash]] [[Temporary set permissions with which new files are created]] Using `sudo` we can execute commands as other users, most commonly as the root user. When passing `-u` switch we can specify different users. When the command involves output redirection it is common to pass the entire command to a shell executed as that user: `sudo -u user bash -c 'command > redirect'`. ## Why do I get "command not found" as I execute with another user? This can be because `sudo` normally discards the environment. Passing the `-i` switch makes sudo "login" which causes `.profile` et al to be sourced, thus configuring the user environment.