├── README.md ├── docs ├── 01-Course-Introduction │ └── 01-Course-Introduction.md ├── 02-Shell-Scripting-Introduction │ ├── 01-Project-Introduction.md │ ├── 02-Lab-Project-Introduction.md │ ├── 03-Creating-your-first-shell-script.md │ ├── 04-Lab-Creating-Your-First-Shell-Script.md │ ├── 05-Variables.md │ ├── 06-Lab-Variables.md │ ├── 07-Download-Course-Material.md │ ├── 08-Command-Line-Arguments.md │ ├── 09-Read-Inputs.md │ ├── 10-Lab-Command-Line-Arguments-and-Inputs.md │ ├── 11-Arithmetic-Operations.md │ └── 12-Lab-Arithmetic-Operations.md ├── 03-Flow-Control │ ├── 01-Conditional-Logic.md │ ├── 02-Lab-Conditional-Logic.md │ ├── 03-Loops-For.md │ ├── 04-Lab-For-Loops.md │ ├── 05-Loops-While.md │ ├── 06-Lab-While.md │ ├── 07-Case-Statements.md │ └── 08-Lab-Case-Statements.md ├── 04-Shebang │ ├── 01-Shebang.md │ ├── 02-Lab-Shebang.md │ ├── 03-Exit-Codes.md │ ├── 04-Lab-Exit-Codes.md │ ├── 05-Functions.md │ ├── 06-Lab-Functions.md │ └── 07-Tips&Tricks-ShellCheck-&-IDE.md └── 05-Project-E-Commerce-Application │ ├── 01-E-Commerce-Application-Introduction.md │ ├── 02-Demo-E-Commerce-Application.md │ ├── 03-Project-Hands-On.md │ └── deploy-ecommerce-application.sh └── images ├── README.md ├── b.PNG ├── ba.PNG ├── bash.PNG ├── bc.PNG ├── best-cla.PNG ├── best-var.PNG ├── best.PNG ├── cb.PNG ├── cl.PNG ├── cla-ri.PNG ├── cla.PNG ├── cla1.PNG ├── co.PNG ├── cond.PNG ├── cond1.PNG ├── create-script.PNG ├── cs.PNG ├── cs1.PNG ├── dash.PNG ├── dm.PNG ├── dm1.PNG ├── dp.PNG ├── e0.PNG ├── e1.PNG ├── ecomm.PNG ├── ecomm1.PNG ├── ecomm2.PNG ├── el.PNG ├── elif.PNG ├── exec-sh.PNG ├── exit.PNG ├── expr.PNG ├── f.PNG ├── for.PNG ├── fu.PNG ├── ht.PNG ├── id.PNG ├── if.PNG ├── lseq.PNG ├── o.PNG ├── obj.PNG ├── re.PNG ├── real.PNG ├── ri.PNG ├── rl.PNG ├── rs.PNG ├── run-sh.PNG ├── s.PNG ├── var.PNG ├── var1.PNG ├── vi.PNG └── wh.PNG /README.md: -------------------------------------------------------------------------------- 1 | # The Linux Basics Course 2 | 3 | These are notes from the [Shell Scripting for Beginners](https://kodekloud.com/courses/shell-scripts-for-beginners/) hosted on KodeKloud. 4 | 5 | # Sections 6 | 7 | - [01-Course-Introduction](docs/01-Course-Introduction) 8 | - [01-Course-Introduction](docs/01-Course-Introduction/01-Course-Introduction.md) 9 | 10 | - [02-Shell-Scripting-Introduction](docs/02-Shell-Scripting-Introduction) 11 | - [01-Project-Introduction](docs/02-Shell-Scripting-Introduction/01-Project-Introduction.md) 12 | - [02-Lab-Project-Introduction](docs/02-Shell-Scripting-Introduction/02-Lab-Project-Introduction.md) 13 | - [03-Creating-your-first-shell-script](docs/02-Shell-Scripting-Introduction/03-Creating-your-first-shell-script.md) 14 | - [04-Lab-Creating-Your-First-Shell-Script](docs/02-Shell-Scripting-Introduction/04-Lab-Creating-Your-First-Shell-Script.md) 15 | - [05-Variables](docs/02-Shell-Scripting-Introduction/05-Variables.md) 16 | - [06-Lab-Variables](docs/02-Shell-Scripting-Introduction/06-Lab-Variables.md) 17 | - [07-Download-Course-Material](docs/02-Shell-Scripting-Introduction/07-Download-Course-Material.md) 18 | - [08-Command-Line-Arguments](docs/02-Shell-Scripting-Introduction/08-Command-Line-Arguments.md) 19 | - [09-Read-Inputs](docs/02-Shell-Scripting-Introduction/09-Read-Inputs.md) 20 | - [11-Arithmetic-Operations](docs/02-Shell-Scripting-Introduction/11-Arithmetic-Operations.md) 21 | - [12-Lab-Arithmetic-Operations](docs/02-Shell-Scripting-Introduction/12-Lab-Arithmetic-Operations.md) 22 | 23 | - [03-Flow-Control](docs/03-Flow-Control) 24 | - [01-Conditional-Logic](docs/03-Flow-Control/01-Conditional-Logic.md) 25 | - [02-Lab-Conditional-Logic](docs/03-Flow-Control/02-Lab-Conditional-Logic.md) 26 | - [03-Loops-For](docs/03-Flow-Control/03-Loops-For.md) 27 | - [04-Lab-For-Loops](docs/03-Flow-Control/04-Lab-For-Loops.md) 28 | - [05-Loops-While](docs/03-Flow-Control/05-Loops-While.md) 29 | - [06-Lab-For-Loops](docs/03-Flow-Control/06-Lab-While.md) 30 | - [07-Case-Statements](docs/03-Flow-Control/07-Case-Statements.md) 31 | - [08-Lab-Case-Statements](docs/03-Flow-Control/08-Lab-Case-Statements.md) 32 | 33 | - [04-Shebang](docs/04-Shebang) 34 | - [01-Shebang](docs/04-Shebang/01-Shebang.md) 35 | - [02-Lab-Shebang](docs/04-Shebang/02-Lab-Shebang.md) 36 | - [03-Exit-Codes](docs/04-Shebang/03-Exit-Codes.md) 37 | - [04-Lab-Exit-Codes](docs/04-Shebang/04-Lab-Exit-Codes.md) 38 | - [05-Functions](docs/04-Shebang/05-Functions.md) 39 | - [06-Lab-Functions](docs/04-Shebang/06-Lab-Functions.md) 40 | - [07-Tips&Tricks-ShellCheck-&-IDE](docs/04-Shebang/07-Tips&Tricks-ShellCheck-&-IDE.md) 41 | 42 | - [05-Project-E-Commerce-Application](docs/05-Project-E-Commerce-Application) 43 | - [01-E-Commerce-Application-Introduction](docs/05-Project-E-Commerce-Application/01-E-Commerce-Application-Introduction.md) 44 | - [02-Demo-E-Commerce-Application](docs/05-Project-E-Commerce-Application/02-Demo-E-Commerce-Application.md) 45 | - [03-Project-Hands-On](docs/05-Project-E-Commerce-Application/03-Project-Hands-On.md) 46 | -------------------------------------------------------------------------------- /docs/01-Course-Introduction/01-Course-Introduction.md: -------------------------------------------------------------------------------- 1 | # Course Introduction 2 | - Take me to [Video Tutorial](https://kodekloud.com/topic/course-introduction-2/) 3 | 4 | #### Shell scripts in linux are easy to use time saving solution for automating repetative (or) complex set of tasks in a system administrator daily life. 5 | 6 | ## In this section, we will take a look at the below. 7 | - Why shell scripts? 8 | - Who is this for? 9 | - Fun Lectures: We will learn in fun way with examples. 10 | - We will also see a number of real world use cases of script through out this course. 11 | - Hands-On labs 12 | 13 | ## Objectives 14 | 15 | ![obj](../../images/obj.PNG) 16 | 17 | ## Pre-Requisites 18 | - Linux Basics 19 | - Command Line Basics 20 | - No Programming knowledge required 21 | 22 | ## Why Shell Scripts? 23 | - Automate Daily Backups 24 | - Automate Installation and Patching of Software on multiple servers 25 | - Monitor System Periodically 26 | - Raise alarms and send notifications 27 | - Troubleshooting and Audits 28 | - Many more 29 | 30 | ## Who is this for? 31 | - System Administrators 32 | - Developers 33 | - IT Engineers 34 | - Absolute Beginners 35 | - No Programming Experience 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/02-Shell-Scripting-Introduction/01-Project-Introduction.md: -------------------------------------------------------------------------------- 1 | # Shell Script Project Introduction 2 | - Take me to [Video Tutorial](https://kodekloud.com/topic/project-introduction/) 3 | 4 | ![lseq](../../images/lseq.PNG) 5 | 6 | 7 | -------------------------------------------------------------------------------- /docs/02-Shell-Scripting-Introduction/02-Lab-Project-Introduction.md: -------------------------------------------------------------------------------- 1 | # Lab - Project Introduction 2 | - Take me to [Practice Test](https://kodekloud.com/topic/lab-project-introduction/) 3 | 4 | #### Solutions to the Practice test - Project Introduction 5 | - Rocket commands have been configured on your system. Let's test it out. Run the rocket-ls command to list all rockets. 6 | 7 |
8 | 9 | ``` 10 | $ rocket-ls 11 | ``` 12 |
13 | 14 | - Run mkdir /home/bob/ 15 | 16 |
17 | 18 | ``` 19 | $ mkdir /home/bob/lunar-mission 20 | ``` 21 |
22 | 23 | - Run 'rocket-add lunar-mission' command from /home/bob 24 | 25 |
26 | 27 | ``` 28 | $ rocket-add lunar-mission 29 | ``` 30 |
31 | 32 | - Run 'rocket-start-power lunar-mission' command from /home/bob 33 | 34 |
35 | 36 | ``` 37 | $ rocket-start-power lunar-mission 38 | ``` 39 |
40 | 41 | - Run 'rocket-internal-power lunar-mission' command from /home/bob 42 | 43 |
44 | 45 | ``` 46 | $ rocket-internal-power lunar-mission 47 | ``` 48 |
49 | 50 | - Run 'rocket-start-sequence lunar-mission' command from /home/bob 51 | 52 |
53 | 54 | ``` 55 | $ rocket-start-sequence lunar-mission 56 | ``` 57 |
58 | 59 | - Run 'rocket-start-engine lunar-mission' command from /home/bob 60 | 61 |
62 | 63 | ``` 64 | $ rocket-start-engine lunar-mission 65 | ``` 66 |
67 | 68 | - Run 'rocket-lift-off lunar-mission' command from /home/bob 69 | 70 |
71 | 72 | ``` 73 | $ rocket-lift-off lunar-mission 74 | ``` 75 |
76 | 77 | - Run 'rocket-status lunar-mission' command from /home/bob 78 | 79 |
80 | 81 | ``` 82 | $ rocket-status lunar-mission 83 | ``` 84 |
85 | 86 | - Run the below under /home/bob 87 | 88 |
89 | 90 | ``` 91 | $ mkdir mars-mission 92 | $ rocket-add mars-mission 93 | $ rocket-start-power mars-mission 94 | $ rocket-internal-power mars-mission 95 | $ rocket-start-sequence mars-mission 96 | $ rocket-start-engine mars-mission 97 | $ rocket-lift-off mars-mission 98 | $ rocket-status mars-mission 99 | ``` 100 |
101 | 102 | - Run 'rocket-ls' under /home/bob 103 | 104 |
105 | 106 | ``` 107 | $ rocket-ls 108 | ``` 109 |
110 | 111 | 112 | -------------------------------------------------------------------------------- /docs/02-Shell-Scripting-Introduction/03-Creating-your-first-shell-script.md: -------------------------------------------------------------------------------- 1 | # Creating your first shell script 2 | - Take me to [Video Tutorial](https://kodekloud.com/topic/creating-your-first-shell-script/) 3 | 4 | In this section, we will take a look at creating your first shell script. 5 | 6 | To Create a shell script name create-and-launch-script.sh 7 | ``` 8 | $ vi create-and-launch-script.sh 9 | ``` 10 | ![create-script](../../images/create-script.PNG) 11 | 12 | ## Run script as command 13 | - There are different ways to execute a shell script 14 | - Execute a shell script with **`bash`** command 15 | ``` 16 | $ bash create-and-launch-script.sh 17 | ``` 18 | - Execute a shell script as an **`executable`** 19 | ``` 20 | $ create-and-launch-script.sh 21 | ``` 22 | **`Note`**: It is a best practice to not name your script with the **`.sh`** extension when you would like to create an executable of a script. 23 | ``` 24 | $ create-and-launch-script 25 | ``` 26 | 27 | ## Configure a script to run as command 28 | - Whenever a command is run at a linux system, the O.S looks at the path configured in the **`$PATH`** environment variable to locate the executable or script for the command. 29 | - If it cannot find the command in the **`$PATH`** then a **`command not found`** error will be thrown. 30 | 31 | - To add our script as a command, append the path to the directory containing the script to the end of the $PATH variable. 32 | ``` 33 | $ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/michael 34 | ``` 35 | - A better way to do this is to append the path to the directory to $PATH variable 36 | ``` 37 | $ export PATH=$PATH:/home/michael 38 | ``` 39 | - Run the command 40 | ``` 41 | $ create-and-launch-script 42 | ``` 43 | - To see the location of the command 44 | ``` 45 | $ which create-and-launch-script 46 | ``` 47 | 48 | ![run-sh](../../images/run-sh.PNG) 49 | 50 | ## Executing a script 51 | - For a shell script to work, we must set the correct permissions to the file, if the permissions are not set a "Permission Denied" error will be thrown when you run the script for the first time. 52 | 53 | - Inspect the file permissions 54 | ``` 55 | $ ls -l /home/michael/create-and-launch-script 56 | ``` 57 | - Add executable permissions to a file and then inspect the file to check if it got write permissions. 58 | ``` 59 | $ chmod +x /home/michael/create-and-launch-script 60 | $ ls -l /home/michael/create-and-launch-script 61 | ``` 62 | - Now, run the script 63 | ``` 64 | $ /home/michael/create-and-launch-script 65 | ``` 66 | 67 | ![exec-sh](../../images/exec-sh.PNG) 68 | 69 | ## Best Practices 70 | 71 | ![best](../../images/best.PNG) 72 | -------------------------------------------------------------------------------- /docs/02-Shell-Scripting-Introduction/04-Lab-Creating-Your-First-Shell-Script.md: -------------------------------------------------------------------------------- 1 | # Lab - Creating your first shell script 2 | - Take me to [Practice Test](https://kodekloud.com/topic/lab-creating-your-first-shell-script/) 3 | 4 | Solutions to the practice test 5 | - Create a script 6 | 7 |
8 | 9 | ``` 10 | vi create-and-launch-rocket 11 | 12 | mkdir lunar-mission 13 | rocket-add lunar-mission 14 | rocket-start-power lunar-mission 15 | rocket-internal-power lunar-mission 16 | rocket-start-sequence lunar-mission 17 | rocket-start-engine lunar-mission 18 | rocket-lift-off lunar-mission 19 | rocket-status lunar-mission 20 | 21 | ``` 22 |
23 | 24 | - Run the command chmod +x create-and-launch-rocket 25 | 26 |
27 | 28 | ``` 29 | $ chmod +x create-and-launch-rocket 30 | ``` 31 |
32 | 33 | - Run the command ./create-and-launch-rocket or bash create-and-launch-rocket 34 | 35 |
36 | 37 | ``` 38 | $ ./create-and-launch-rocket (or) 39 | $ bash create-and-launch-rocket 40 | ``` 41 |
42 | 43 | - Run chmod +x /home/bob/say_hello.sh to add execute permissions to the script. 44 | 45 |
46 | 47 | ``` 48 | $ chmod +x /home/bob/say_hello.sh 49 | ``` 50 |
51 | 52 | - The solution script is located at /tmp/assets/create-directory-structure-answer.sh Check it out. 53 | 54 |
55 | 56 | ``` 57 | $ vi create-directory-structure.sh 58 | 59 | mkdir countries 60 | cd countries 61 | mkdir USA India UK 62 | echo "Washington, D.C" > USA/capital.txt 63 | echo "London" > UK/capital.txt 64 | echo "New Delhi" > India/capital.txt 65 | uptime 66 | 67 | ``` 68 |
69 | 70 | - Check the cd countries line within the script. It changes the PWD to within the countries folder. From there you do not need to specify countries within the path. To solve this, either remove the cd statement and modify the rest of the script to use countries in the path, or remove countries in the path while creating capital.txt files. 71 | 72 |
73 | 74 | ``` 75 | vi create-directory-structure-v2.sh 76 | 77 | mkdir countries 78 | 79 | mkdir -p countries/USA countries/India countries/UK 80 | 81 | echo "Washington, D.C" > countries/USA/capital.txt 82 | echo "London" > countries/UK/capital.txt 83 | echo "New Delhi" > countries/India/capital.txt 84 | 85 | uptime 86 | ``` 87 |
88 | -------------------------------------------------------------------------------- /docs/02-Shell-Scripting-Introduction/05-Variables.md: -------------------------------------------------------------------------------- 1 | # Variables 2 | - Take me to [Video Tutorial](https://kodekloud.com/topic/variables/) 3 | 4 | In this section, we will take a look at variables in shell script. 5 | 6 | ## A Variable in Shell script 7 | - A variable is a value that can vary or change. 8 | - A variable always has a **`$`** sign before it's name. 9 | - A variable name may only contain alphanumeric or underscores 10 | - A variable is case sensitive as well. 11 | - To set the value for a variable 12 | ``` 13 | $ mission_name=lunar-mission 14 | ``` 15 | 16 | ![var](../../images/var.PNG) 17 | 18 | - We can also use variables to store the result of another command and print it. 19 | ``` 20 | $ rocket_status=$(rocket-status $mission_name) 21 | $ echo "Status of launch: $rocket_status" 22 | ``` 23 | 24 | ![var1](../../images/var1.PNG) 25 | 26 | ## Best Practices 27 | 28 | ![best-var](../../images/best-var.PNG) 29 | 30 | -------------------------------------------------------------------------------- /docs/02-Shell-Scripting-Introduction/06-Lab-Variables.md: -------------------------------------------------------------------------------- 1 | # Lab - Variables 2 | - Take me to [Practice Test](https://kodekloud.com/topic/lab-variables-5/) 3 | 4 | Solutions to practice test - variables 5 | 6 | - Check the answer file at /tmp/assets/create-and-launch-rocket-answer 7 | 8 |
9 | 10 | ``` 11 | bob@caleston-lp10:~$ cat create-and-launch-rocket 12 | mission_name=lunar-mission 13 | 14 | mkdir $mission_name 15 | 16 | rocket-add $mission_name 17 | 18 | rocket-start-power $mission_name 19 | rocket-internal-power $mission_name 20 | rocket-start-sequence $mission_name 21 | rocket-start-engine $mission_name 22 | rocket-lift-off $mission_name 23 | 24 | rocket-status $mission_name 25 | 26 | ``` 27 | ``` 28 | $ bash create-and-launch-rocket 29 | ``` 30 |
31 | 32 | - Variable name must be in the same case as defined $user_name 33 | 34 |
35 | 36 | ``` 37 | bob@caleston-lp10:~$ cat print-welcome-message.sh 38 | user_name=Michael 39 | 40 | echo "Hi $user_name, Welcome to xFusionCorp Industries. Weand the rest of the management are glad to have you on board" 41 | ``` 42 |
43 | 44 | - Variable name should not have a dashes. Correct it. 45 | 46 |
47 | 48 | ``` 49 | bob@caleston-lp10:~$ cat print-uptime.sh 50 | uptime=$(uptime) 51 | 52 | echo "The uptime of the system is $uptime" 53 | ``` 54 |
55 | 56 | - Variable should be encapsulated in { }. Change variable to ${file_name}_bkp 57 | 58 |
59 | 60 | ``` 61 | bob@caleston-lp10:~$ cat backup-file.sh 62 | # This script creates a backup of a given file by creatinga copy as bkp# For example some-file is backed up as some-file_bkp 63 | 64 | file_name="create-and-launch-rocket" 65 | 66 | cp $file_name ${file_name}_bkp 67 | ``` 68 |
69 | 70 | - Make sure that the variable names that are defined are actually the ones being used in the script. 71 | 72 |
73 | 74 | ``` 75 | bob@caleston-lp10:~$ cat create_files.sh 76 | FILE01="Japan"FILE02="South Korea" 77 | FILEO3="Canada" 78 | 79 | cd /home/bob 80 | 81 | echo "Creating file called $FILE01" 82 | touch $FILE01 83 | 84 | echo "Creating file called $FILE02"touch $FILE02 85 | 86 | echo "Creating file called $FILE03" 87 | touch $FILE02 88 | ``` 89 |
90 | 91 | - This script uses an environment variable. If unclear, check out the Bash section in the Linux Basics Course 92 | 93 | 94 | -------------------------------------------------------------------------------- /docs/02-Shell-Scripting-Introduction/07-Download-Course-Material.md: -------------------------------------------------------------------------------- 1 | # Download Course Material 2 | - Take me to [Tutorial](https://kodekloud.com/topic/download-course-materials/) 3 | 4 | -------------------------------------------------------------------------------- /docs/02-Shell-Scripting-Introduction/08-Command-Line-Arguments.md: -------------------------------------------------------------------------------- 1 | # Command Line Arguments 2 | - Take me to [Video Tutorial](https://kodekloud.com/topic/command-line-arguments/) 3 | 4 | In the section, we will take a look at "Command Line Arguments" in shell scripts. 5 | 6 | We can replace the hardcoded names within our script with the built in variable. 7 | - $0, $1, $2, $3 ... etc. are built in variables. 8 | 9 | ![cla](../../images/cla.PNG) 10 | 11 | ## Best Practices 12 | - It is a best practice to assign a varaible to a meaningful variable name 13 | 14 | ![cla1](../../images/cla1.PNG) 15 | 16 | ![best-cla](../../images/best-cla.PNG) 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/02-Shell-Scripting-Introduction/09-Read-Inputs.md: -------------------------------------------------------------------------------- 1 | # Read Inputs 2 | - Take me to [Video Tutorial](https://kodekloud.com/topic/read-inputs/) 3 | 4 | In this section, lets take a look at prompting for inputs in a shell script 5 | 6 | To prompt the user for input, use the **`read`** statement followed by adding a **`prompt`** with **`-p`** option. 7 | ``` 8 | $ read -p "Enter mission name:" mission_name 9 | ``` 10 | 11 | ![ri](../../images/ri.PNG) 12 | 13 | When to use **`Command Line Arguments`** and **`Read Inputs`** ? 14 | 15 | ![cla-ri](../../images/cla-ri.PNG) 16 | -------------------------------------------------------------------------------- /docs/02-Shell-Scripting-Introduction/10-Lab-Command-Line-Arguments-and-Inputs.md: -------------------------------------------------------------------------------- 1 | # Lab - Command Line Arguements and Read Inputs 2 | - Take me to [Practice Test](https://kodekloud.com/topic/lab-command-line-arguments-inputs/) 3 | 4 | Solutions to the practice test - Command Line Arguments and Read Inputs 5 | - Check the answer file at /tmp/assets/create-and-launch-rocket-answer 6 | 7 |
8 | 9 | ``` 10 | bob@caleston-lp10:~$ cat create-and-launch-rocket 11 | mission_name=$1 12 | mkdir $mission_name 13 | 14 | rocket-add $mission_name 15 | 16 | rocket-start-power $mission_name 17 | rocket-internal-power $mission_name 18 | rocket-start-sequence $mission_name 19 | rocket-start-engine $mission_name 20 | rocket-lift-off $mission_name 21 | 22 | rocket-status $mission_name 23 | ``` 24 |
25 | 26 | - Run the script 27 | 28 |
29 | ``` 30 | $ bash print-capital.sh 31 | ``` 32 |
33 | 34 | - Check the answer file at /tmp/assets/print-capital-answer.sh 35 | 36 |
37 | 38 | ``` 39 | bob@caleston-lp10:~$ cat print-capital.sh 40 | echo "Capital city of $1 is $2" 41 | ``` 42 |
43 | 44 | - Check the answer file at /tmp/assets/backup-file-answer.sh 45 | 46 |
47 | 48 | ``` 49 | bob@caleston-lp10:~$ cat backup-file.sh 50 | # This script creates a backup of a given file by creating a copy as bkp 51 | # For example some-file is backed up as some-file_bkp 52 | set -e 53 | 54 | file_name=$1 55 | 56 | cp $file_name ${file_name}_bkp 57 | 58 | echo "Done" 59 | bob@caleston-lp10:~$ 60 | ``` 61 |
62 | 63 | - cat the script file and check the command-line arguments such as $1, $2 64 | 65 | 66 | - There is a syntax issue in which the arguments are used for the usermod command. Fix it. 67 | 68 |
69 | 70 | ``` 71 | new_shell=$2 72 | user_name=$1 73 | 74 | useradd -s $new_shell $user_name 75 | ``` 76 |
77 | -------------------------------------------------------------------------------- /docs/02-Shell-Scripting-Introduction/11-Arithmetic-Operations.md: -------------------------------------------------------------------------------- 1 | # Arithmetic Operations 2 | - Take me to [Video Tutorial](https://kodekloud.com/topic/arithmetic-operations/) 3 | 4 | In this section, we will take a look at "Arithmetic Operations" 5 | - There are different methods with which we can perform arithemetic operations 6 | 7 | ## expr 8 | - For addition 9 | ``` 10 | $ expr 6 + 3 11 | ``` 12 | - For substraction 13 | ``` 14 | $ expr 6 - 3 15 | ``` 16 | - For Division 17 | ``` 18 | $ expr 6 / 3 19 | ``` 20 | - For Multiplication 21 | ``` 22 | $ expr 6 \* 3 23 | ``` 24 | 25 | - These can be used with vairable substitution as well 26 | ``` 27 | $ A=6 28 | $ B=3 29 | $ expr $A + $B 30 | $ expr $A - $B 31 | $ expr $A / $B 32 | $ expr $A \* $B 33 | ``` 34 | ![expr](../../images/expr.PNG) 35 | 36 | ## Double Parentheses 37 | - Another method for performing arithmetic operations is double parenthesis. 38 | ``` 39 | $ echo $(( A + B )) 40 | $ echo $(( A-B )) 41 | $ echo $((A / B)) 42 | $ echo $((A*B)) 43 | ``` 44 | 45 | - You may also programming language C stype manipulations of variables 46 | ``` 47 | $ echo $(( ++A )) 48 | $ echo $(( --A )) 49 | $ echo $(( A++ )) 50 | $ echo $(( A-- )) 51 | ``` 52 | ![dp](../../images/dp.PNG) 53 | 54 | ## bc 55 | - expr and "double parentheses" only return decimal output, they do not support floating values. 56 | - For this we use another utility called **`bc`**, it referred to as **`Basic Calculator`**. 57 | - It works in an interactive mode and also you can input to another command as well 58 | 59 | ``` 60 | $ A=10 61 | $ B=3 62 | $ expr $A / $B 63 | $ echo $((A/B)) 64 | $ echo $A / $B |bc -l 65 | ``` 66 | ![bc](../../images/bc.PNG) 67 | -------------------------------------------------------------------------------- /docs/02-Shell-Scripting-Introduction/12-Lab-Arithmetic-Operations.md: -------------------------------------------------------------------------------- 1 | # Lab - Arithmetic Operations 2 | - Take me to [Practice Test](https://kodekloud.com/topic/lab-airthmetic-operations-2/) 3 | 4 | Solutions to practice test - Arithmetic Operations 5 | 6 | - Check the solution at /tmp/assets/calculation-answer.sh 7 | 8 |
9 | 10 | ``` 11 | bob@caleston-lp10:~$ cat calculation.sh 12 | A=20 13 | B=10 14 | 15 | echo "Sum is $(( A + B))" 16 | echo "Difference is $(( A - B))" 17 | echo "Product is $(( A * B))" 18 | echo "Quotient is $(( A / B))" 19 | ``` 20 | ``` 21 | $ bash calculation.sh 22 | ``` 23 |
24 | 25 | - Check the solution at /tmp/assets/calculation-answer-2.sh 26 | 27 |
28 | 29 | ``` 30 | bob@caleston-lp10:~$ cat calculation.shA=$1 31 | B=$2 32 | 33 | echo "Sum is $(( A + B))" 34 | echo "Difference is $(( A - B))" 35 | echo "Product is $(( A * B))" 36 | echo "Quotient is $(( A / B))" 37 | ``` 38 |
39 | 40 | - Check the solution at /tmp/assets/calculate-price.sh 41 | 42 |
43 | 44 | ``` 45 | bob@caleston-lp10:~$ cat calculate-price.sh 46 | price=$(( $1 * $2 )) 47 | 48 | echo "The total price for items is ${price} dollars" 49 | ``` 50 |
51 | 52 | - The "*" should be escaped as "\*" for multiplication using expr statement. 53 | 54 |
55 | ``` 56 | $ cat calculate-total-apples.sh 57 | baskets=4 58 | apples_per_basket=5 59 | total_apples=`expr $baskets \* $apples_per_basket` 60 | echo "Total Apples = $total_apples" 61 | ``` 62 |
63 | 64 | - Answer script: /tmp/assets/calculate-average-answer.sh 65 | 66 |
67 | 68 | ``` 69 | $ cat calculate-average.sh 70 | num1=$1 71 | num2=$2 72 | num3=$3 73 | sum=$(( num1 + num2 + num3 )) 74 | average=$(echo "$sum / 3" | bc -l) 75 | ``` 76 |
77 | -------------------------------------------------------------------------------- /docs/03-Flow-Control/01-Conditional-Logic.md: -------------------------------------------------------------------------------- 1 | # Conditional Logic 2 | 3 | - Lets understand [Conditional-Logic](https://kodekloud.com/topic/conditional-logic/) 4 | 5 | #### Create and Launch Rocket 6 | 7 | - To Check the status of the rocket use below command: 8 | 9 | ``` 10 | $ rocket-status lunar-mission 11 | ``` 12 | 13 | - To debug the status of the rocket. 14 | 15 | ``` 16 | $ rocket-debug lunar-mission 17 | ``` 18 | 19 | ![cl](../../images/cl.PNG) 20 | 21 | #### Conditional Statement 22 | 23 | - **`if`** is defined as 24 | 25 | ``` 26 | if [ $rocket_status = "failed" ] 27 | then 28 | rocket-debug $mission_name 29 | fi 30 | ``` 31 | 32 | ![if](../../images/if.PNG) 33 | 34 | - **`elif`** condition is defined as 35 | 36 | ``` 37 | if [ $rocket_status = "failed" ] 38 | then 39 | rocket-debug $mission_name 40 | elif [ $rocket_status = "success" ] 41 | then 42 | echo "This is successful" 43 | fi 44 | ``` 45 | 46 | ![elif](../../images/elif.PNG) 47 | 48 | - **`else`** is written as 49 | 50 | ``` 51 | if [ -d "/home/bob/caleston" ] 52 | then 53 | echo "Directory exists" 54 | else 55 | echo "Directory not found" 56 | ``` 57 | 58 | ![el](../../images/el.PNG) 59 | 60 | #### Conditional Operators 61 | 62 | - Comparing statement can be used as: 63 | 64 | ![co](../../images/co.PNG) 65 | 66 | 67 | - Conditional Operators that works in **`bash`** 68 | 69 | ![cb](../../images/cb.PNG) 70 | 71 | 72 | - **`AND`** and **`OR`** Operators 73 | 74 | ![cond](../../images/cond.PNG) 75 | 76 | 77 | - Conditional operation description 78 | 79 | ![cond1](../../images/cond1.PNG) 80 | 81 | -------------------------------------------------------------------------------- /docs/03-Flow-Control/02-Lab-Conditional-Logic.md: -------------------------------------------------------------------------------- 1 | # Lab Conditional Logic 2 | 3 | - Take me to the [Lab](https://kodekloud.com/topic/lab-conditional-logic/) 4 | 5 | 6 | 1. See the solution 7 | 8 |
9 | 10 | ``` 11 | mission_name=$1 12 | 13 | mkdir $mission_name 14 | 15 | rocket-add $mission_name 16 | 17 | rocket-start-power $mission_name 18 | rocket-internal-power $mission_name 19 | rocket-start-sequence $mission_name 20 | rocket-start-engine $mission_name 21 | rocket-lift-off $mission_name 22 | 23 | rocket_status=$(rocket-status $mission_name) 24 | 25 | echo "The status of launch is $rocket_status" 26 | 27 | if [ $rocket_status = "failed" ] 28 | then 29 | rocket-debug $mission_name 30 | fi 31 | ``` 32 |
33 | 34 | 2. See the solution 35 | 36 |
37 | 38 | ``` 39 | if [ -d "/home/bob/caleston" ] 40 | then 41 | echo "Directory exists" 42 | else 43 | echo "Directory not found" 44 | fi 45 | ``` 46 |
47 | 48 | 3. See the solution 49 | 50 |
51 | 52 | ``` 53 | if [ $1 -gt $2 ] 54 | then 55 | echo $1 56 | else 57 | echo $2 58 | fi 59 | ``` 60 |
61 | 62 | 4. See the solution 63 | 64 |
65 | 66 | ``` 67 | month_number=$1 68 | 69 | if [ -z $month_number ] 70 | then 71 | echo "No month number given. Please enter a month number as a command line argument." 72 | echo "eg: ./print-month-number 5" 73 | exit 74 | fi 75 | 76 | if [[ $month_number -lt 1 && $month_number -gt 12 ]] 77 | then 78 | echo "Invalid month number given. Please enter a valid number - 1 to 12." 79 | exit 80 | fi 81 | 82 | if [ $month_number -eq 1 ] 83 | then 84 | echo "January" 85 | elif [ $month_number -eq 2 ] 86 | then 87 | echo "February" 88 | elif [ $month_number -eq 3 ] 89 | then 90 | echo "March" 91 | elif [ $month_number -eq 4 ] 92 | then 93 | echo "April" 94 | elif [ $month_number -eq 5 ] 95 | then 96 | echo "May" 97 | elif [ $month_number -eq 6 ] 98 | then 99 | echo "June" 100 | elif [ $month_number -eq 7 ] 101 | then 102 | echo "July" 103 | elif [ $month_number -eq 8 ] 104 | then 105 | echo "August" 106 | elif [ $month_number -eq 9 ] 107 | then 108 | echo "September" 109 | elif [ $month_number -eq 10 ] 110 | then 111 | echo "October" 112 | elif [ $month_number -eq 11 ] 113 | then 114 | echo "November" 115 | elif [ $month_number -eq 12 ] 116 | then 117 | echo "December" 118 | fi 119 | ``` 120 |
121 | -------------------------------------------------------------------------------- /docs/03-Flow-Control/03-Loops-For.md: -------------------------------------------------------------------------------- 1 | # Loops 2 | 3 | - Loops is used for repetative tasks, lets understand how it works in this [lecture](https://kodekloud.com/topic/loops-for/) 4 | 5 | ### Type of Loops 6 | 7 | - **`for`** loops is used when you want to run same command multiple times 8 | - Execute a command or a set of commands many times 9 | - Iterate through files 10 | - Iterate through lines within a file 11 | - Iterate through the output of a command 12 | 13 | - **`for`** loops can be written in multiple ways: 14 | 15 | ``` 16 | for mission in 17 | do 18 | create-and-launch-rocket $mission 19 | done 20 | ``` 21 | 22 | ``` 23 | for mission in 1 2 3 4 5 6 24 | do 25 | create-and-launch-rocket $mission 26 | done 27 | ``` 28 | 29 | ``` 30 | for mission in {0..100} 31 | do 32 | create-and-launch-rocket $mission 33 | done 34 | ``` 35 | 36 | ![for](../../images/for.PNG) 37 | 38 | 39 | - Real life use case can be: 40 | 41 | - Iterate thorugh list of files from the output of the **`ls`** command 42 | 43 | - Iterate thorugh list of packages store them in a file and installs them one by one. 44 | 45 | - **`ssh`** to the list of servers and check there **`uptime`** . 46 | 47 | ``` 48 | for file in $(ls) 49 | do 50 | echo Line count of $file is $(cat $file | wc -l) 51 | done 52 | ``` 53 | 54 | ``` 55 | for server in $(cat servers.txt) 56 | do 57 | ssh $server "uptime" 58 | done 59 | ``` 60 | 61 | ``` 62 | for package in $(cat install-packages.txt) 63 | do 64 | sudo apt-get –y install $package 65 | done 66 | ``` 67 | 68 | ![real](../../images/real.PNG) -------------------------------------------------------------------------------- /docs/03-Flow-Control/04-Lab-For-Loops.md: -------------------------------------------------------------------------------- 1 | # Lab For Loop 2 | 3 | - Take me to the [Lab](https://kodekloud.com/topic/lab-for-loops/) 4 | 5 | 6 | 1. Solution is given below 7 | 8 |
9 | 10 | ``` 11 | for mission in lunar-mission mars-mission jupiter-mission saturn-mission mercury-mission 12 | do 13 | bash /home/bob/create-and-launch-rocket $mission 14 | done 15 | ``` 16 |
17 | 18 | 2. Solution is given below 19 | 20 |
21 | 22 | ``` 23 | for mission_name in $(cat /tmp/assets/mission-names.txt) 24 | do 25 | bash /home/bob/create-and-launch-rocket $mission_name 26 | done 27 | ``` 28 |
29 | 30 | 3. Solution is given below 31 | 32 |
33 | 34 | ``` 35 | for i in {31..40} 36 | do 37 | echo $i 38 | done 39 | 40 | ``` 41 |
42 | 43 | 4. Solution is given below 44 | 45 |
46 | 47 | ``` 48 | echo -e " Log name \t GET \t POST \t DELETE " 49 | echo -e "------------------------------------------------------------" 50 | 51 | for app in $(cat /tmp/assets/apps.txt) 52 | do 53 | get_requests=$(cat /var/log/apps/${app}_app.log | grep "GET" | wc -l) 54 | post_requests=$(cat /var/log/apps/${app}_app.log | grep "POST" | wc -l) 55 | delete_requests=$(cat /var/log/apps/${app}_app.log | grep "DELETE" | wc -l) 56 | echo -e " ${app} \t ${get_requests} \t ${post_requests} \t ${delete_requests}" 57 | 58 | done 59 | ``` 60 |
61 | 62 | 5. Solution is given below 63 | 64 |
65 | 66 | ``` 67 | for file in $(ls images) 68 | do 69 | if [[ $file = *.jpeg ]] 70 | then 71 | new_name=$(echo $file| sed 's/jpeg/jpg/g') 72 | mv images/$file images/$new_name 73 | fi 74 | done 75 | ``` 76 |
-------------------------------------------------------------------------------- /docs/03-Flow-Control/05-Loops-While.md: -------------------------------------------------------------------------------- 1 | # While Loop 2 | 3 | - Help me to understand the [while loop](https://kodekloud.com/topic/loops-while/) 4 | 5 | - While loop works just like the for loop, except theat it executes the loop as long as the condition is true. 6 | - Execute a command or a set of commands multiple times but you are not sure how many times. 7 | - Execute a command or a set of commands until a specific condition occurs 8 | - Create infinite loops 9 | - Menu driven programs 10 | 11 | ### Examples of while loop 12 | 13 | ``` 14 | mission_name=$1 15 | 16 | mkdir $mission_name 17 | 18 | rocket-add $mission_name 19 | 20 | rocket-start-power $mission_name 21 | rocket-internal-power $mission_name 22 | rocket-start-sequence $mission_name 23 | rocket-start-engine $mission_name 24 | rocket-lift-off $mission_name 25 | rocket_status=rocket-status $mission_name 26 | 27 | while [ $rocket_status = "launching" ] 28 | do 29 | sleep 2 30 | rocket_status=rocket-status $mission_name 31 | done 32 | 33 | if [ $rocket_status = "failed" ] 34 | then 35 | rocket-debug $mission_name 36 | fi 37 | ``` 38 | 39 | ![wh](../../images/wh.PNG) 40 | 41 | 42 | - Real life use case can be : 43 | 44 | ![rl](../../images/rl.PNG) -------------------------------------------------------------------------------- /docs/03-Flow-Control/06-Lab-While.md: -------------------------------------------------------------------------------- 1 | # Lab while 2 | 3 | - Lets do some practical with [while Loop](https://kodekloud.com/topic/labs-while-loops/) 4 | 5 | 1. Solution is given below 6 | 7 | 8 | 9 | ``` 10 | mission_name=$1 11 | 12 | mkdir $mission_name 13 | 14 | rocket-add $mission_name 15 | 16 | rocket-start-power $mission_name 17 | rocket-internal-power $mission_name 18 | rocket-start-sequence $mission_name 19 | rocket-start-engine $mission_name 20 | rocket-lift-off $mission_name 21 | 22 | rocket_status=$(rocket-status $mission_name) 23 | 24 | echo "The status of launch is $rocket_status" 25 | 26 | while [ $rocket_status = "launching" ] 27 | do 28 | sleep 2 29 | rocket_status=$(rocket-status $mission_name) 30 | done 31 | 32 | if [ $rocket_status = "failed" ] 33 | then 34 | rocket-debug 35 | fi 36 | ``` 37 | 38 | 39 | 40 | 2. Solution is given below 41 | 42 | 43 | 44 | ``` 45 | to_number=$1 46 | number=0 47 | while [ $number -lt $to_number ] 48 | do 49 | echo $(( number++ )) 50 | done 51 | ``` 52 | 53 | 54 | 55 | 3. Solution is given below 56 | 57 | 58 | 59 | ``` 60 | Print the numbers from 0 to give number 61 | ``` 62 | 63 | 64 | 65 | 4. Solution is given below 66 | 67 | 68 | 69 | ``` 70 | while true 71 | do 72 | echo "1. Add" 73 | echo "2. Subsctract" 74 | echo "3. Multiply" 75 | echo "4. Divide" 76 | echo "5. Quit" 77 | 78 | read -p "Enter your choice: " choice 79 | 80 | if [ $choice -eq 1 ] 81 | then 82 | read -p "Enter Number1: " number1 83 | read -p "Enter Number2: " number2 84 | echo Answer=$(( $number1 + $number2 )) 85 | elif [ $choice -eq 2 ] 86 | then 87 | read -p "Enter Number1: " number1 88 | read -p "Enter Number2: " number2 89 | echo Answer=$(( $number1 - $number2 )) 90 | elif [ $choice -eq 3 ] 91 | then 92 | read -p "Enter Number1: " number1 93 | read -p "Enter Number2: " number2 94 | echo Answer=$(( $number1 * $number2 )) 95 | elif [ $choice -eq 4 ] 96 | then 97 | read -p "Enter Number1: " number1 98 | read -p "Enter Number2: " number2 99 | echo Answer=$(( $number1 / $number2 )) 100 | elif [ $choice -eq 5 ] 101 | then 102 | break 103 | fi 104 | 105 | done 106 | ``` 107 | 108 | -------------------------------------------------------------------------------- /docs/03-Flow-Control/07-Case-Statements.md: -------------------------------------------------------------------------------- 1 | # Case Statements 2 | 3 | - Lets understand [Case Statement](https://kodekloud.com/topic/case-statements/) 4 | 5 | - Case statement is used for simplifying multiple condition check with multiple different choices. 6 | 7 | ``` 8 | echo "1. Shutdown" 9 | echo "2. Restart" 10 | echo "3. Exit Menu" 11 | read –p "Enter your choice: " choice 12 | 13 | case $choice in 14 | 15 | 1) shutdown now 16 | ;; 17 | 2) shutdown –r now 18 | ;; 19 | 3) break 20 | ;; 21 | *) continue 22 | ;; 23 | 24 | esac 25 | ``` 26 | 27 | ![cs](../../images/cs.PNG) 28 | 29 | 30 | - Case statement can also be written along with the **`while`** loop as shown 31 | 32 | ``` 33 | while true 34 | do 35 | echo "1. Shutdown" 36 | echo "2. Restart" 37 | echo "3. Exit Menu" 38 | read –p "Enter your choice: " choice 39 | 40 | case $choice in 41 | 42 | 1) shutdown now 43 | ;; 44 | 2) shutdown –r now 45 | ;; 46 | 3) break 47 | ;; 48 | *) continue 49 | ;; 50 | 51 | esac 52 | done 53 | ``` 54 | ![cs1](../../images/cs1.PNG) -------------------------------------------------------------------------------- /docs/03-Flow-Control/08-Lab-Case-Statements.md: -------------------------------------------------------------------------------- 1 | # Labs Case Statement 2 | 3 | - Take me to the lab [Case Statement](https://kodekloud.com/topic/labs-case-statements/) 4 | 5 | 6 | 1. Solution is given below 7 | 8 |
9 | 10 | ``` 11 | The script is missing the in keyword on line 4. Lines 7 and 9 is missing ;;. Lines 13 is missing ) 12 | 13 | os=Fedora 14 | 15 | case $os in 16 | "Fedora") echo "Uses RPM package manager" ;; 17 | 18 | "RHEL") echo "Uses RPM package manager" ;; 19 | 20 | "CentOS") echo "Uses RPM package manager" ;; 21 | 22 | "Debian") echo "Uses DEB package manager" ;; 23 | 24 | "Ubuntu") 25 | echo "Uses DEB package manager" ;; 26 | esac 27 | 28 | ``` 29 |
30 | 31 | 2. Solution is given below 32 | 33 |
34 | 35 | ``` 36 | month_number=$1 37 | 38 | if [ -z $month_number ] 39 | then 40 | echo "No month number given. Please enter a month number as a command line argument." 41 | echo "eg: ./print-month-number 5" 42 | exit 43 | fi 44 | 45 | if [[ $month_number -lt 1 && $month_number -gt 12 ]] 46 | then 47 | echo "Invalid month number given. Please enter a valid number - 1 to 12." 48 | exit 49 | fi 50 | 51 | case $month_number in 52 | 1) echo "January" ;; 53 | 2) echo "February" ;; 54 | 3) echo "March" ;; 55 | 4) echo "April" ;; 56 | 5) echo "May" ;; 57 | 6) echo "June" ;; 58 | 7) echo "July" ;; 59 | 8) echo "August" ;; 60 | 9) echo "September" ;; 61 | 10) echo "October" ;; 62 | 11) echo "November" ;; 63 | 12) echo "December" ;; 64 | esac 65 | 66 | ``` 67 |
68 | 69 | 3. Solution is given below 70 | 71 |
72 | 73 | ``` 74 | while true 75 | do 76 | echo "1. Add" 77 | echo "2. Subsctract" 78 | echo "3. Multiply" 79 | echo "4. Divide" 80 | echo "5. Quit" 81 | 82 | read -p "Enter your choice: " choice 83 | 84 | if [ $choice -eq 1 ] 85 | then 86 | read -p "Enter Number1: " number1 87 | read -p "Enter Number2: " number2 88 | echo Answer=$(( $number1 + $number2 )) 89 | elif [ $choice -eq 2 ] 90 | then 91 | read -p "Enter Number1: " number1 92 | read -p "Enter Number2: " number2 93 | echo Answer=$(( $number1 - $number2 )) 94 | elif [ $choice -eq 3 ] 95 | then 96 | read -p "Enter Number1: " number1 97 | read -p "Enter Number2: " number2 98 | echo Answer=$(( $number1 * $number2 )) 99 | elif [ $choice -eq 4 ] 100 | then 101 | read -p "Enter Number1: " number1 102 | read -p "Enter Number2: " number2 103 | echo Answer=$(( $number1 / $number2 )) 104 | elif [ $choice -eq 5 ] 105 | then 106 | break 107 | fi 108 | 109 | done 110 | 111 | ``` 112 |
113 | 114 | 4. Solution is given below 115 | 116 |
117 | 118 | ``` 119 | while true 120 | do 121 | echo "1. Add" 122 | echo "2. Subsctract" 123 | echo "3. Multiply" 124 | echo "4. Divide" 125 | echo "5. Average" 126 | echo "6. Quit" 127 | 128 | read -p "Enter your choice: " choice 129 | 130 | case $choice in 131 | 1) 132 | read -p "Enter Number1: " number1 133 | read -p "Enter Number2: " number2 134 | echo Answer=$(( $number1 + $number2 )) 135 | ;; 136 | 2) 137 | read -p "Enter Number1: " number1 138 | read -p "Enter Number2: " number2 139 | echo Answer=$(( $number1 - $number2 )) 140 | ;; 141 | 142 | 3) 143 | read -p "Enter Number1: " number1 144 | read -p "Enter Number2: " number2 145 | echo Answer=$(( $number1 * $number2 )) 146 | ;; 147 | 4) 148 | read -p "Enter Number1: " number1 149 | read -p "Enter Number2: " number2 150 | echo Answer=$(( $number1 / $number2 )) 151 | ;; 152 | 5) 153 | read -p "Enter Number1: " number1 154 | read -p "Enter Number2: " number2 155 | sum=$(( number1 + number2 )) 156 | echo Answer=$(echo "$sum / 2" | bc -l) 157 | ;; 158 | 6) 159 | break 160 | ;; 161 | esac 162 | 163 | done 164 | ``` 165 |
166 | 167 | 5. Solution is given below 168 | 169 |
170 | 171 | ``` 172 | color=$1 173 | red=`tput setaf 1` 174 | green=`tput setaf 2` 175 | reset=`tput sgr0` 176 | 177 | 178 | case $color in 179 | red) echo "${red}this is red${reset}";; 180 | green) echo "${green}this is green${reset}";; 181 | *) echo "red and green are the only choices" 182 | esac 183 | ``` 184 |
-------------------------------------------------------------------------------- /docs/04-Shebang/01-Shebang.md: -------------------------------------------------------------------------------- 1 | # Shebang 2 | 3 | - Lets understand [Shebang](https://kodekloud.com/topic/shebang/) 4 | 5 | - In this lecture we will understand the types of shell, **`Bourne Shell(sh)`**, **`Bourne again Shell(bash)`**, **`C Shell`**, **`Z Shell`** etc.. 6 | 7 | - A Shebang statement is a line that you specify at the top of the shell script and is used to specify what shell a script must run in. 8 | 9 | - Shebang instructs the shell to use a particular shell or interpreter for the script, below case tells us that the script should run in the bash shell 10 | 11 | 12 | ![bash](../../images/bash.PNG) 13 | 14 | 15 | ### Bourne again Shell 16 | 17 | - Bourne again Shell, it will print the sequence as expected. It will generate the sequence 0 to 10 18 | 19 | ![ba](../../images/ba.PNG) 20 | 21 | 22 | ### Bourne Shell or Debian Almquist Shell(dash) 23 | 24 | - Bourne Shell, if you try to run the same script in **`dash shell`**, it doesnt know how to expand this expression into a seuqnce of numbers 25 | 26 | ![b](../../images/b.PNG) 27 | 28 | - Bourne Shell is, in fact, the(bash) shell itself, it is linked to the (bash). 29 | 30 | ![dash](../../images/dash.PNG) 31 | 32 | 33 | ### Other Shell 34 | 35 | - If you want to run the script from another shell, thats not a(bash) shel, then you must just run it through the(bash) shell by prefixing the **`bash`** command 36 | 37 | ![o](../../images/o.PNG) -------------------------------------------------------------------------------- /docs/04-Shebang/02-Lab-Shebang.md: -------------------------------------------------------------------------------- 1 | # Lab Shebang 2 | 3 | - Take me to the [Lab](https://kodekloud.com/topic/lab-shebang/) 4 | 5 | 6 | 1. Solution is given below 7 | 8 |
9 | 10 | **`Print Numbers from 31 to 40`** 11 |
12 | 13 | 2. Solution is given below 14 | 15 |
16 | 17 | **`Prints {31..40}`** 18 |
19 | 20 | 3. Solution is given below 21 | 22 |
23 | 24 | ``` 25 | #!/bin/bash 26 | for i in {31..40} 27 | do 28 | echo $i 29 | done 30 | ``` 31 |
32 | 33 | 4. Solution is given below 34 | 35 |
36 | 37 | ``` 38 | print_number4.sh 39 | ``` 40 |
41 | 42 | 5. Solution is given below 43 | 44 |
45 | 46 | ``` 47 | #!/bin/bash 48 | echo {1..10} 49 | ``` 50 |
-------------------------------------------------------------------------------- /docs/04-Shebang/03-Exit-Codes.md: -------------------------------------------------------------------------------- 1 | # Exit Codes 2 | 3 | - Lets understand [Exit-Codes](https://kodekloud.com/topic/exit-codes/) 4 | 5 | - In this lecture we will understand the Exit-Codes and different types of Exit Codes. 6 | 7 | ![e0](../../images/e0.PNG) 8 | 9 | 10 | ![e1](../../images/e1.PNG) 11 | 12 | 13 | - Command to check the exit code of the the last executed command is **`echo $?`** 14 | 15 | - For example to check the status of command **`rocket-status`** use 16 | 17 | ![rs](../../images/rs.PNG) 18 | 19 | 20 | - If the launch of the rocket is successfull then exit code should be **`zero`** and if it fails it should be a **`non-zero`** value 21 | 22 | - If the launch of the rocket is failed then script should return 1 this can be modified in the script to retrun a exit-code. 23 | 24 | ![exit](../../images/exit.PNG) -------------------------------------------------------------------------------- /docs/04-Shebang/04-Lab-Exit-Codes.md: -------------------------------------------------------------------------------- 1 | # Lab Exit-Codes 2 | 3 | - Take me to the [Lab](https://kodekloud.com/topic/lab-exit-codes/) 4 | 5 | 1. Solution is given below 6 | 7 |
8 | 9 | 10 | ``` 11 | Exit Status - 0 12 | ``` 13 |
14 | 15 | 1. Solution is given below 16 | 17 |
18 | 19 | 20 | ``` 21 | Exit Status - 127 22 | ``` 23 |
24 | 25 | 1. Solution is given below 26 | 27 |
28 | 29 | 30 | ``` 31 | Exit Status - 126 32 | ``` 33 |
34 | 35 | 1. Solution is given below 36 | 37 |
38 | 39 | 40 | ``` 41 | mission_name=$1 42 | 43 | mkdir $mission_name 44 | 45 | rocket-add $mission_name 46 | 47 | rocket-start-power $mission_name 48 | rocket-internal-power $mission_name 49 | rocket-start-sequence $mission_namerocket-start-engine $mission_name 50 | rocket-lift-off $mission_name 51 | 52 | rocket_status=$(rocket-status $mission_name) 53 | 54 | echo "The status of launch is $rocket_status" 55 | 56 | if [ $rocket_status = "launching" ] 57 | then 58 | sleep 2 59 | rocket_status=$(rocket-status $mission_name) 60 | fi 61 | 62 | if [ $rocket_status = "failed" ] 63 | then 64 | rocket-debug 65 | exit 1 66 | fi 67 | ``` 68 |
69 | 70 | -------------------------------------------------------------------------------- /docs/04-Shebang/05-Functions.md: -------------------------------------------------------------------------------- 1 | # Functions 2 | 3 | - Lets understand [Functions](https://kodekloud.com/topic/functions/) 4 | 5 | - Functions within a shell script is a piece of code or a block of code that perform a particular function that can be reused. 6 | 7 | ![f](../../images/f.PNG) 8 | 9 | - When a shell script runs it runs line-by-line. So your Function must **`always be defined first`** before calling it, if not then it will give error. 10 | 11 | - The return statement within a function call helps in specifying the exit code for that function. It is just like the exit code for the entire script but in this case it 12 | wont exit the script but the function. 13 | 14 | ![re](../../images/re.PNG) 15 | 16 | - When to use Functions? 17 | 18 | - Break up large script that performs many different tasks 19 | - Installing packages 20 | - Adding users 21 | - Configuring firewalls 22 | - Perform Mathematical calculations 23 | 24 | 25 | - Function to add two numbers, returning the value of addition to a variable called **`sum`** and outputing the exit code of previouly run command 26 | 27 | ![fu](../../images/fu.PNG) 28 | 29 | -------------------------------------------------------------------------------- /docs/04-Shebang/06-Lab-Functions.md: -------------------------------------------------------------------------------- 1 | # Lab Functions 2 | 3 | - Take me to the [Lab](https://kodekloud.com/topic/lab-functions/) 4 | 5 | 1. Solution is give below 6 | 7 |
8 | 9 | ``` 10 | The name of the function is after the function keyword and before the double brackets () 11 | Function name is prepare-directory-structure 12 | 13 | ``` 14 |
15 | 16 | 2. Solution is give below 17 | 18 |
19 | 20 | ``` 21 | function prepare-directory-structure(){ 22 | mkdir apps 23 | cd apps mkdir app1 app2 app3 touch app1/logs app2/logs app3/logs 24 | } 25 | ``` 26 |
27 | 28 | 3. Solution is give below 29 | 30 |
31 | 32 | ``` 33 | function add(){ 34 | sum=$(( $1 + $2 )) 35 | } 36 | 37 | result=$(add 3 5) 38 | echo "The result is $result" 39 | 40 | ``` 41 |
42 | 43 | 4. Solution is give below 44 | 45 |
46 | 47 | ``` 48 | function add(){ 49 | sum=$(( $1 + $2 )) 50 | echo $sum 51 | } 52 | 53 | result=$(add 3 5) 54 | echo "The result is $result" 55 | 56 | ``` 57 |
58 | 59 | 5. Solution is given below 60 | 61 |
62 | 63 | ``` 64 | function add(){ 65 | sum=$(( $1 + $2 )) 66 | } 67 | 68 | result=$(add 3 5) 69 | echo "The result is $result" 70 | ``` 71 |
72 | 73 | 6. Solution is given below 74 | 75 |
76 | 77 | ``` 78 | #!/bin/bash 79 | function read_numbers(){ 80 | read -p "Enter Number1: " number1 81 | read -p "Enter Number2: " number2 82 | } 83 | 84 | while true 85 | do 86 | echo "1. Add" 87 | echo "2. Subsctract" 88 | echo "3. Multiply" 89 | echo "4. Divide" 90 | echo "5. Quit" 91 | 92 | read -p "Enter your choice: " choice 93 | 94 | case $choice in 95 | 1) read_numbers 96 | echo $(( $number1 + $number2 )) ;; 97 | 2) 98 | read_numbers 99 | echo $(( $number1 - $number2 )) ;; 100 | 101 | 3) 102 | read_numbers 103 | echo $(( $number1 * $number2 )) ;; 104 | 105 | 4) 106 | read_numbers 107 | echo $(( $number1 / $number2 )) ;; 108 | 109 | 5) break 110 | esac 111 | 112 | done 113 | ``` 114 |
115 | 116 | 7. Solution is given below 117 | 118 |
119 | 120 | ``` 121 | function launch_rocket(){ 122 | mission_name=$1 123 | 124 | mkdir $mission_name 125 | 126 | rocket-add $mission_name 127 | 128 | rocket-start-power $mission_name 129 | rocket-internal-power $mission_name 130 | rocket-start-sequence $mission_name 131 | rocket-start-engine $mission_name 132 | rocket-lift-off $mission_name 133 | 134 | rocket_status=$(rocket-status $mission_name) 135 | 136 | echo "The status of launch is $rocket_status" 137 | 138 | if [ $rocket_status = "launching" ] 139 | then 140 | sleep 2 141 | rocket_status=$(rocket-status $mission_name) 142 | fi 143 | 144 | if [ $rocket_status = "failed" ] 145 | then 146 | rocket-debug 147 | exit 1 148 | fi 149 | } 150 | 151 | launch_rocket $1 152 | ``` 153 |
-------------------------------------------------------------------------------- /docs/04-Shebang/07-Tips&Tricks-ShellCheck-&-IDE.md: -------------------------------------------------------------------------------- 1 | # Tipes & Tricks - ShellCheck & IDE 2 | 3 | - Lets understand about [shellcheck and IDE](https://kodekloud.com/topic/tips-tricks-shellcheck-ide/) 4 | 5 | - VIM provides syntax highlighting, which helps in catching any syntax error in your shell scripts. 6 | 7 | ![vi](../../images/vi.PNG) 8 | 9 | ### ShellCheck 10 | 11 | - To analyze and identify bugs and area of improvement in your script use **`shellcheck`** utility based on your OS 12 | 13 | ``` 14 | apt-get install shellcheck 15 | 16 | OR 17 | 18 | yum install shellcheck 19 | 20 | ``` 21 | [ShellCheck-Github](https://github.com/koalaman/shellcheck) 22 | 23 | 24 | ![s](../../images/s.PNG) 25 | 26 | 27 | ### IDE 28 | 29 | - The **`JetBrains PyCharm`** supports a development environment for Python, but it also has plugin for shell scripts 30 | - It also provides syntax highlighting and recommendations to improve your script. 31 | 32 | 33 | ![id](../../images/id.PNG) 34 | 35 | 36 | ### Editors 37 | 38 | - Visual Studio Code and Atom can be used as an editor tool. 39 | 40 | 41 | ### Styleguide 42 | 43 | - Google's **`styleguide`** can be used too for writing shell scripts. 44 | 45 | [styleguide](https://google.github.io/styleguide/shellguide.html) 46 | 47 | -------------------------------------------------------------------------------- /docs/05-Project-E-Commerce-Application/01-E-Commerce-Application-Introduction.md: -------------------------------------------------------------------------------- 1 | # E-Commerce-Application-Introduction 2 | 3 | - Take me to [Video Tutorial](https://kodekloud.com/topic/project-kodekloud-e-commerce-application-3/) 4 | 5 | In this section, we will now introduced to a project that we will work on. 6 | - We will deploy the kodekloud e-commerce website. 7 | - We will work on setting up a lab environment, then we will deploy the application. 8 | 9 | The KodeKloud e-commerce website is a fictional online store that sells electronic devices. 10 | - It's a LAMP stack application, deployed on Linux with Apache Server that uses MariaDB database and a PHP programming language. 11 | 12 | ![ecomm](../../images/ecomm.PNG) 13 | 14 | ## Install and Configure 15 | 16 | - Install firewalld 17 | ``` 18 | $ sudo yum install firewalld 19 | ``` 20 | - Start firewalld service 21 | ``` 22 | $ sudo service firewalld start 23 | ``` 24 | - Enable the service at boot 25 | ``` 26 | $ sudo systemctl enable firewalld 27 | ``` 28 | 29 | - Install MariaDB 30 | ``` 31 | $ sudo yum install mariadb-server 32 | ``` 33 | - Configure MariaDB 34 | ``` 35 | $ sudo vi /etc/my.cnf 36 | ``` 37 | - Start the MariaDB service 38 | ``` 39 | $ sudo service mariadb start 40 | ``` 41 | - Enable the service at boot 42 | ``` 43 | $ sudo systemctl enable mariadb 44 | ``` 45 | - Configure Firewall and reload the firewall 46 | ``` 47 | $ sudo firewall-cmd --permanent --zone=public --add-port=3306/tcp 48 | $ sudo firewall-cmd --reload 49 | ``` 50 | - Configure Database 51 | ``` 52 | $ mysql 53 | MariaDB > CREATE DATABASE ecomdb; 54 | MariaDB > CREATE USER 'ecomuser'@'localhost' IDENTIFIED BY 'ecompassword'; 55 | MariaDB > GRANT ALL PRIVILEGES ON *.* TO 'ecommuser'@'localhost'; 56 | MariaDB > FLUSH PRIVILAGES; 57 | ``` 58 | - Load Inventory Data 59 | ``` 60 | $ mysql < db-load-script.sql 61 | ``` 62 | 63 | ![ecomm1](../../images/ecomm1.PNG) 64 | 65 | 66 | - Install httpd and php 67 | ``` 68 | $ sudo yum install -y httpd php php-mysql 69 | ``` 70 | - Configure Firewall 71 | ``` 72 | $ sudo firewall-cmd --permanent --zone=public --add-port=80/tcp 73 | $ sudo firewall-cmd --reload 74 | ``` 75 | - Configure httpd 76 | ``` 77 | $ sudo vi /etc/httpd/conf/httpd.conf 78 | ``` 79 | - Start the httpd service 80 | ``` 81 | $ sudo service httpd start 82 | ``` 83 | - Enable the service at boot 84 | ``` 85 | $ sudo systemctl enable httpd 86 | ``` 87 | 88 | - Install git and download all supporting code for our e-commerce application 89 | ``` 90 | $ sudo yum install -y git 91 | $ sudo git clone https://github.com/.git /var/www/html/ 92 | ``` 93 | 94 | - Test your work using curl 95 | ``` 96 | $ curl http://localhsot 97 | ``` 98 | 99 | 100 | ![ecomm2](../../images/ecomm2.PNG) 101 | 102 | 103 | -------------------------------------------------------------------------------- /docs/05-Project-E-Commerce-Application/02-Demo-E-Commerce-Application.md: -------------------------------------------------------------------------------- 1 | # Demo - E-Commerce Application 2 | 3 | - Take me to [E-Commerce Application Project Demo](https://kodekloud.com/topic/demo-kodekloud-e-commerce-application/) 4 | 5 | Demo 6 | - Install git and access the application code at github. 7 | ``` 8 | $ sudo yum install -y git 9 | $ sudo git clone https://github.com/kodekloudhub/learning-app-ecommerce.git 10 | ``` 11 | 12 | #### Take me to [Instructions](https://github.com/kodekloudhub/learning-app-ecommerce/blob/master/README.md) 13 | -------------------------------------------------------------------------------- /docs/05-Project-E-Commerce-Application/03-Project-Hands-On.md: -------------------------------------------------------------------------------- 1 | # Project Hands On 2 | 3 | - Take me to [Practice Test](https://kodekloud.com/topic/lab-project-2/) 4 | - Take me to [Automation Script](deploy-ecommerce-application.sh) 5 | 6 | #### Solutions to the practice test 7 | 8 | - Run the below command to give execute permissions to the script 9 | 10 |
11 | 12 | ``` 13 | $ chmod +x deploy-ecommerce-application.sh 14 | ``` 15 |
16 | 17 | - Run the script 18 | 19 |
20 | 21 | ``` 22 | $ ./deploy-ecommerce-application.sh 23 | ``` 24 |
25 | 26 | 27 | #### Take me to [Practice Test - Solution](https://kodekloud.com/topic/solution-project-ecommerce-application/) 28 | -------------------------------------------------------------------------------- /docs/05-Project-E-Commerce-Application/deploy-ecommerce-application.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Automate ECommerce Application Deployment 4 | # Author: Mumshad Mannambeth 5 | 6 | ####################################### 7 | # Print a message in a given color. 8 | # Arguments: 9 | # Color. eg: green, red 10 | ####################################### 11 | function print_color(){ 12 | NC='\033[0m' # No Color 13 | case $1 in 14 | "green") COLOR='\033[0;32m' ;; 15 | "red") COLOR='\033[0;31m' ;; 16 | "*") COLOR='\033[0m' ;; 17 | esac 18 | 19 | echo -e "${COLOR} $2 ${NC}" 20 | } 21 | 22 | ####################################### 23 | # Check the status of a given service. If not active exit script 24 | # Arguments: 25 | # Service Name. eg: firewalld, mariadb 26 | ####################################### 27 | function check_service_status(){ 28 | service_is_active=$(sudo systemctl is-active $1) 29 | 30 | if [ $service_is_active = "active" ] 31 | then 32 | echo "$1 is active and running" 33 | else 34 | echo "$1 is not active/running" 35 | exit 1 36 | fi 37 | } 38 | 39 | ####################################### 40 | # Check the status of a firewalld rule. If not configured exit. 41 | # Arguments: 42 | # Port Number. eg: 3306, 80 43 | ####################################### 44 | function is_firewalld_rule_configured(){ 45 | 46 | firewalld_ports=$(sudo firewall-cmd --list-all --zone=public | grep ports) 47 | 48 | if [[ $firewalld_ports == *$1* ]] 49 | then 50 | echo "FirewallD has port $1 configured" 51 | else 52 | echo "FirewallD port $1 is not configured" 53 | exit 1 54 | fi 55 | } 56 | 57 | ####################################### 58 | # Check if a given item is present in an output 59 | # Arguments: 60 | # 1 - Output 61 | # 2 - Item 62 | ####################################### 63 | function check_item(){ 64 | if [[ $1 = *$2* ]] 65 | then 66 | print_color "green" "Item $2 is present on the web page" 67 | else 68 | print_color "red" "Item $2 is not present on the web page" 69 | fi 70 | } 71 | 72 | 73 | 74 | 75 | 76 | 77 | echo "---------------- Setup Database Server ------------------" 78 | 79 | # Install and configure firewalld 80 | print_color "green" "Installing FirewallD.. " 81 | sudo yum install -y firewalld 82 | 83 | print_color "green" "Installing FirewallD.. " 84 | sudo service firewalld start 85 | sudo systemctl enable firewalld 86 | 87 | # Check FirewallD Service is running 88 | check_service_status firewalld 89 | 90 | # Install and configure Maria-DB 91 | print_color "green" "Installing MariaDB Server.." 92 | sudo yum install -y mariadb-server 93 | 94 | print_color "green" "Starting MariaDB Server.." 95 | sudo service mariadb start 96 | sudo systemctl enable mariadb 97 | 98 | # Check FirewallD Service is running 99 | check_service_status mariadb 100 | 101 | # Configure Firewall rules for Database 102 | print_color "green" "Configuring FirewallD rules for database.." 103 | sudo firewall-cmd --permanent --zone=public --add-port=3306/tcp 104 | sudo firewall-cmd --reload 105 | 106 | is_firewalld_rule_configured 3306 107 | 108 | 109 | # Configuring Database 110 | print_color "green" "Setting up database.." 111 | cat > setup-db.sql <<-EOF 112 | CREATE DATABASE ecomdb; 113 | CREATE USER 'ecomuser'@'localhost' IDENTIFIED BY 'ecompassword'; 114 | GRANT ALL PRIVILEGES ON *.* TO 'ecomuser'@'localhost'; 115 | FLUSH PRIVILEGES; 116 | EOF 117 | 118 | sudo mysql < setup-db.sql 119 | 120 | # Loading inventory into Database 121 | print_color "green" "Loading inventory data into database" 122 | cat > db-load-script.sql <<-EOF 123 | USE ecomdb; 124 | CREATE TABLE products (id mediumint(8) unsigned NOT NULL auto_increment,Name varchar(255) default NULL,Price varchar(255) default NULL, ImageUrl varchar(255) default NULL,PRIMARY KEY (id)) AUTO_INCREMENT=1; 125 | 126 | INSERT INTO products (Name,Price,ImageUrl) VALUES ("Laptop","100","c-1.png"),("Drone","200","c-2.png"),("VR","300","c-3.png"),("Tablet","50","c-5.png"),("Watch","90","c-6.png"),("Phone Covers","20","c-7.png"),("Phone","80","c-8.png"),("Laptop","150","c-4.png"); 127 | 128 | EOF 129 | 130 | sudo mysql < db-load-script.sql 131 | 132 | mysql_db_results=$(sudo mysql -e "use ecomdb; select * from products;") 133 | 134 | if [[ $mysql_db_results == *Laptop* ]] 135 | then 136 | print_color "green" "Inventory data loaded into MySQl" 137 | else 138 | print_color "green" "Inventory data not loaded into MySQl" 139 | exit 1 140 | fi 141 | 142 | 143 | print_color "green" "---------------- Setup Database Server - Finished ------------------" 144 | 145 | print_color "green" "---------------- Setup Web Server ------------------" 146 | 147 | # Install web server packages 148 | print_color "green" "Installing Web Server Packages .." 149 | sudo yum install -y httpd php php-mysql 150 | 151 | # Configure firewalld rules 152 | print_color "green" "Configuring FirewallD rules.." 153 | sudo firewall-cmd --permanent --zone=public --add-port=80/tcp 154 | sudo firewall-cmd --reload 155 | 156 | is_firewalld_rule_configured 80 157 | 158 | # Update index.php 159 | sudo sed -i 's/index.html/index.php/g' /etc/httpd/conf/httpd.conf 160 | 161 | # Start httpd service 162 | print_color "green" "Start httpd service.." 163 | sudo service httpd start 164 | sudo systemctl enable httpd 165 | 166 | # Check FirewallD Service is running 167 | check_service_status httpd 168 | 169 | # Download code 170 | print_color "green" "Install GIT.." 171 | sudo yum install -y git 172 | sudo git clone https://github.com/kodekloudhub/learning-app-ecommerce.git /var/www/html/ 173 | 174 | print_color "green" "Updating index.php.." 175 | sudo sed -i 's/172.20.1.101/localhost/g' /var/www/html/index.php 176 | 177 | print_color "green" "---------------- Setup Web Server - Finished ------------------" 178 | 179 | # Test Script 180 | web_page=$(curl http://localhost) 181 | 182 | for item in Laptop Drone VR Watch Phone 183 | do 184 | check_item "$web_page" $item 185 | done 186 | -------------------------------------------------------------------------------- /images/README.md: -------------------------------------------------------------------------------- 1 | IMAGES 2 | -------------------------------------------------------------------------------- /images/b.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/b.PNG -------------------------------------------------------------------------------- /images/ba.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/ba.PNG -------------------------------------------------------------------------------- /images/bash.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/bash.PNG -------------------------------------------------------------------------------- /images/bc.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/bc.PNG -------------------------------------------------------------------------------- /images/best-cla.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/best-cla.PNG -------------------------------------------------------------------------------- /images/best-var.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/best-var.PNG -------------------------------------------------------------------------------- /images/best.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/best.PNG -------------------------------------------------------------------------------- /images/cb.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/cb.PNG -------------------------------------------------------------------------------- /images/cl.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/cl.PNG -------------------------------------------------------------------------------- /images/cla-ri.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/cla-ri.PNG -------------------------------------------------------------------------------- /images/cla.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/cla.PNG -------------------------------------------------------------------------------- /images/cla1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/cla1.PNG -------------------------------------------------------------------------------- /images/co.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/co.PNG -------------------------------------------------------------------------------- /images/cond.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/cond.PNG -------------------------------------------------------------------------------- /images/cond1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/cond1.PNG -------------------------------------------------------------------------------- /images/create-script.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/create-script.PNG -------------------------------------------------------------------------------- /images/cs.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/cs.PNG -------------------------------------------------------------------------------- /images/cs1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/cs1.PNG -------------------------------------------------------------------------------- /images/dash.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/dash.PNG -------------------------------------------------------------------------------- /images/dm.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/dm.PNG -------------------------------------------------------------------------------- /images/dm1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/dm1.PNG -------------------------------------------------------------------------------- /images/dp.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/dp.PNG -------------------------------------------------------------------------------- /images/e0.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/e0.PNG -------------------------------------------------------------------------------- /images/e1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/e1.PNG -------------------------------------------------------------------------------- /images/ecomm.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/ecomm.PNG -------------------------------------------------------------------------------- /images/ecomm1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/ecomm1.PNG -------------------------------------------------------------------------------- /images/ecomm2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/ecomm2.PNG -------------------------------------------------------------------------------- /images/el.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/el.PNG -------------------------------------------------------------------------------- /images/elif.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/elif.PNG -------------------------------------------------------------------------------- /images/exec-sh.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/exec-sh.PNG -------------------------------------------------------------------------------- /images/exit.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/exit.PNG -------------------------------------------------------------------------------- /images/expr.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/expr.PNG -------------------------------------------------------------------------------- /images/f.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/f.PNG -------------------------------------------------------------------------------- /images/for.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/for.PNG -------------------------------------------------------------------------------- /images/fu.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/fu.PNG -------------------------------------------------------------------------------- /images/ht.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/ht.PNG -------------------------------------------------------------------------------- /images/id.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/id.PNG -------------------------------------------------------------------------------- /images/if.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/if.PNG -------------------------------------------------------------------------------- /images/lseq.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/lseq.PNG -------------------------------------------------------------------------------- /images/o.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/o.PNG -------------------------------------------------------------------------------- /images/obj.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/obj.PNG -------------------------------------------------------------------------------- /images/re.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/re.PNG -------------------------------------------------------------------------------- /images/real.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/real.PNG -------------------------------------------------------------------------------- /images/ri.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/ri.PNG -------------------------------------------------------------------------------- /images/rl.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/rl.PNG -------------------------------------------------------------------------------- /images/rs.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/rs.PNG -------------------------------------------------------------------------------- /images/run-sh.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/run-sh.PNG -------------------------------------------------------------------------------- /images/s.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/s.PNG -------------------------------------------------------------------------------- /images/var.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/var.PNG -------------------------------------------------------------------------------- /images/var1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/var1.PNG -------------------------------------------------------------------------------- /images/vi.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/vi.PNG -------------------------------------------------------------------------------- /images/wh.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kodekloudhub/shell-scripting-for-beginners-course/327837c688219993d92701d29cfa8ec6eff484fd/images/wh.PNG --------------------------------------------------------------------------------