Linux CentOS Shell Scripting Quick Start
How to Getting-Started Step-by-Step to Making and Executing a Bash Shell Script for CentOS GNU/Linux.
Shell Scripts are files in which we write a Sequence of Commands that we need to perform and are Executed using the Shell utility.
The Bash (Bourne Again Shell) is the Default Shell environment for most GNU/Linux system.
To Edit & Save our Bash Shell Script we’ll make Use of the Default GNU/Linux Shell Editor nano.
Open a Shell Terminal emulator window
(Press “Enter” to Execute Commands)
Or Login into the Server Shell.
Editing a Bash Script on Home Directory with nano
First we Change to our Home with
Then we Make the Bash Script with
To be Runnable directly as a Shell Script we append a Bash Shebang to the Top like
Then for Testing the Execution we should Insert a classic Hello-Word greating
echo 'Hello World!'
The ‘echo‘ Command simply Output a String on Terminal
So finally our simple Bash Script will be containing just
#!/bin/bash date echo 'Hello World!' echo 'From a Bash Shell Script :)'
The Sequence of Bash Commands must be a Stack of sigle Commands
myBashCommand1 myBashCommand2 ...
Or simply in a Line of Commands Divided by a ‘;’ SemiColon
myBashCommand1 ; myBashCommand2 ...
Ctrl+x to Save & Exit from nano Editor
Executing the Hello-World Bash Script
We Need to give the Execution Permissions with
chmod +x ./mybashscript.sh
Then to Run our little Bash Script simply
You’ll be nicely greeted on Shell with something like
Sun Jan 10 10:31:26 PST 2016 Hello World! From a Bash Shell Script :)
Tags: Bash, CentOS bash, CentOS bash scripting, CentOS command line, CentOS Shell, CentOS shell scripting, CentOS shell scripting quickstart, centos tutorial, Command line, gnu, gnu linux, gnu linux tutorial, Guide, How-to, linux command line, linux shell, Linux Tutorial, quickstart, run shell script CentOS, Shell, shell script, shell scripting, Tutorial