I am logged in as root user and need to execute a single command from redbox user without switching. For this, I am using following command:
# su - redbox -c 'CMD'.
When I try to execute "ifconfig" (
su - redbox -c 'ifconfig'), I get following error:
-bash: ifconfig: command not found
But it works if I switch to redbox first, and then execute "ifconfig" as shown below:
# su - redbox
Same problem for many more commands. I don't understand what is causing this problem. Please help me figure it out.
I am using Alpine Linux v3.9.4
Thanks to link shared by Jeff, I see the problem now. When I use
su - redbox - c 'ifconfig', the value of $PATH is different than when I use
su - redbox followed by
Can someone explain why $PATH is different in both cases? Note that in both cases I hove used
- which uses login shell.