Linux Shell Scripting: A Project-Based Approach to Learning
4.5 (4,933 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
35,933 students enrolled

Linux Shell Scripting: A Project-Based Approach to Learning

Learn how to shell script through project-based training (Bash Scripting, Bash Programming, Sed, Grep, Awk, and More)
Bestseller
4.5 (4,933 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
35,933 students enrolled
Created by Jason Cannon
Last updated 7/2020
English
English [Auto], French [Auto], 8 more
  • German [Auto]
  • Indonesian [Auto]
  • Italian [Auto]
  • Polish [Auto]
  • Portuguese [Auto]
  • Romanian [Auto]
  • Spanish [Auto]
  • Thai [Auto]
Current price: $129.99 Original price: $199.99 Discount: 35% off
2 days left at this price!
30-Day Money-Back Guarantee
This course includes
  • 11.5 hours on-demand video
  • 8 articles
  • 10 downloadable resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Write your very own Linux shell scripts using the concepts you learned in this course.
Requirements
  • A basic understanding of the Linux command line.
  • The ability to download large files of about 500 MB from the Internet.
  • Access to a computer with a 64-bit processor running either Windows, Mac, or Linux. (You do NOT need Linux already installed to take this course.)
Description

Have you tried to learn shell scripting on your own, but lack the structure you need to really improve your skills?

Are you tired of picking up bits and pieces of information that you can't just seem to put together?

Do you learn best by doing?

If so, you're going to love this course.

One of the biggest complaints I hear from students is that most of the courses they've taken in the past simply provide information without any context and without any idea of how to put that information to use!  

This course turns that old, frustrating, and outdated way of learning on its head.  

It's project-based, which means instead of learning bits and pieces of information, you'll write actual shell scripts that you can use in real-world situations. You get the chance to immediately put what you learn to use so that you fully understand and remember it.

In this Linux shell scripting course you will learn how to:

  • Name your shell scripts.
  • Use the proper permissions on your shell scripts.
  • Create and use variables in your scripts.
  • Use shell built-in commands and operating system commands.
  • Make the most out of special variables that are available to you in your scripts.
  • Make decisions by using if statements and performing several different kinds of tests
  • Check the exit statuses of commands and why you need to.
  • Use cryptographic hash functions
  • Create random data so you can do things like automatically generate strong passwords for user accounts.
  • Perform the same action or set of actions over a series of data utilizing for loops, while loops, and infinite loops.
  • Control all types of input and output.
  • Accept standard input from a user as well as from another program.
  • Redirect standard output and standard error.
  • Combine standard output and standard error
  • Use command pipelining
  • Perform text and string manipulation.
  • Process command line arguments
  • Creating functions and when to do so.
  • Parsing, analyzing, and reporting on log files, CSV files, and other data.
  • Writing scripts that execute commands on other systems.
  • Much, much, more...

When you enroll, you get lifetime access to the course.  Your course never expires.  You can study at your own pace and refer back to the lessons whenever you want!

I stand behind my courses and care about your goals.  That's why this course comes with an unconditional 30-day money-back guarantee. It's my personal promise of your success!  So...

If you're ready to level-up your shell scripting skills, enroll now!

Who this course is for:
  • Linux system administrators, developers, programmers, or anyone who wants to learn Linux shell scripting.
Course content
Expand all 48 lectures 11:59:17
+ Course Introduction
2 lectures 04:33

Welcome to this Linux Shell Scripting course!

Preview 01:41

Download the shell scripting class files that include solutions to the exercises.

Course Downloads
02:52
+ Creating a Local Linux Shell Scripting Environment
7 lectures 01:09:48

How to create a local lab environment using Vagrant and VirtualBox.

Creating a Local Lab Environment Using Vagrant and VirtualBox - Background
16:28

Instructions for creating a local lab environment using Vagrant and VirtualBox.

Exercise 1 Instructions - Creating a Local Linux Shell Scripting Lab Environment
11:58

Note: Only use this lesson if you are using Windows as your operating system.  If you are not, proceed to the next lesson.

Learn how to install Vagrant and VirtualBox on Windows.

Exercise 1 – Walkthrough – Part I – Windows Users Only
04:18

Note: Only use this lesson if you are using Mac as your operating system.  If you are not, proceed to the next lesson.

Learn how to install Vagrant and VirtualBox on Mac.

Exercise 1 – Walkthrough – Part I – Mac Users Only
03:15

Note: Only use this lesson if you are using CentOS or Red Hat Enterprise Linux as your operating system.  If you not, proceed to the next lesson.

Learn how to install Vagrant and VirtualBox on CentOS/RHEL.

Exercise 1 – Walkthrough – Part I – Linux (CentOS/RHEL) Users Only
02:53

Note: This lesson is for everyone, no matter what operating system you are using.  (Windows, Mac, CentOS, RHEL)

Exercise 1 – Walkthrough – Part II – All Users
22:54

If you encountered errors with Vagrant or Virtualbox, use the strategies in this lesson to fix those issues.

Vagrant and VirtualBox Troubleshooting Tips
08:02
+ User and Account Creation - Shell Scripting Project 1
7 lectures 02:07:45
Section Introduction
02:47
Concepts covered in this lesson:
  • Naming shell scripts and file extensions.
  • Shell script file permissions and the chmod command.
  • Shebangs
  • Comments
  • Variables
  • Quoting – single vs double quotes.
  • Shell Builtins including echo, type, and help.
  • Displaying information to the screen with the echo shell builtin.
  • Getting help on shell builtins by using the help builtin.
  • Getting help on Linux commands by using the man command.
  • The touch command.



Getting Started with Shell Scripting: Naming, Permissions, Variables, Builtins.
35:02

Shell scripting concepts covered in this lesson:

  • Pseudocode and pseudocoding.

  • Special variables created by the shell including UID.

  • How to store the output of a command in a variable with command substitution.

  • The if statement.

  • The id command.

  • The whoami command.

  • How to read help and man pages.

  • Command options, order, and conventions.

  • Conditionals, operators, and expressions.

  • The [[, [, and, test shell builtins.

  • The command separator.

  • Exit statuses.

  • Piping output to the less pager.

  • Executing commands as root with the sudo command.

  • Using the su command to switch users.

  • Sanity and “idiot” checking.

Special Variables, Pseudocode, Command Substitution, if Statement, Conditionals.
23:14

Concepts covered in this lesson:

  • Exit status conventions.

  • Controlling the exit status of your shell script with the exit shell builtin.

  • Shell Special Variables.

  • Checking the return code or exit status of a command by examining the contents of the $? special variable.

  • String test conditionals.

  • DRY – Don’t Repeat Yourself.


Exit Statuses, Return Codes, String Test Conditionals, More Special Variables.
17:38

Shell scripting concepts covered in this lesson:

  • Getting input from the person executing the script using the read shell builtin.

  • Introduction to standard input, standard output, and standard error.

  • Creating accounts with the useradd command.

  • Username conventions including length, case, and valid characters.

  • Using the “-” or “-l” options to the su command to simulate a full login when switching users.

  • Controlling the default account creation behaviors by editing the /etc/login.defs file.

  • Using quotes to make a string that contains spaces behave as a single argument or item.

  • Setting passwords with the passwd command interactively and programmatically.

  • Using pipes to chain together multiple commands.

  • Expiring accounts with the passwd command

Reading Standard Input, Creating Accounts, Username Conventions, More Quoting.
23:26

The goal of this exercise is to create a shell script that adds users to the same Linux system as the script is executed on.

Exercise 2 - Instructions
04:16

The goal of this exercise is to create a shell script that adds users to the same Linux system as the script is executed on.

Exercise 2 - Walkthrough
21:22
+ Password Generation and Shell Script Arguments - Shell Scripting Project 2
5 lectures 01:41:39

Shell scripting concepts covered in this lesson:

  • Generating random data.

  • How to automate the creation of a random password.

  • The RANDOM shell builtin variable.

  • Event designators (shell shortcuts).

  • Display the current date and time using the date command in various formats.

  • Unix time, POSIX time, and epoch time.

  • Checksums and cryptographic hash functions.

  • The sha1sum and sha256sum commands.

  • Verifying downloads with checksums.

  • The head, fold, and shuf commands.

  • How to work through pipes. (Data munging, text manipulation, string manipulation.)

Random Data, Cryptographic Hash Functions, Text and String Manipulation.
31:01

Shell Scripting concepts covered in this lesson:

  • Positional parameters. ($0, $1, $2, $3, etc.)

  • The difference between arguments and parameters.

  • The which command.

  • The command search path and the PATH shell variable.

  • The hash shell builtin.

  • The basename and dirname commands.

  • Using command substitution within another command without assigning it to a variable first.

  • The for loop.

  • Special parameters including $#, $@, and $*.

Positional Parameters, Arguments, for Loops, Special Parameters
29:48

Shell scripting concepts covered in this lesson:

  • The while loop.

  • The true shell builtin.

  • The sleep command.

  • Creating and breaking out of infinite loops.

  • Send an interrupt signal by typing Ctrl-C.

  • The shift shell builtin.

The while Loop, Infinite Loops, Shifting, Sleeping
16:11
Exercise 3 - Instructions
04:32
Exercise 3 - Walkthrough
20:07
+ Linux Programming Conventions - Shell Scripting Project 3
4 lectures 56:01

Concepts covered in this lesson:

  • A deeper look at standard input, standard output, and standard error.
  • File descriptors.
  • Redirecting standard output to a file.
  • Redirecting standard error to a file.
  • Redirecting standard output and error to a file.
  • Redirecting standard input from a file.
  • Redirecting standard output and error through a pipe.
  • Redirecting standard error to standard output.
  • Redirecting standard output to standard error.
  • Overwriting and appending output to a file.
  • The null device.
Advanced Standard Input, Standard Output, and Standard Error - Part I
13:26

Concepts covered in this lesson:

  • A deeper look at standard input, standard output, and standard error.
  • File descriptors.
  • Redirecting standard output to a file.
  • Redirecting standard error to a file.
  • Redirecting standard output and error to a file.
  • Redirecting standard input from a file.
  • Redirecting standard output and error through a pipe.
  • Redirecting standard error to standard output.
  • Redirecting standard output to standard error.
  • Overwriting and appending output to a file.
  • The null device.
Advanced Standard Input, Standard Output, and Standard Error - Part II
25:45
Exercise 4 - Instructions
04:53
Exercise 4 - Walkthrough
11:57
+ Parsing Command Line Options – Shell Scripting Project 4
10 lectures 02:47:44

Learn how to use the "case" statement in your shell scripts.

Case Statements
19:56

Shell scripting concepts covered in this lesson:

  • Reasons to create functions

  • DRY vs WET programming concepts:

    • DRY: Don’t Repeat Yourself

    • WET: Write Everything Twice, We Enjoy Typing, Waste Everyone’s Time

  • Defining functions

  • Calling functions

  • Sending messages to the syslog subsystem with the logger command.

  • Where to place functions in your script.

  • Variable scope and the local shell builtin.

  • Passing in data to a function.

  • Making variables read-only with the readonly shell builtin.

  • How to backup files before you change them.

  • Exit status of functions and the return command.


Functions
33:09

Shell scripting concepts covered in this lesson:

  • How to accept and parse command line options.

  • Why getopts is better than using an if or case statement.

  • Performing mathematical calculations in your scripts.

  • Using the basic calculator: bc.


Parsing Command Line Options with getopts, Part 1
20:16

Learn how to use "getops" in your shell scripts.

Parsing Command Line Options with getopts, Part 2
17:34

Shell scripting concepts covered in this lesson:

  • Deleting users with the userdel command.

  • Expiring and locking accounts with the chage command.

  • How to find commands not in your PATH.

  • Using the locate and find commands.

  • Matching patterns with the grep command.

  • Using the !! and !$ event designators to speed up your workflow at the command line.

  • UID for system accounts and normal user accounts.

  • Creating and restoring backups and archives with the tar command.

  • How to compress files with gzip and uncompress them with gunzip.

  • Why not to lock accounts with the passwd command or by using the nologin shell.

Deleting and Disabling Linux Accounts, Part 1 of 4 (Finding Files)
11:23

Demonstration of the userdel and id commands.

Deleting and Disabling Linux Accounts, Part 2 of 4 (The userdel command)
05:06

Demonstration of the tar, gzip, and gunzip commands.

Deleting and Disabling Linux Accounts, Part 3 of 4 (Archives with tar)
13:37

Demonstration of using the chage, passwd, and usermod commands.

Deleting and Disabling Linux Accounts, Part 4 of 4 (Disabling Accounts)
08:08
Deleting Users – Exercise 5 – Instructions
05:48
Deleting Users – Exercise 5 – Walkthrough
32:47
+ Transforming Data / Data Processing / Reporting – Shell Scripting Project 5
6 lectures 01:35:28

In this lesson, you will learn how to use the "cut" and "awk" commands.

Cut and Awk
21:37

Demonstration of using the cut and awk commands.

Cut and Awk Demonstration Script: Open Network Ports
09:43

In this lesson, you will learn how to use the sort and uniq commands.

Sort and Uniq
18:05

In this shell scripting exercise, you'll be parsing data using the awk, cut, sort, and uniq commands.

The goal of this exercise is to create a shell script that displays the number of failed login attempts by IP address and location.

Parsing Log Files - Exercise 6 - Instructions
02:41
Parsing Log Files - Exercise 6 - Walkthrough
14:32

In this lesson, you will learn how to use sed.

Sed
28:50
+ Network Scripting & Automation of Distributed Systems: Shell Scripting Project 6
4 lectures 01:17:50

In this lesson you will learn how to create a small network of VMs that will simulate a company network.  You'll also learn how to configure ssh key authentication and execute commands on remote systems over ssh.

Configuring a Mini Network and Scripting for Remote Systems
30:10

The goal of this exercise is to create a shell script that executes a given command on multiple servers.

Scripting Remote Commands – Exercise – Instructions
09:19
Scripting Remote Commands – Walkthrough – Part 1
25:44
Scripting Remote Commands – Walkthrough – Part 2
12:37
+ Course Summary
1 lecture 07:46

This lesson is reminder of just some shell scripting concepts and techniques you've learned during this course.

Summary
07:46
+ Course Extras
1 lecture 09:38

In this lesson, you will learn:

  • What shell scripts are.

  • Why you should learn bash shell scripting.

  • How shell scripts can be helpful to you.

  • Shell scripting examples and use cases.

Preview 09:38