The multiple number of commands can be executed at once in Linux terminal using two different ways. Both the ways are too simple. The one way among the two introduce us to the Shell Scripting. Yes, I have been talking a lot about shell scripting. Well, it starts now! Let’s focus on how to run multiple command at same time. I recommend, if you are not familiar with the Linux commands see our other various tutorials which will make you familiar with the various Linux commands. Also, see the cool things that you can do in the terminal like watching games, playing movies and all.
This one is very simple. You just need to separate the commands which semi colon. After you are done, hit enter and all your commands will execute. The syntax is:
command; command; command; command
The commands ls, cat hello and ls -l are executed. The first command “ls” listed all the directories, “cat hello” read the file hell0 and “ls -l” commands listed all the files and directories in detail with permission. See, the various things you can do with ls command and cat command.
Instead of executing the command from terminal we will first store the commands in a text file and later execute that file. This is called shell script. Shell simply refers to terminal and script means command that do something. Thus, shell script is nothing just a bunch of commands written in a text file.
First let us create a file using cat utility with commands in that file:
We created a text file called shscriptexample and put three commands in that file. This file is now called script file.
How to execute script file:
The syntax for executing script file is:
As you can see, the result is same. The shell script makes the Linux shell more powerful. To perform specific task, you can create your own script file and execute that file. I am going to cover more tutorials on shell scripting.