I was following the instructions in https://stackoverflow.com/questions/2135644/how-can-i-define-a-bash-alias-as-a-sequence-of-multiple-commands to create my own bash script. It is as follows:
sudo -u otheruser -i alias cd1="cd /dir/one/" alias cd2="cd /dir/two/"
I want these aliases to be available to
otheruser. My goal is to run it as an executable but for testing I am sourcing it (to avoid the problem in https://stackoverflow.com/questions/2197461/how-to-set-an-alias-inside-a-bash-shell-script-so-that-is-it-visible-from-the-ou) like
Even with doing that, the sudo works, but none of the following aliases are available (for
otheruser). Do you think the aliases are being applied to the user that invoked this command, and not to the new user? Or is there some rule that commands in a script are ignored after sudo'ing to another user?