There are two ways to make this happen.
The first is using the semicolon like so:
sudo apt-get update; sudo apt-get upgrade -y
The only problem with that method is that the second command will run, even if the first command fails.
In those cases, you’d run the command:
sudo apt-get update && sudo apt-get upgrade -y
Both versions of the command will run, but the second form will only run the second command if the first complete successfully.
And you can do this with more than two commands.
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get autoremove -y