Introduction to Bash for Beginners

Introduction to Bash for Beginners

Bash is an acronym of “Bourne-Again Shell”. Bash is an automation powerhouse for UNIX based systems. In UNIX and Linux based operating systems, a terminal window is consist of a shell and Bash. Bash is the powerhouse of these systems, which includes Linux distributions as well as MacOS among others. Learning bash can be super useful to perform automation.

Bash is an automation powerhouse for UNIX based systems, let’s learn it together.

Bash is an acronym of “Bourne-Again Shell”. It is a default command-line interpreter for UNIX and Linux based operating systems. In UNIX and Linux based operating systems, a terminal window is consist of a shell and Bash.

Bash is the powerhouse of these systems, which includes Linux distributions as well as MacOS among others. Learning bash can be super useful to perform automation. I’m someone who is always installing a new OS, and setting all my configs and programs manually each time can be super painful, but thanks to a few bash commands that I created I can fully automate the procedure.

Using bash I can install software, download configs from the net, set up configurations for my desktop, and much more.

Bash is super powerful and has lots of features. Today I’m going to present a few commands and statements that will help you automate a good deal of actions.


Bash shell scripting guide

For the bash shell scripting, we need to use the shell and the text editor. The extension of the shell scripting file is .sh. To create a new scripting file, create a text file, and save it with .sh file extension. I am using Ubuntu 20.04 for the demonstration and creation of Bash scripting files. The gedit is the default text editor for Ubuntu and many Linux based operating systems.

Let’s create a new file myscript.sh.

Create myscript.sh file

To execute the bash scripting file, first we need to change the permissions of the file and make it executable. The permission are changed by chmod +x command. In order to make the bash scripting file executable, you have to open up your terminal and navigate to the folder or directory where the file is stored, and execute the following command.

chmod +x filename

Now let’s execute:

chmod +x myscript.sh command.

Give the file execution rights

Execution of bash script file:

The bash script file can be executed in two ways:

  1. bash filename
  2. ./filename

To execute the bash file, navigate to the folder or directory where the bash file is saved. In the first way of execution simply write bash and then the filename on the terminal and hit enter. The bash script file will be executed.

In the second way, write “./filename” on the terminal and press enter. We will use the second way for executing the bash file throughout this tutorial.

In this basic guide of bash scripting, we will cover the following things:

  1. Echo command
  2. Comments in bash scripting file
  3. ls command
  4. Variables declaration and usage
  5. Conditional statement
  6. Loops in Bash

bash linux ubuntu programming developer

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Hire Dedicated Linux Developer

Looking to develop real-time applications? **[Hire Dedicated Linux Developer](https://hourlydeveloper.io/hire-dedicated-linux-developer/ "Hire Dedicated Linux Developer")** from **[HourlyDeveloper.io](https://hourlydeveloper.io/...

10 Best Ubuntu-based Linux Distributions

Ubuntu is arguably one of the most popular and widely-used Linux distribution owing to its classic UI, stability, user-friendliness, and a rich repository that contains over 50,000 software packages. Furthermore, it comes highly recommended for beginners who are trying to give a shot at Linux.

How long does it take to develop/build an app?

This article covers A-Z about the mobile and web app development process and answers your question on how long does it take to develop/build an app.

Developer Career Path: To Become a Team Lead or Stay a Developer?

For a developer, becoming a team leader can be a trap or open up opportunities for creating software. Two years ago, when I was a developer, ... by Oleg Sklyarov, Fullstack Developer at Skyeng company

How to Install Microsoft Teams on Ubuntu 20.04

In this tutorial, we will show you how to install Microsoft Teams on Ubuntu 20.04 machine. we can install teams using Debian installer file or by adding microsoft repository.