Not sure what I'm doing wrong here.
User2 sources a file in it's .bash_profile to set environment specific aliases.
# .bash_profile source $HOME/set_environment_shortcuts
Inside $HOME/set_environment_shortcuts (there are many aliases in here). Example:
Now I would like to 'startservices from another user.
[User1@server1 ~]$ sudo su -l User2 -c '. ~/.bash_profile; startservices' -bash: startservices: command not found
The runuser command produces the same result.
[User1@Server1 ~]$ sudo runuser -l User2 -c '. ~/.bash_profile; startservices' -bash: startservices: command not found
Do aliases not work in this way?
Note, when bypassing the alias entirely, the command works.
startservicesdefined in the other user's
~means home directory (as does
$HOME), and that different users have different home directories, right? Please edit your question to be a whole lot clearer about what is defined in whose file, and which user is executing which command.