Bash Scripting

Bash scripting provides programming for the most popular operating system in the world. Linux is the most popular OS

Last updated 2022-01-10 | 3.5

- Bash Scripting
- Linux Programming
- Shell Scripting

What you'll learn

Bash Scripting
Linux Programming
Shell Scripting
Application Programming
Scripting
Cross Platform Development
Terminal Commands
Unix Commands
Command Prompts
Semantics of General Programming
The Format of Coding Applications
All The Features of Bash Scripting

* Requirements

* Passion For Learning Bash Scripting
* Basic Computer Knowledge and Skills
* Passion For Linux Programming
* Basic Knowledge of Computer Science Is Optional

Description

  • Bash Scripting
  • Linux Programming
  • Shell Scripting
  • Application Programming
  • Scripting
  • Cross Platform Development
  • Terminal Commands
  • Unix Commands
  • Command Prompts
  • Semantics of General Programming
  • The Format of Coding Applications
  • All The Features of Bash Scripting

Course content

9 sections • 67 lectures

Introduction Preview 02:20

Course introduction

Bash vs Shell vs Command Line vs Terminal Preview 05:44

Learn about the differences between Bash, Shell, Command Line and Terminal.

Listing Folder Contents (ls) Preview 04:36

Whenever it's required to take a look at the contents of a directory on the command line in Linux, ls is the command that's used. It lists the contents sorted in alphabetical order.

Print Current Folder (pwd) Preview 01:01

The pwd command, like ls and cd, is one of the most frequently used Linux utilities. Regardless of the kind of user you are (newbie or pro), you'll find yourself using this command line tool a lot. So in this tutorial, we will quickly discuss the basics of pwd through some easy to understand examples.

Change Folder (cd) Preview 03:28

The cd command is one of the most frequently used commands in Linux, as it's used to change directories (one of the most basic command line operations). While most users restrict themselves to the basic usage of cd, there are many other features the tool provides.

Using A Stack To Push Folders (pushd/popd) Preview 02:34

The pushd command stores a directory path in the directory stack while the popd command removes the top directory path from the same stack. In addition, both these commands make the directory being working on as your new working directory.

Check File Type (file) Preview 01:07

While working on the Linux command line, there may be times when you'd encounter a file which is an archive (say a .zip file), but its extension (or lack of it) would suggest otherwise. It's in times like these, the file command proves helpful as it lets you determine the actual file type.

Find File By Name (locate) & Update Locate Database (updatedb) Preview 02:27

While find is no doubt one of the most popular as well as powerful command line utilities for file searching in Linux, it not fast enough for situations where-in you need instantaneous results. If you want to search a file on your system through the command line, and speed is the top most priority, then there's another command that you can use: Locate.

Find A Command (which) Preview 02:04

The which command in Linux lets users know about the absolute path of command line tools.

Show Command History (history) Preview 01:36

If your work involves running tools and scripts on the Linux command line, I am sure there are a lot of commands you would be running each day. Those new to the command line should know there exists a tool - dubbed history - that gives you a list of commands you've executed earlier.

Quiz 1 - Navigation

Time to test your knowledge on navigation

Show Manual Descriptions (whatis) Preview 01:28

Man pages are one of the most useful resources when it comes to understanding command line utilities. A man page, however, contains a lot of details about the command. There may be times when you'd want to quickly know - may be in a small line or so - what a command line tool does. Well, you'll be glad to know there exists a command that's specifically built for this purpose.

Search Manual (apropos) Preview 01:38

In Linux, if you ever need help regarding a command, all you need to do is to open its man page. But what if a situation arises wherein the requirement is to quickly search the names and descriptions of all available man pages? Well, Linux has got your covered, as there exists a command dubbed apropos that does exactly this for you.

Reference Manuals (man) Preview 02:04

A very useful aspect of the Linux command line is that the documentation for almost all command line tools is easily accessible. These documents are known as man pages, and you can easily access them through the command line using the man command.

Quiz 2 - Getting Help

Time to test your knowledge on getting help for commands

Creating A Folder (mkdir) Preview 01:45

At any given time on the command line, you are in a directory. So it speaks for itself how integral directories are to the command line. In Linux, while the rm command lets you delete directories, it's the mkdir command that allows you create them in the first place.

Creating A File (touch) Preview 01:38

Sometimes, while working on the command line in Linux, you might want to create a new file. Or, there may be times when the requirement is to change the timestamps of a file. Well, there exists a utility that can you can use in both these scenarios. The tool in question is touch, and in this tutorial, we will understand its basic functionality through easy to understand examples.

Copy Files/Folders (cp) Preview 01:41

If you are new to Linux, it's worth knowing that command line is a very powerful tool, capable of doing almost all those tasks that you can do through the graphical interface. However, more often than not, you'll find yourself doing simple tasks on the command line. One such simple task is to copy files/directories.

Move & Rename Files/Folders (mv) Preview 02:12

Just like cp for copying and rm for deleting, Linux also offers an in-built command for moving and renaming files. It's called mv. In this article, we will discuss the basics of this command line tool using easy to understand examples.

Delete Files/Folders (rm) Preview 02:19

Deleting files is a fundamental operation, just like copying files or renaming/moving them. In Linux, there's a dedicated command - dubbed rm - that lets you perform all deletion-related operations. In this tutorial, we will discuss the basics of this tool along with some easy to understand examples.

Delete Empty Folder (rmdir) Preview 01:31

So we've already discussed the rm command that's primarily used for deleting files and directories from the Linux command line. However, there's another, related command line utility that is specifically aimed at removing directories. The tool in question is rmdir, and in this tutorial, we will discuss the basics of it using some easy to understand examples.

Change File Permissions (chmod) Preview 05:35

There are times when you create, say, a bash script on your Linux machine. But when you try running it, you get a permission error. What do you do? Simple, assuming you're on Ubuntu, right click on the file's icon, go to the 'Permissions' tab, and enable the 'Allow executing file as program' option.

Quiz 3 - Working With Files

Time to test your knowledge on working files

File Concatenation (cat) Preview 03:08

If you a regular Linux command line user, I am sure you must have used the cat command. The tool is mostly used for displaying contents of a file, although it provides many other small but useful features. In this article, we will discuss the cat command in detail, explaining some of its key features.

File Perusal Filter (more/less) Preview 01:49

Sometimes, while working on the command line, you'll see outputs produced by commands in certain cases are so large that they don't fit into the screen area, and hence, you get to see only the last part of the output (as the initial part scrolls past the screen). Thankfully, there are utilities that are specifically designed to help you in such cases.

Terminal Based Text Editor (nano) Preview 03:07

GNU nano is a text editor for Unix-like computing systems or operating environments using a command line interface. It emulates the Pico text editor, part of the Pine email client, and also provides additional functionality. Unlike Pico, nano is licensed under the GNU General Public License.

Quiz 4 - Text Files

Time to test your knowledge of using text files

Run Commands As A Superuser (sudo) Preview 02:47

Sudo (superuser do) is a utility for UNIX- and Linux-based systems that provides an efficient way to give specific users permission to use specific system commands at the root (most powerful) level of the system. Sudo also logs all commands and arguments.

Change User (su) Preview 02:38

The main work of the su command is to let you switch to some other user during a login session. In other words, the tool lets you assume the identity of some other user without having to logout and then login (as that user).

Show Effecter User and Group IDs (id) Preview 01:45

If you are new to system administration in Linux, you'll gradually learn that user management is an important aspect of your work. The Linux command line offers several command-line utilities for this purpose, and one of them is the id command.

Quiz 5 - Users

Time to test your knowledge on users

Kill A Running Command (ctrl + c) Preview 01:36

Ctrl + C is the interrupt signal. When you type this in a terminal, bash sends SIGINT to the job in the foreground.

Kill All Processes By A Name (killall) Preview 02:03

We've already discussed the kill command that you can use in case you want to terminate processes in Linux. However, there exists another command line utility that you can use for the same purpose: killall. In this tutorial, we will discuss the basics of this command using some easy to understand examples.

Logging Out Of Bash (exit) Preview 00:59

If you are a Linux newbie, and your work involves doing stuff through the command line, then it goes without saying that you must be spending a lot of time on the terminal window. As you'd likely agree, there are some commands that we tend to use very frequently, like ls, cp, and rm. However, there are some others that are comparatively less used. In this tutorial, we will discuss one such, less frequently used command: Exit.

Quiz 6 - Killing Programs & Logging Out

Time to test your knowledge for ending programs and logging out.

Tell Bash That There Is No More Input (ctrl + d) Preview 02:03

Ctrl D tells the terminal that it should register a EOF on standard input, which bash interprets as a desire to exit. Ctrl + D ( ^D ) means end of file.

Clear The Screen (ctr + l) Preview 01:36

Learn how to reduce clutter and clear the bash terminal screen.

Zoom In (ctrl + +) Preview 01:52

Learn how to zoom in on the bash terminal.

Zoom Out (ctrl + -) Preview 01:43

Learn how to zoom out in the bash terminal.

Moving The Cursor Preview 02:03

Learn about moving the cursor in the terminal for advanced navigation.

Deleting Text Preview 04:02

Learn about deleting text in the bash terminal.

Fixing Typos Preview 03:01

Learn about fixing typos in the bash terminal.

Cutting and Pasting Preview 02:50

Learn about cutting and pasting in the bash terminal.

Character Capitalisation Preview 02:34

Learn about capitalising characters in the bash terminal.

Quiz 7 - Shortcuts

Time to test your knowledge on shortcuts

Bash File Structure Preview 03:11

Learn about the basic structure of a bash file.

Echo Command Preview 03:35

In computing, echo is a command that outputs the strings it is being passed as arguments. It is a command typically used in shell scripts and batch files to output status text to the screen or a computer file, or as a source part of a pipeline.

Comments Preview 04:12

You should be aware of the fact that you might not be the only person reading your code. A lot of users and system administrators run scripts that were written by other people. If they want to see how you did it, comments are useful to enlighten the reader.

Comments also make your own life easier. Say that you had to read a lot of man pages in order to achieve a particular result with some command that you used in your script. You won't remember how it worked if you need to change your script after a few weeks or months, unless you have commented what you did, how you did it and/or why you did it.

Variables Preview 05:47

A variable in bash can contain a number, a character, a string of characters. You have no need to declare a variable, just assigning a value to its reference will create it.

Strings Preview 06:25

In computer programming, a string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. The latter may allow its elements to be mutated and the length changed, or it may be fixed (after creation). A string is generally considered as a data type and is often implemented as an array data structure of bytes (or words) that stores a sequence of elements, typically characters, using some character encoding. String may also denote more general arrays or other sequence (or list) data types and structures.

While Loop Preview 03:59

In most computer programming languages, a while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. The while loop can be thought of as a repeating if statement.

For Loop Preview 03:56

In computer science, a for-loop (or simply for loop) is a control flow statement for specifying iteration, which allows code to be executed repeatedly.

Until Loop Preview 03:19

Use DO UNTIL loops when a condition is not true and you want to execute the loop until the condition is true. The DO UNTIL loop tests the condition at the end of the loop and repeats only when the condition is false. Otherwise the loop executes once and ends.

Break & Continue Preview 02:48

When a break statement is encountered, it terminates the block and gets the control out of the switch or loop. When a continue statement is encountered, it gets the control to the next iteration of the loop. A break causes the innermost enclosing loop or switch to be exited immediately.

Get User Input Preview 01:33

User Input is one of the most important aspects of programming concepts. Every program should have some sort of user interaction, from getting a character's name for a game to asking for a password to log into a database.

If Statement Preview 09:21

IF Statement is one of the most popular instructions among the Decision Making statements. IF Statement gives the desired intelligence to a program, so that it can take decisions based on a criteria and most importantly decide the program flow.

Case Statements Preview 05:41

CASE Statement. The CASE statement chooses from a sequence of conditions, and executes a corresponding statement. The CASE statement evaluates a single expression and compares it against several potential values, or evaluates multiple Boolean expressions and chooses the first one that is TRUE.

Get Arguments From The Command Line Preview 04:22

Command line argument is a parameter supplied to the program when it is invoked.Command line argument is an important concept in programming. It is mostly used when you need to control your program from outside.

Functions Preview 05:13

In programming, a named section of a program that performs a specific task. In this sense, a function is a type of procedure or routine. Some programming languages make a distinction between a function, which returns a value, and a procedure, which performs some operation but does not return a value.

Global vs Local Variables Preview 02:32

Global variables are declared outside any function, and they can be accessed (used) on any function in the program. Local variables are declared inside a function, and can be used only inside that function. It is possible to have local variables with the same name in different functions.

Arrays Preview 06:06

In computer programming, an array is a set of data elements stored under the same name. Arrays can be created to hold any type of data, and each element can be individually assigned and read. There can be arrays of numbers, characters, sentences, boolean values, and so on.

Shell & Environment Variables Preview 05:35

Environment variables such as $SHELL are valid systemwide. In a current Bash shell, $BASH points to the execution path of bash, whereas $SHELL points to the shell defined as default (which may be of the same value). For an explanation of environment variables see Environment Variables in Ubuntu Help.

Scheduled Automation Preview 03:26

Their primary purpose is to generate build artifacts through activities like compiling and linking source code. Build-automation servers. These are general web based tools that execute build-automation utilities on a scheduled or triggered basis; a continuous integration server is a type of build-automation server.

Aliases Preview 03:22

Aliases. A Bash alias is essentially nothing more than a keyboard shortcut, an abbreviation, a means of avoiding typing a long command sequence. If, for example, we include alias lm="ls -l. more" in the ~/.bashrc file, then each lm [1] typed at the command-line will automatically be replaced by a ls -l.

Wildcards Preview 03:03

Alternatively referred to as a wild character or wildcard character, a wildcard is a symbol used to replace or represent one or more characters. The most common wildcards are the asterisk (*), which represents one or more characters and question mark (?) that represents a single character.

Multiple Commands Preview 02:25

Using Multiple Commands. Linux allows you to enter multiple commands at one time. The only requirement is that you separate the commands with a semicolon. Running the combination of commands creates the directory and moves the file in one line.

Quiz 8 - Bash

Time to test your knowledge of Bash