Linux Commands Training Course – Create and Run Linux Scripts to Run Multiple Commands at Once


You can easily automate the process of running many Linux commands so that you can run several commands at once – by creating and “running” a Linux script.

With a Linux script, you can take a series of routinely run commands, put them in a file and then run all of them at once by simply typing in the name of the file and pressing Enter.

A Linux script is similar in concept to a “macro” that you can create with some word processing, spreadsheet, and other software program – and scripts are very commonly used to do Linux System Administration tasks.

Linux Commands Training Tips: Using Linux scripts to automate commands is being describe here to demonstrate why you shouldn’t use Linux GUI utilities (unless you absolutely have to) – and to demonstrate another one of the great benefits of learning how to use commands – and to give you a “sneak preview” of how to create and run a script.

Creating a Linux Script to Automatically Run Several Linux Commands

A Linux text file is just a file that contains text (only) and does not have any formatting codes in it, such as bold and underline codes.

And a Linux “script” is a text file that has been made “executable” (so that it can be run, or “executed”), in the same way as you run a Linux command. You run the Linux chmod command “on” a text file that contains commands to make the text file executable.

A script contains a single line of text at the top (just this: #!/bin/bash) and then one or more lines below of commands that you need to have run automatically.

A script can also contain programming logic, and so creating a script is a type of Linux programming. Linux script programming logic, such as “if .. then” statements”, is used to determine if and when the commands in the script should be run.

A Linux script can be as simple as running a single command – or a script can be very complicated and include hundreds of lines of programming logic with hundreds of commands.

Linux Commands Training Tips: One of the great benefits of learning to use commands for Linux System Administration is that you can easily put commands in a script to automate routinely performed commands.

This allows you to do routine “basic” tasks and also do very complex Linux System Administration tasks – quickly and easily by simply typing in the name of a script and pressing Enter.

Knowing how to create Linux scripts to automate routine Linux System Administration tasks is a highly sought-after skill!


Leave a Reply