Neither of these work. Can you tell me why sudo does not work with a function, and is there a way to make it work with a function like this?
yy() { yum upgrade -y; yum upgrade -y; }
sudo yy
or:
sudo $(yum upgrade -y; yum upgrade -y)
You are creating a subshell. What you are doing is executing the output of the command as sudo. Try
sudo bash -c 'yum upgrade -y; yum upgrade -y'