How to Run More Than One Bash Command at Once

One of the things that makes Linux servers so powerful is Bash and shell systems similar to it. You can use it to run complex scripts, execute multiple commands, and automate processes. If you ever want to execute multiple commands with bash, there are a couple of easy ways to make it happen.

One method is to put commands into the background. When you run a command and put a “&” after it, it will push that command to the background and allow you to run others. You could put this into a string of commands:

$ cmnd1 & cmnd2 & cmnd3 &

And the output would be:

[1] 2679

[2] 2680

[3] 2681


Notice that the bash prompt returns allowing you to do more while those three commands run.

If those commands are connected, and you need the results of one to pour into the next, you can use piping “|” instead. For example:

$ cmnd1 | cmnd2

As you can see, this is just a little taste of what you can do to run multiple commands in bash. You can get much more creative with the tools it has available. For a more detailed explanation, see this post.