How to run multiple commands in Linux SSH

To run multiple commands in Linux SSH, all we need a to write a Bash shell script. The shell script execute the commands based on the order in which commands have been written.

You can have loops, if else statements etc like any other programming.  For this post I am restricting myself to getting started with a shell script and run few commands.

Here are steps to create a simple Bash shell script.

Create an empty file using vim.

Enter Bash shell script identifier

Enter list of commands you want to run per line

I want to run some simple commands. here it is.

Escape from vim with saving shell script file

Press Esc Key on your PC and write down this. It will save the file and exit from vim editor.

Make this file executable

Finally execute your first shell Script

If all goes well then you will see and commands are executing in the order you have written in shell script. There are many tutorial sites on web from you can learn more about Bash shell scripting.

Related posts

Leave a Comment