I ssh into my machine and then, in order to run some commands, I need to sudo bash first.In an interactive terminal session, if I do this:[vagrant@33 ~]$ sudo bash[root@33 vagrant]# which bundle/opt/upnxt/rbenv-0.4.0-7/shims/bundlethings work. But if I need to do this in one line:[vagrant@33 ~]$ sudo bash -c whoami; which bundlerootwhich: no bundle in (/sbin:/bin:/usr/sbin:/usr/bin)things stop working. Why is this happening and what else do I need to do to the second scenario in order to be able to run it like the first one?
Command not found when run with sudo bash
shell;sudo;path
When you call sudo bash you run new instance of bash with user root environment. But if you call sudo bash -c whoami; which bundle the environment is remain as for your user. If you havn't intention to do so you can modify last call by sudo options -i-i, --loginRun the shell specified by the target user's password database entry as a login shell.  This means that login-specific resource files such as .profile or .login will be read by the shell.  If a command is specified, it is passed to the shell for execution via the shell's -c option.  If no command is specified, an interactive shell is executed.  sudo attempts to change to that user's home directory before running the shell.  The command is run with an environment similar to the one a user would receive at log in.  The Command Environment section in the sudoers(5) manual documents how the -i option affects the environment in which a command is run when the sudoers policy is in use.