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:
alias startservices="verylongcommand"
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.
startservices
defined in the other user's~/.bash_profile
? – Satō Katsura Sep 25 '17 at 20:03~
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. – Scott - Слава Україні Sep 26 '17 at 01:02