Bash Scripting on Linux (The Complete Guide) Class 01 - Course Introduction

Learn Linux TV
28 Nov 202211:10

Summary

TLDRWelcome to the Bash scripting course on Learn Linux TV, where you'll learn to automate repetitive tasks and harness the power of bash, a versatile command interpreter akin to a programming language. Instructor Jay, with over 20 years of Linux experience, guides you through foundational concepts to advanced scripting, covering variables, loops, conditionals, and more. Each episode is available for a comprehensive learning experience, aiming to turn you into a proficient bash scripter.

Takeaways

  • ๐Ÿ“ The course is designed to teach everything needed to write bash scripts for Linux administrators and DevOps professionals.
  • ๐Ÿ”„ Bash scripting automates the execution of repeated commands, saving time and effort.
  • ๐Ÿ›  Bash offers advanced features like if statements, while loops, and variables, making it almost a programming language.
  • ๐Ÿ“š The instructor, Jay, has over two decades of experience with Linux and scripting, and is the owner of Learn Linux TV.
  • ๐Ÿ“˜ Jay has written books, including 'Mastering Ubuntu Server', which can be found at www.ubuntuserverbook.com.
  • ๐ŸŽฅ The entire series of videos is available on YouTube for viewers to learn at their own pace.
  • ๐Ÿ”ข The course will cover foundational concepts like variables and math functions in bash, which are essential for scripting.
  • ๐Ÿ” The course will also delve into conditional statements, exit codes, loops, and other scripting constructs.
  • ๐Ÿ“ The importance of knowing where to save scripts on the Linux file system will be discussed to ensure easy access and organization.
  • ๐Ÿ” The course will explore data streams and functions to control data flow and script behavior.
  • ๐Ÿ—“๏ธ Scheduling jobs and understanding arguments for scripts will be covered to enhance script utility and flexibility.

Q & A

  • What is the main purpose of writing bash scripts according to the video?

    -The main purpose of writing bash scripts is to automate the execution of a series of commands that are run repeatedly, thus saving time and effort for Linux administrators or DevOps professionals.

  • Why might someone consider bash scripting similar to a programming language?

    -Bash scripting might be considered similar to a programming language because it offers features like if statements, while loops, and the ability to use variables, which are common in programming languages.

  • What does the instructor claim about the episodes of the bash scripting course?

    -The instructor claims that every single episode of the bash scripting course is already uploaded on YouTube, allowing viewers to watch them all at once or take their time learning the concepts.

  • What is Jay's professional background, and how does it relate to the course?

    -Jay is the owner of Learn Linux TV, an education company specializing in Linux. He has over two decades of experience with Linux and has held various positions in system administration, network administration, DevOps management, and other roles. His extensive background in Linux makes him well-suited to teach the course.

  • What is the significance of the 'hello world' script in the context of the course?

    -The 'hello world' script is significant as it is traditionally the first example taught in programming and scripting languages, and the course follows this tradition by starting with it.

  • Why are variables covered early in the course?

    -Variables are covered early in the course because they are a foundational concept in scripting, and they will be used in many of the lessons throughout the course.

  • What is the role of exit codes in bash scripting?

    -Exit codes in bash scripting indicate whether a command or script was successful. They help administrators understand the result of a script and take appropriate action based on that result.

  • What is the purpose of while loops in the course?

    -While loops are used in the course to teach how to write scripts that monitor for a file or other criteria to decide whether the script should continue running or exit, providing control over script execution.

  • What does the update script example in the course demonstrate?

    -The update script example demonstrates how to keep servers up to date and serves as a recurring example in several videos throughout the course.

  • What is the focus of the class on scheduling jobs?

    -The focus of the class on scheduling jobs is to teach how to schedule tasks to run at specific times or under certain conditions, which is a two-part class in the course.

  • What additional resources does the instructor offer for further learning?

    -The instructor offers his latest book, 'Mastering Ubuntu Server', as an additional resource for further learning, which can be found at www.ubuntuserverbook.com or by searching for the book on Amazon.

  • What are the technical requirements to follow along with the course?

    -The technical requirements to follow along with the course include having a computer with a terminal and access to a Linux server or a Linux installation, which can be a virtual machine, a spare server, or even a personal computer running Linux.

Outlines

00:00

๐Ÿ“š Introduction to Bash Scripting Course

In this introductory paragraph, the speaker welcomes viewers to the Learn Linux TV course on Bash scripting. The purpose of the course is to teach the essentials of writing Bash scripts, which are useful for automating repetitive command sequences in Linux administration and DevOps roles. The speaker emphasizes the efficiency of scripting over manual command execution and introduces the concept of Bash as a programming language with features like if statements and loops. The course content is outlined, promising to take viewers from basics to advanced scripting, with all episodes available for immediate viewing. The speaker also introduces himself as Jay, an experienced Linux professional and owner of Learn Linux TV, and mentions his book 'Mastering Ubuntu Server'.

05:01

๐Ÿ” Course Content and Prerequisites

This paragraph delves into the specifics of the course content, starting with the creation of a 'Hello, World' script, a traditional first step in programming and scripting education. The course will cover foundational topics like variables, math functions, and control structures such as if statements and loops. It will also explore exit codes, data streams, functions, and case statements, leading up to creating a practical backup script. The speaker outlines the lessons, emphasizing the importance of understanding where to save scripts and how to pass arguments to them. The course concludes with a look at job scheduling and่ต„ๆบๆ•ดๅˆ. The paragraph concludes with the prerequisites for the course, which include a computer with terminal access and a Linux installation, suggesting that viewers can use the channel's resources to set up Linux if needed.

10:02

๐Ÿš€ Getting Started with Bash Scripting

The final paragraph serves as a call to action, encouraging viewers to begin their journey in learning Bash scripting. The speaker reiterates the availability of all course videos for immediate viewing and invites viewers to proceed to the next episode. The paragraph wraps up with a thank you note to the viewers and an expression of enthusiasm for teaching the upcoming lessons. The speaker also hints at the wealth of Linux-related content available on the channel, positioning it as a valuable resource for those new to Linux or needing assistance with installation.

Mindmap

Keywords

๐Ÿ’กBash

Bash, short for 'Bourne Again SHell', is a Unix shell and command language that allows users to interact with the operating system. In the context of this video, Bash is presented as a scripting language for automating tasks on Linux systems. The script is a series of commands saved in a text file that can be executed as a single entity, which is central to the theme of the video.

๐Ÿ’กScripting

Scripting refers to the process of writing scripts, which are sequences of instructions that automate tasks. In the video, the instructor emphasizes the importance of scripting for Linux administrators and DevOps professionals to automate repetitive tasks, thus enhancing efficiency and reducing manual labor.

๐Ÿ’กAutomation

Automation is the use of control systems to operate equipment such as machinery, processes in a factory, or more broadly, the creation of a process that functions with minimal human intervention. The video discusses the automation of command execution as a key benefit of using Bash scripts, eliminating the need to manually run the same set of commands repeatedly.

๐Ÿ’กLinux Administrator

A Linux Administrator is a professional who manages Linux servers and systems. They are responsible for maintaining the stability, performance, and security of the servers. In the script, the instructor addresses Linux administrators as the primary audience for the course, indicating that scripting skills are essential for their role.

๐Ÿ’กDevOps

DevOps is a set of practices that combines software development (Dev) and IT operations (Ops) to shorten the system development lifecycle and provide continuous delivery of high-quality software. The video mentions DevOps professionals as the target audience, suggesting that Bash scripting is a valuable skill in the DevOps toolkit.

๐Ÿ’กVariables

In programming and scripting, variables are used to store data that can be used or manipulated within a script. The video explains that variables are a foundational concept in Bash scripting, allowing scripts to adapt to different conditions by using stored information.

๐Ÿ’กIf Statements

If statements are conditional expressions that allow scripts to execute different blocks of code based on whether a certain condition is true or false. The video introduces if statements as a way to introduce branching in scripts, enabling decision-making within the script's execution.

๐Ÿ’กLoops

Loops are programming structures that repeat a block of code until a specified condition is met. The video mentions 'while loops' as a feature in Bash scripting that allows scripts to continuously check for certain conditions, such as the presence of a file, before deciding to continue or exit.

๐Ÿ’กExit Codes

Exit codes are values returned by a command or script to indicate its success or failure. In the video, the instructor explains the importance of exit codes for administrators to understand the result of a script or command execution, which is crucial for troubleshooting and automation.

๐Ÿ’กFunctions

Functions in scripting are reusable blocks of code that perform a specific task. The video mentions functions as a part of the course, suggesting that they are an important concept for creating modular and organized scripts in Bash.

๐Ÿ’กScheduling Jobs

Scheduling jobs refers to the automation of tasks that are set to run at specified times or under certain conditions. The video includes a class on scheduling jobs, indicating that this is a key aspect of Bash scripting for automating routine tasks on Linux systems.

๐Ÿ’กArguments

Arguments in scripting are values passed to a script when it is executed, allowing the script to be dynamic and adaptable to different inputs. The video discusses how to pass arguments to a script, which is essential for creating flexible and reusable scripts.

๐Ÿ’กBackup Script

A backup script is a specific type of script designed to create copies of data for the purpose of recovery in case of data loss. The video mentions creating a backup script as a culmination of the course, integrating various concepts learned throughout the series to create a practical tool for server backup.

Highlights

Introduction to a new bash scripting course aimed at teaching everything needed to write bash scripts.

Rationale for writing bash scripts: automating repetitive command execution for efficiency.

Bash scripting's capabilities beyond simple command execution, including conditionals and loops.

Bash's role as a command interpreter or shell with programming language-like features.

Course structure includes an overview and subsequent deep dives into specific bash scripting topics.

Availability of the entire course series on YouTube for self-paced or binge-watching learning.

Instructor Jay's introduction, sharing his extensive experience with Linux and scripting.

Jay's professional background in system administration, network administration, and devops management.

Jay's passion for creating educational content and his latest book 'Mastering Ubuntu Server'.

Course outline detailing the topics covered in each class, starting with a 'Hello, World' script.

Importance of understanding variables as a foundational concept in scripting.

Exploration of math functions in bash and their unique handling compared to other languages.

Introduction to if statements and branching in scripts for decision-making capabilities.

Understanding exit codes as indicators of script or command success.

Utilization of while loops for scripts that monitor conditions to determine execution flow.

Creating an update script as a recurring example to demonstrate scripting concepts.

For loops as a tool for iterating over sequences in bash scripts.

Discussion on where to save scripts in the Linux filesystem for easy access and organization.

Data streams' role in controlling the flow of data within scripts.

Functions in bash scripting for modular and reusable code segments.

Case statements for creating user-selectable menus within scripts.

Scheduling jobs as a two-part class on automating script execution at specified times.

Using arguments to pass information to scripts for dynamic execution.

Creating a comprehensive backup script integrating various course concepts.

Course conclusion with additional resources for further learning and script development.

Prerequisites for the course, including a computer with terminal access and a Linux installation.

Recommendation to use the instructor's YouTube channel for additional Linux installation guidance.

Transcripts

play00:07

thank you

play00:10

hello and welcome back to learn Linux TV

play00:13

and also welcome to my brand new bash

play00:16

scripting course in this series what I'm

play00:18

going to do is teach you everything that

play00:20

you need to know in order to get up and

play00:22

running when it comes to writing bash

play00:24

scripts but you might be thinking why

play00:26

exactly would I want to write a bash

play00:28

script

play00:29

well we as Linux administrators or

play00:32

devops professionals are going to be

play00:34

running quite a few commands and

play00:35

eventually we're going to run into a

play00:37

situation where we have a series of

play00:39

commands that we need to run every now

play00:41

and then but if we're going to be

play00:43

running the same set of commands over

play00:45

and over again then why not automate it

play00:48

why would we want to manually run those

play00:50

commands every time we go to complete

play00:51

that task

play00:53

and that's where bash scripting comes in

play00:55

at its lowest form bash scripting is

play00:58

just a way to have a bunch of commands

play00:59

run one after another commands that you

play01:02

save in a text file and then execute as

play01:04

a script but that's not all that you

play01:05

could do in bash bash has all kinds of

play01:07

cool features such as if statements

play01:10

while Loops the ability to have

play01:12

variables and if I didn't know any

play01:13

better I would say based on that

play01:15

description it almost sounds like bash

play01:16

is a programming language well if you're

play01:19

thinking about bash in terms of a

play01:20

programming language you're not actually

play01:22

far off now to be fair bash is actually

play01:25

a command interpreter or a shell that we

play01:28

use on our Linux or Unix systems but

play01:30

don't let the term interpreter fool you

play01:31

bash is basically a programming language

play01:34

and the scripts that you could write

play01:35

within bash are really awesome and

play01:38

you're going to see examples of that in

play01:40

this series so what I'm going to do in

play01:42

this video is introduce the course and

play01:44

tell you all about it and then in each

play01:46

video from here on out we're going to

play01:48

learn more and more about bash scripting

play01:50

and by the end of this series you're

play01:51

going to be a pro when it comes to

play01:53

writing bash scripts and I can't wait to

play01:55

teach you guys about bash scripting this

play01:57

is going to be a ton of fun in fact

play02:00

every single episode in this series is

play02:02

already on YouTube right now that's

play02:04

right every single episode has been

play02:06

uploaded at the exact same time if you

play02:09

want to binge watch this series you can

play02:10

go right ahead and do so but then again

play02:12

it might be better to slow it down a bit

play02:14

and take your time and make sure that

play02:16

you're learning all of the concepts

play02:17

either way every video in this series is

play02:20

going to be right there waiting for you

play02:22

whenever you're ready for it anyway like

play02:24

I mentioned earlier in this video what

play02:25

I'm going to do is introduce the course

play02:27

so let's go ahead and switch gears and

play02:29

I'll give you an overview of what you'll

play02:31

expect to find in this course

play02:33

[Music]

play02:38

so at this point I'll tell you guys a

play02:40

little bit more about myself

play02:42

first of all my name is Jay nice to meet

play02:44

you

play02:45

now I've been working with Linux for

play02:47

over two decades it's literally my

play02:49

favorite technology and writing scripts

play02:51

has definitely helped me along my career

play02:53

and I'm sure it'll help you and yours as

play02:55

well

play02:56

now professionally I am the owner of

play02:58

learn Linux TV an education company that

play03:01

specializes in Linux

play03:03

before learn Linux TV became my only gig

play03:06

I've held positions in system

play03:08

administration Network Administration

play03:10

devops Management and other roles as

play03:14

well I Love Leading people leading teams

play03:16

and I also love technology so my career

play03:19

has been very good to me in addition to

play03:21

creating educational videos I also write

play03:23

books as well my latest book as of the

play03:26

time I'm recording the series is

play03:28

mastering Ubuntu Server if you want to

play03:30

check it out you could go to

play03:33

www.ubuntuserverbook.com and that domain

play03:35

will actually take you to whatever the

play03:38

current version of that book happens to

play03:39

be at any one time now before you

play03:42

actually visit that domain I want to

play03:44

point out that what it'll do is take you

play03:46

to the United States store for the book

play03:48

on Amazon and if you live in a different

play03:50

country then what you'll want to do

play03:52

instead is go to amazon.com and search

play03:55

for mastering Ubuntu Server you can do

play03:57

that on your version of Amazon for your

play04:00

country and once you do that you should

play04:02

be able to order the book from an Amazon

play04:03

site that is closer to your geographic

play04:06

location anyway I love Linux it's my

play04:09

favorite technology and I love creating

play04:11

educational content around Linux so you

play04:14

know what I couldn't possibly be in a

play04:15

better place when it comes to my career

play04:17

because I'm doing what I love I love

play04:19

teaching I love technology okay so it

play04:22

all works out

play04:23

now let's go ahead and take a look at

play04:25

the outline for this course

play04:27

the first class will serve as the

play04:29

introduction and welcome and I would

play04:31

love to tell you what we're going to do

play04:33

in that class but we're already doing it

play04:35

you are actually watching that video

play04:37

right now

play04:38

in the next video what we're going to do

play04:40

is write our very first bash script and

play04:43

specifically we will create a hello

play04:45

world script and that's because in well

play04:48

pretty much any programming language as

play04:50

well as scripting languages the hello

play04:51

world example is usually the first thing

play04:54

that instructors teach you and I am not

play04:56

going to break that tradition in the

play04:57

series

play04:58

in class number three we are going to

play05:01

explore variables variables allow us to

play05:04

well save information for later

play05:06

in addition we could use variables to

play05:09

make our scripts change depending on

play05:11

what variables equal and the reason why

play05:13

we're going to cover variables early in

play05:15

this course is because it's a very

play05:17

important foundational concept we will

play05:19

be using variables in quite a few of the

play05:22

lessons so it's a good idea to get that

play05:24

out of the way early in the course class

play05:26

number four we're going to take a look

play05:28

at math functions for example how do you

play05:31

add subtract or multiply numbers in bash

play05:34

now you might already be familiar with

play05:36

how to perform math functions in a

play05:38

programming language perhaps another

play05:40

scripting language however math

play05:42

functions are actually a bit different

play05:44

in bash so we definitely want to make

play05:46

sure that we take a look at that

play05:48

continuing in class number five we're

play05:50

going to take a look at if statements

play05:52

and that'll also be our first look at

play05:54

branching basically we can have a script

play05:57

that does something different depending

play05:59

on some other criteria a test case if

play06:02

you will and that allows us to make

play06:04

decisions within scripts and that's

play06:06

definitely an important aspect to cover

play06:08

and continuing on from there in class

play06:10

number six what we'll do is take a look

play06:13

at Exit codes

play06:14

every command and every script is going

play06:17

to have an exit code and that helps you

play06:19

as the administrator understand if a

play06:21

script or command was successful and

play06:24

knowing that will help you take action

play06:25

based on the result

play06:27

class number seven is all about while

play06:30

loops and that helps us write scripts

play06:32

that are watching for a file or some

play06:34

other criteria to understand whether or

play06:36

not that script should be running or if

play06:38

it should exit we have full control over

play06:40

that so that's what we'll explore in

play06:42

class number seven

play06:43

in class number eight we're going to

play06:45

take a little break from branching and

play06:47

take our first look at an update script

play06:49

and that particular script is going to

play06:51

serve as an example in several videos

play06:53

going forward so that's the first time

play06:55

that we'll take a look at that and that

play06:57

update script will help us keep our

play06:58

servers up to date

play07:00

in class number nine we will return to

play07:02

branching this time taking a look at for

play07:05

Loops in class number 10 we will answer

play07:07

the question where should I save my

play07:09

scripts and the reason that question

play07:11

even comes up is because there's quite a

play07:13

few directories in the Linux file system

play07:15

and although we don't need to understand

play07:17

the purpose of every directory on the

play07:19

Linux file system it is important to

play07:22

understand which directories actually

play07:23

pertain to scripts and that'll help us

play07:25

answer where we should save our scripts

play07:27

for later use

play07:29

continuing into class number 11 we'll

play07:32

take a look at data streams basically

play07:34

standard input standard output as well

play07:36

as standard error data streams

play07:38

themselves allow us to control the flow

play07:40

of data in our scripts and that gives us

play07:43

even more options

play07:44

in class 12 we'll take a look at

play07:46

functions and that one's going to be a

play07:48

lot of fun

play07:49

class number 13 is all about case

play07:52

statements and this essentially allows

play07:54

us to create a menu from which the user

play07:56

can actually select an option and then

play07:59

the script responds accordingly

play08:01

in class number 14 we take our first

play08:03

look at scheduling jobs so this class is

play08:07

part one of a two-part class that goes

play08:09

over exactly that

play08:11

in class 15 we continue our look at

play08:13

scheduling jobs

play08:15

in 16 we'll take a look at arguments

play08:17

specifically how to pass arguments to a

play08:19

script and in class number 17 that's

play08:22

where a majority of what we've learned

play08:24

in this course will all come together

play08:26

because we will use quite a few of the

play08:29

concepts when we create a backup script

play08:31

and that backup script is going to be

play08:33

something that you can actually use to

play08:35

back up your servers and after we do

play08:37

that class number 18 is going to be our

play08:40

closing that's where we'll wrap

play08:41

everything up and I will also give you

play08:44

some additional resources that you can

play08:46

use to extend your knowledge even

play08:48

further

play08:49

foreign

play08:54

to get started and I hope you are we're

play08:57

going to have a lot of fun but you might

play08:59

be wondering what exactly do I need in

play09:01

order to follow along with this course

play09:03

well the first thing you're going to

play09:04

need is a computer obviously you can't

play09:07

really write bash scripts on a toaster

play09:08

actually I probably need to walk that

play09:10

statement back considering that iot

play09:12

devices often run Linux and they

play09:14

probably run scripts too so if you have

play09:16

an iot toaster well it could probably

play09:18

run bash scripts but in this course what

play09:20

we're going to do is just use a computer

play09:22

and you'll also need a terminal as well

play09:24

in Windows it's built in in Mac OS it's

play09:27

built in and also on Linux distributions

play09:30

it's built in so regardless of what kind

play09:32

of computer that you have you should be

play09:34

in good shape in addition to that what

play09:35

you'll need is a Linux server or some

play09:37

kind of Linux installation that you

play09:39

could log into so what you can do for

play09:41

that is spin up Linux in a virtual

play09:42

machine maybe a spare server or maybe

play09:45

even your desktop or laptop if that

play09:46

already runs Linux then well you have

play09:48

everything you need but that's about it

play09:51

if you have a computer and you have the

play09:52

ability to to spin up a Linux

play09:54

installation you should be good to go

play09:55

but if you don't actually have a Linux

play09:58

installation all set up and you have no

play10:00

idea how to get one set up do I have the

play10:02

YouTube channel for you in fact you're

play10:04

watching it right now the last time I

play10:06

checked there was almost a thousand

play10:07

videos on this channel and I'm probably

play10:09

over that at this time so there's going

play10:11

to be no shortage of content on this

play10:13

channel that you can use to get up and

play10:14

running with Linux in fact you can check

play10:16

out any of the videos that I already

play10:17

have that tell you how to install Linux

play10:19

and you should be good to go anyway I

play10:21

can't wait to get started and teach you

play10:23

guys bash scripting this course is going

play10:24

to be a ton of fun so this is the end of

play10:27

this particular video right here but

play10:29

like I mentioned earlier every video in

play10:30

this series is already on this channel

play10:32

so you can watch the next episode

play10:33

anytime you'd like to do so in fact why

play10:36

don't you go ahead and meet me there

play10:37

right now in the meantime thank you guys

play10:39

for watching this particular video and

play10:41

I'll see you in the next video

play10:44

[Music]

play10:56

thank you

play10:58

[Music]

Rate This
โ˜…
โ˜…
โ˜…
โ˜…
โ˜…

5.0 / 5 (0 votes)

Related Tags
Bash ScriptingLinux AdminDevOpsScript AutomationCommand SeriesProgramming LanguageEducational SeriesScript VariablesLoopsFunctionsLinux Server