How to Execute Multiple Commands in Linux Bash Shell at Once

When you’re in a hurry and need to execute multiple commands at once, it can be hard to type them all into the Terminal. Fortunately, there is an easier way!

To execute more than one command in the Linux bash shell at once, use semicolons (;). For example:

echo "Hello" ; echo "World!"

The first echo will output Hello and then World!. You can also add spaces between the commands if you want:

echo "Hello" ; echo "World!"

If you are a power user of the Linux Bash Shell, then you know that it is possible to execute multiple commands at once. This can be done by separating them with semicolons and pressing enter after each one. However, if you want to put these commands into a script file, there is an alternate way of executing them all together using the && command.

In the below example, I’m installing Python 3.9 on a Ubuntu server using a single line.

 sudo apt update && sudo apt install python3.9  && sudo apt-get install python3.9-dev python3.9-venv