How to run multiple linux command at same time

 


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.

 

 

Way 1:

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

1

command; command; command; command

executing multiple commands

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.

 

 

Way 2:

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:

create a file using cat utility

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:

sh filename

1

sh filename

executing script file

Advertisements