Parallel processing is the concept of running multiple processes simultaneously. This concept is the crux of today’s modern computer systems. In the very same manner, multiple commands can also be made to run in parallel, and today, we will learn how to do this on a Linux Mint 20 system.
Methods of Running Multiple Commands in Parallel in Linux Mint 20
For running multiple commands in parallel in Linux Mint 20, you can make use of either of the following methods:
Method #1: Using the Semicolon Operator
For using the semicolon operator for running multiple commands in parallel in Linux Mint 20, you need to separate multiple commands that you want to run in parallel with semicolon in your terminal in the manner shown below:
Here, you can have as many commands as you want to run in parallel separated by semicolons.
When you press the “Enter” key to execute this statement in your terminal, you will be able to notice from the output that all of these commands have been executed in parallel, as shown in the following image:
Method #2: Using a Bash Script
For using a Bash script to run multiple commands in parallel in Linux Mint 20, you will have to create a Bash file, i.e., a file with the “.sh” extension in your Home directory. You can name this file as per your preference. In our case, we have named it “Parallel.sh”. In this file, you need to state all those commands that you want to run in parallel in separate lines followed by the “&” symbol. We wanted to run the “ls” command thrice in parallel, as you can see from the image shown below:
After writing this script and saving it, you can execute it in the terminal with the following command:
When you hit the “Enter” key to execute this script, you will be able to analyze from the output that the specified commands in your Bash script have run in parallel, as shown in the image below:
Conclusion
In this article, we taught you the two different methods of running multiple commands in parallel on a Linux Mint 20 system. The first method was quite simple as you simply had to run all the commands separated by semicolons in your terminal. However, for the second method, you had to create a Bash script for serving the very same purpose.