├── practice ├── commandchainingOperators.sh ├── HelloWorld.sh ├── heredocout.txt ├── usageOfHereDoc.sh ├── advanced_echo.sh ├── about_variables.sh ├── debug_script.sh ├── isUserhavingsudo.sh ├── checkDockerIsInstalled.sh ├── demo.sh ├── practice_on_variables.sh ├── inventory_comments_usage.sh ├── blockofcode.sh ├── root_or_not.sh ├── startdockeer.sh └── simpleif.sh ├── 6. AWK Comamnd └── 1.Document-awk command part-1.pdf ├── 4. Grep Command ├── 1.Document-grep-command-part-1.pdf ├── 2.Document-grep-command-part-2.pdf └── ~$2. Read a File Content with condition.pptx ├── 5.Cut Command └── 1.Document-complete-cut-command.pdf ├── 10. Basics of Bash Shell Scripting ├── 6. Here String.pdf ├── 2. Introduction to Variables.pdf ├── 9. Debugging a Bash Shell Script.pdf ├── 4. Advanced usage of echo command.pdf ├── 5. Here Document for Multi-lines or Multi-line block.pdf ├── practice_on_variables.sh.txt ├── 4.color_codes └── 4.color_codes.txt ├── 2. Redirection Operators ├── 1. Redirection Operators.pdf └── ~$2. Read a File Content with condition.pptx ├── 11. Operations on Sctring ├── 1. Basic String Operations.pdf ├── 2. String Operations on Paths.pdf └── ~$10. Usage of declare.pptx ├── 9. Simple useful commands for shell scripting ├── 1. tr command.pdf └── 2. tee command.pdf ├── 3.CommandsToReadFileContent └── 1. Commands to read a file content.pdf ├── 14. test command and command chaining Operators ├── 1.1.Document-test-command-info.pdf ├── 2. Commands Chanining Operators_copy.pdf └── 1.2.Document-file-test-operator.txt ├── 12. Input and Output Commands ├── 1.Document-input-and-out-commands.sh └── 2.Document-command-line-arguments.sh ├── README.md ├── 13.Arithemetic operators for Shell Scripting ├── 2.2.Document-disply-required-files-based-on-extention.sh ├── 2.1.Document-case-with-simple-pattern.sh ├── 2.3.Document-simple-menu-driven-cal.sh └── 1.Document-arithmetic-operations.txt ├── 1.Introduction ├── 3. How to download required documents for this course.txt ├── Basic steps to write and execute a bash shell script.txt └── 4. Steps to Configure Gmail on Ubuntu server to send mails.txt ├── 15. Conditional Statements └── actionsOnDocekr.sh └── LICENSE /practice/commandchainingOperators.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /practice/HelloWorld.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Hello World" 3 | -------------------------------------------------------------------------------- /practice/heredocout.txt: -------------------------------------------------------------------------------- 1 | The user is: automation 2 | The home for this automation is: /home/automation 3 | -------------------------------------------------------------------------------- /practice/usageOfHereDoc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat << Narendra | grep "this" 3 | The user is: $USER 4 | The home for this $USER is: $HOME 5 | Narendra 6 | -------------------------------------------------------------------------------- /practice/advanced_echo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo -e "This is first line\nThis is second line" 3 | 4 | 5 | echo -n "This is third line" 6 | echo "This is fouth line" 7 | 8 | -------------------------------------------------------------------------------- /6. AWK Comamnd/1.Document-awk command part-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/6. AWK Comamnd/1.Document-awk command part-1.pdf -------------------------------------------------------------------------------- /4. Grep Command/1.Document-grep-command-part-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/4. Grep Command/1.Document-grep-command-part-1.pdf -------------------------------------------------------------------------------- /4. Grep Command/2.Document-grep-command-part-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/4. Grep Command/2.Document-grep-command-part-2.pdf -------------------------------------------------------------------------------- /5.Cut Command/1.Document-complete-cut-command.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/5.Cut Command/1.Document-complete-cut-command.pdf -------------------------------------------------------------------------------- /10. Basics of Bash Shell Scripting/6. Here String.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/10. Basics of Bash Shell Scripting/6. Here String.pdf -------------------------------------------------------------------------------- /2. Redirection Operators/1. Redirection Operators.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/2. Redirection Operators/1. Redirection Operators.pdf -------------------------------------------------------------------------------- /practice/about_variables.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | s="Bash Shell Scripting" 3 | echo "Welcome to $s" 4 | echo "$s is powerful in Linux Env" 5 | echo "Now we are workging with varaibles concept of $s" 6 | -------------------------------------------------------------------------------- /11. Operations on Sctring/1. Basic String Operations.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/11. Operations on Sctring/1. Basic String Operations.pdf -------------------------------------------------------------------------------- /11. Operations on Sctring/2. String Operations on Paths.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/11. Operations on Sctring/2. String Operations on Paths.pdf -------------------------------------------------------------------------------- /9. Simple useful commands for shell scripting/1. tr command.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/9. Simple useful commands for shell scripting/1. tr command.pdf -------------------------------------------------------------------------------- /3.CommandsToReadFileContent/1. Commands to read a file content.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/3.CommandsToReadFileContent/1. Commands to read a file content.pdf -------------------------------------------------------------------------------- /9. Simple useful commands for shell scripting/2. tee command.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/9. Simple useful commands for shell scripting/2. tee command.pdf -------------------------------------------------------------------------------- /10. Basics of Bash Shell Scripting/2. Introduction to Variables.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/10. Basics of Bash Shell Scripting/2. Introduction to Variables.pdf -------------------------------------------------------------------------------- /11. Operations on Sctring/~$10. Usage of declare.pptx: -------------------------------------------------------------------------------- 1 | 2 | SRI VASTAV 3 | SRI VASTAV -------------------------------------------------------------------------------- /10. Basics of Bash Shell Scripting/9. Debugging a Bash Shell Script.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/10. Basics of Bash Shell Scripting/9. Debugging a Bash Shell Script.pdf -------------------------------------------------------------------------------- /4. Grep Command/~$2. Read a File Content with condition.pptx: -------------------------------------------------------------------------------- 1 | 2 | SRI VASTAV 3 | SRI VASTAV -------------------------------------------------------------------------------- /10. Basics of Bash Shell Scripting/4. Advanced usage of echo command.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/10. Basics of Bash Shell Scripting/4. Advanced usage of echo command.pdf -------------------------------------------------------------------------------- /2. Redirection Operators/~$2. Read a File Content with condition.pptx: -------------------------------------------------------------------------------- 1 | 2 | SRI VASTAV 3 | SRI VASTAV -------------------------------------------------------------------------------- /practice/debug_script.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #set -n 3 | #set -x 4 | #set -e 5 | #set -v 6 | pwd 7 | date 8 | asdfasdf 9 | user=$(whoami 10 | echo "This is about debugging a bash shell script" 11 | echo "The user is: $user" 12 | -------------------------------------------------------------------------------- /14. test command and command chaining Operators/1.1.Document-test-command-info.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/14. test command and command chaining Operators/1.1.Document-test-command-info.pdf -------------------------------------------------------------------------------- /practice/isUserhavingsudo.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | sudo -v 1>/dev/null 2>/dev/null && echo "The user $(id -un) is having sudo privilages on this host $(hostname)" || echo "The user $(id -un) is not having sudo privilages on this host $(hostname)" 4 | -------------------------------------------------------------------------------- /practice/checkDockerIsInstalled.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | which docker 2>&1 1>/dev/null 3 | if [[ $? -eq 0 ]] 4 | then 5 | echo "Docker is installed on this host $(hostname -s)" 6 | else 7 | echo "Docker is not installed on this host $(hostname -s)" 8 | fi 9 | -------------------------------------------------------------------------------- /14. test command and command chaining Operators/2. Commands Chanining Operators_copy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/14. test command and command chaining Operators/2. Commands Chanining Operators_copy.pdf -------------------------------------------------------------------------------- /10. Basics of Bash Shell Scripting/5. Here Document for Multi-lines or Multi-line block.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NarendraPAutomationEngineer/BashShellScriptingTutorials/HEAD/10. Basics of Bash Shell Scripting/5. Here Document for Multi-lines or Multi-line block.pdf -------------------------------------------------------------------------------- /practice/demo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | dockerStatus=$(systemctl status docker | awk '/Active/ { print $3 }' | tr -d "[()]") 3 | dockerVersion=$(docker -v | awk '/version/ { print $3 }' | tr -d ",") 4 | echo "The Docker Status is: $dockerStatus 5 | The Docker version is: $dockerVersion" 6 | -------------------------------------------------------------------------------- /12. Input and Output Commands/1.Document-input-and-out-commands.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | << mycom 3 | read -p "Enter your name: " my_name 4 | my_name_up=${my_name^^} 5 | echo "Your name in upper-case is: $my_name_up" 6 | mycom 7 | 8 | read -p "Enter your name: " 9 | echo "$REPLY" 10 | -------------------------------------------------------------------------------- /practice/practice_on_variables.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | dockerStatus=$(systemctl status docker | awk '/Active/ { print $3 }' | tr -d "[()]") 3 | dockerVersion=$(docker -v | awk '/version/ { print $3 }' | tr -d ",") 4 | echo "The Docker Status is: $dockerStatus" 5 | echo "The Docker version is: $dockerVersion" 6 | -------------------------------------------------------------------------------- /practice/inventory_comments_usage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Authore: Narendra 3 | 4 | << MYCOM 5 | Created: Aug-2020 6 | Version: 1.0 7 | Pupose: Inventory Script 8 | MYCOM 9 | 10 | : ' 11 | This is about ainventory 12 | and its works for Linux Systems 13 | ' 14 | 15 | echo "This is an Inventory Script" 16 | 17 | -------------------------------------------------------------------------------- /10. Basics of Bash Shell Scripting/practice_on_variables.sh.txt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | dockerStatus=$(systemctl status docker | awk '/Active/ { print $3 }' | tr -d "[()]") 3 | dockerVersion=$(docker -v | awk '/version/ { print $3 }' | tr -d ",") 4 | echo "The Docker Status is: $dockerStatus" 5 | echo "The Docker version is: $dockerVersion" 6 | -------------------------------------------------------------------------------- /12. Input and Output Commands/2.Document-command-line-arguments.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | << mycom 3 | echo "$0" 4 | echo "$1" 5 | echo "$2" 6 | echo "$3" 7 | echo "${10}" 8 | mycom 9 | 10 | echo "The number command line arguments: $#" 11 | echo "All command line arguments are: $*" 12 | echo "All command line arguments are: $@" 13 | -------------------------------------------------------------------------------- /practice/blockofcode.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #{ ls ; pwd ; date ; } 3 | 4 | #which docker && { echo "Docker is intalled on this host" ; echo "The docker version is: $(docker -v)" ; } 5 | 6 | which apache2 2>&1 1>/dev/null && { echo "Apache is installed" ; echo "apache versin info is: $(apache2 -v)" ; } || echo "apache is not installed" 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BashShellScriptingTutorials 2 | Automation with Bash Shell Scripting Tutorials 3 | ## Learn Bash Shell Scripting Course freely for first 14 days from [SkillShare](https://www.skillshare.com/r/user/narendrap) 4 | 5 | # OR 6 | ## Get Same Course From Udemy and use this link to get coupon codes: (https://www.youtube.com/watch?v=k7dGgbrI5dQ) 7 | -------------------------------------------------------------------------------- /13.Arithemetic operators for Shell Scripting/2.2.Document-disply-required-files-based-on-extention.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | clear 3 | read -p "Enter your file extention: " ext 4 | case $ext in 5 | ".txt") 6 | ls -lrt *.txt 7 | ;; 8 | ".sh") 9 | ls -lrt *.sh 10 | ;; 11 | *) 12 | echo "Sorry!. You entered invalid file extention" 13 | ;; 14 | esac 15 | -------------------------------------------------------------------------------- /practice/root_or_not.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | 4 | #userId=$(id -u) 5 | # [[ $userId -eq 0 ]] && echo "You are root" || echo "You are not root" 6 | 7 | #[[ $(id -u) -eq 0 ]] && echo "You are root" || echo "You are not root" 8 | 9 | if [[ $(id -u) -eq 0 ]] 10 | then 11 | echo "You are root" 12 | else 13 | echo "You are not root" 14 | fi 15 | 16 | -------------------------------------------------------------------------------- /1.Introduction/3. How to download required documents for this course.txt: -------------------------------------------------------------------------------- 1 | Git Repo url is: https://github.com/NarendraPAutomationEngineer/BashShellScriptingTutorials 2 | 3 | Open git bash/linux terminal and run below command to download repo: 4 | 5 | git clone https://github.com/NarendraPAutomationEngineer/BashShellScriptingTutorials.git 6 | 7 | Note: Above command will download BashShellScriptingTutorials repo -------------------------------------------------------------------------------- /13.Arithemetic operators for Shell Scripting/2.1.Document-case-with-simple-pattern.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | read -p "Enter any number: " num 3 | case $num in 4 | [0-9]) 5 | echo "you enterd single number" 6 | ;; 7 | [a-z]) 8 | echo "you entered lower case alph" 9 | ;; 10 | [A-Z]) 11 | echo "you enterd upper case alph" 12 | ;; 13 | *) 14 | echo "Unable to identify your input" 15 | ;; 16 | 17 | esac 18 | -------------------------------------------------------------------------------- /13.Arithemetic operators for Shell Scripting/2.3.Document-simple-menu-driven-cal.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | clear 3 | read -p "Enter num-1: " a 4 | read -p "Enter num-2: " b 5 | echo "=========================" 6 | echo "Enter 1. Addition" 7 | echo " 2. Sub" 8 | echo " 3. Mul" 9 | echo " 4. Div" 10 | echo "=========================" 11 | read -p "Enter your option(1-4): " opt 12 | 13 | case $opt in 14 | 1) 15 | echo "The addition of $a and $b is: $((a+b))" 16 | ;; 17 | 2) 18 | echo "The sub of $a and $b is: $((a-b))" 19 | ;; 20 | 3) 21 | echo "The mul of $a and $b is: $((a*b))" 22 | ;; 23 | 4) echo "The div of $a with $b is: $((a/b))" 24 | ;; 25 | *) 26 | echo "Your entered invalid option" 27 | ;; 28 | 29 | esac 30 | -------------------------------------------------------------------------------- /13.Arithemetic operators for Shell Scripting/1.Document-arithmetic-operations.txt: -------------------------------------------------------------------------------- 1 | Arithmetic Operators: 2 | ==================== 3 | Addition + 4 | Subtraction - 5 | Multiplication * 6 | Division / 7 | Remainder % 8 | Increment ++ (To increment your value by one; example if x=2 then ((x++)) means x value will increase by 1 and it is 3 now. 9 | Decrement -- 10 | If your data is integers then use (()) syntax to perform arithmetic operations else use bc (bash calculator). 11 | 12 | Integer Example: 13 | x=4 14 | y=7 15 | ((sum=x+y)) 16 | echo "The addition of $x and $y is: $sum" 17 | Float/integer Example: 18 | Note: bc calculator is a commmand to perform arithemtic operations on either integers or float numbers. 19 | x=4.5 20 | y=6.7 21 | sum=$(bc<<<"scale=3;$x+$y") 22 | echo "The addtion of $x and $y is: $sum" -------------------------------------------------------------------------------- /practice/startdockeer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ $(id -u) -eq 0 ]] 4 | then 5 | 6 | if systemctl status docker 1>/dev/null 2>/dev/null 7 | then 8 | echo "Already docker is up and running" 9 | else 10 | echo "Starting docker service...." 11 | systemctl start docker 12 | echo "Successfully started docker service" 13 | fi 14 | 15 | else 16 | if sudo -v 1>/dev/null 2>/dev/null 17 | then 18 | if systemctl status docker 1>/dev/null 2>/dev/null 19 | then 20 | echo "Already docker is up and running" 21 | else 22 | echo "Starting docker service...." 23 | sudo systemctl start docker 24 | echo "Successfully started docker service" 25 | fi 26 | else 27 | echo "Sorry, you are not allowed to start docker service, because you are not the root user and also you dont have suod previlages to start it" 28 | fi 29 | fi 30 | 31 | -------------------------------------------------------------------------------- /15. Conditional Statements/actionsOnDocekr.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ###################################################### 3 | # Author: Narendraa # 4 | # Date: Aug-2020 # 5 | # Usage is: start,stop,restart and version of docker # 6 | ###################################################### 7 | 8 | if [[ $(id -u) -ne 0 ]] 9 | then 10 | echo "You are not allowed to run this script" 11 | exit 1 12 | fi 13 | 14 | 15 | read -p "Enter your option: " option 16 | 17 | if [[ $option == start ]] 18 | then 19 | echo "Starting docker...." 20 | systemctl start docker 21 | elif [[ $option == stop ]] 22 | then 23 | echo "Stopping docker...." 24 | systemctl stop docker 25 | elif [[ $option == restart ]] 26 | then 27 | echo "Restarting docker...." 28 | systemctl restart docker 29 | elif [[ $option == version ]] 30 | then 31 | version=$(docker -v | cut -d " " -f 3 | tr -d ",") 32 | echo "The version of docker is: $version" 33 | else 34 | echo "You option is invalid" 35 | echo "Valid Options are: start stop restart and version" 36 | fi 37 | -------------------------------------------------------------------------------- /practice/simpleif.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | << simpleif 3 | #which docker && { echo "Docker is intalled on this host" ; echo "The docker version is: $(docker -v)" ; } 4 | 5 | if which docker 2>/dev/null 1>/dev/null 6 | then 7 | echo "Docker is intalled on this host" 8 | echo "The docker version is: $(docker -v)" 9 | fi 10 | 11 | 12 | which docker 2>&1 1>/dev/null 13 | if [[ $? -eq 0 ]] 14 | then 15 | echo "Docker is intalled on this host" 16 | echo "The docker version is: $(docker -v)" 17 | fi 18 | 19 | 20 | if true 21 | then 22 | echo "Always this will execute" 23 | fi 24 | 25 | 26 | if false 27 | then 28 | echo "It wont execute" 29 | fi 30 | 31 | simpleif 32 | 33 | #which apache2 2>&1 1>/dev/null && { echo "Apache is installed" ; echo "apache versin info is: $(apache2 -v)" ; } || echo "apache is not installed" 34 | 35 | if which apache2 2>&1 1>/dev/null 36 | then 37 | echo "Apache is installed" 38 | echo "apache versin info is: $(apache2 -v)" 39 | else 40 | echo "apache is not installed" 41 | fi 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /1.Introduction/Basic steps to write and execute a bash shell script.txt: -------------------------------------------------------------------------------- 1 | Steps to create any user on Ubuntu server: 2 | 3 | useradd automation 4 | passwd automation 5 | Check UserHome: ls -lrt /home/automation 6 | if user home is not created then run below two commands: 7 | mkdir -p /home/automation 8 | chown -R automation:automation /home/automation 9 | How to change a shell for the user ? 10 | 11 | simply run below command and provide the password and path of the required shell. 12 | Command is: chsh 13 | 14 | Steps to create and execute a shell script: 15 | ============================================ 16 | Step1: Get Manual Commands for the requirement 17 | Step2: Select any command line editor like vi, vim and nano to write a script. 18 | Step3: Write a Bash shell script 19 | - Now open a text file with anyName and with any extension but will take .sh just to represent that text file is a shell script. 20 | - Write first line as a shebang line. 21 | - Paste all required commands in a sequence 22 | Step4: Executing Bash Shell Script 23 | - Provide the Execution Permission using chmod +x script_name.sh 24 | - Run with ./script_name.sh or /script_name.sh 25 | ========================================================================== 26 | 27 | -------------------------------------------------------------------------------- /1.Introduction/4. Steps to Configure Gmail on Ubuntu server to send mails.txt: -------------------------------------------------------------------------------- 1 | Steps: 2 | step1: Get Gmail Id and Password 3 | Step2: login into ubuntu and switch to root using: sudo su - 4 | Step3: Run below commands: 5 | apt-get update -y 6 | apt-get install sendmail mailutils -y 7 | Step4: Create authentication file 8 | cd /etc/mail 9 | mkdir -m 700 authinfo 10 | cd authinfo/ 11 | vi gmail 12 | add the below conntent 13 | 14 | AuthInfo: "U:root" "I:your-mail@gmail.com" "P:your-password" 15 | 16 | Now edit your mail id and password 17 | 18 | Step5: create hash map of the file: 19 | makemap hash gmail < gmail 20 | Step6: Got to /etc/mail and open sendmail.mc 21 | then Add the following lines to sendmail.mc file right above MAILER_DEFINITIONS: 22 | #GMail settings: 23 | define(`SMART_HOST',`[smtp.gmail.com]')dnl 24 | define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl 25 | define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl 26 | define(`confAUTH_OPTIONS', `A p')dnl 27 | TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl 28 | define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl 29 | FEATURE(`authinfo',`hash -o /etc/mail/authinfo/gmail.db')dnl 30 | 31 | 32 | Step7: Now run below two command from /etc/mail 33 | make 34 | /etc/init.d/sendmail reload 35 | Step8: Now open https://www.google.com/settings/security/lesssecureapps 36 | and Allow less secure apps: ON 37 | Step9: Verify the test mail using 38 | echo "Demo" | mail -s "Status of Httpd" dowithscripting@gmail.com 39 | 40 | echo "Demo" | mail -s "Status of Httpd" dowithscripting@gmail.com -A demo.txt -------------------------------------------------------------------------------- /14. test command and command chaining Operators/1.2.Document-file-test-operator.txt: -------------------------------------------------------------------------------- 1 | File test operators: 2 | -------------------- 3 | 4 | [ -d file ] -- It return true if the file/path is directory else false 5 | [ -f file ] -- It return true if the file/path is a file else false 6 | [ -e file ] -- It return true if the file/path is exists else false 7 | [ -r file ] -- It return true if the file/path is readable else false 8 | [ -w file ] -- It return true if the file/path is writable else false 9 | [ -x file ] -- It return true if the file/path is executable else false 10 | 11 | ----------------------------------------------------------------------------- 12 | Advanced file test operators are listed below: 13 | 14 | a : True if the file exists. 15 | b : True if the file exists and is a block special file. 16 | c : True if the file exists and is a character special file. 17 | d : True if the file exists and is a directory. 18 | e : True if the file exists. 19 | f : True if the file exists and is a regular file. 20 | g : True if the file exists and its SGID bit is set. 21 | h : True if the file exists and is a symbolic link. 22 | k : True if the file exists and its sticky bit is set. 23 | p : True if the file exists and is a named pipe (FIFO). 24 | r : True if the file exists and is readable. 25 | s : True if the file exists and has a size greater than zero. 26 | t : True if file descriptor is open and refers to a terminal. 27 | u : True if the file exists and its SUID (set user ID) bit is set. 28 | w : True if the file exists and is writable. 29 | x : True if the file exists and is executable. 30 | O : True if the file exists and is owned by the effective user ID. 31 | G : True if the file exists and is owned by the effective group ID. 32 | L : True if the file exists and is a symbolic link. 33 | N : True if the file exists and has been modified since it was last read. 34 | S : True if the file exists and is a socket. 35 | ============================================================================== -------------------------------------------------------------------------------- /10. Basics of Bash Shell Scripting/4.color_codes: -------------------------------------------------------------------------------- 1 | # Reset 2 | Color_Off='\033[0m' # Text Reset 3 | 4 | # Regular Colors 5 | Black='\033[0;30m' # Black 6 | Red='\033[0;31m' # Red 7 | Green='\033[0;32m' # Green 8 | Yellow='\033[0;33m' # Yellow 9 | Blue='\033[0;34m' # Blue 10 | Purple='\033[0;35m' # Purple 11 | Cyan='\033[0;36m' # Cyan 12 | White='\033[0;37m' # White 13 | 14 | # Bold 15 | BBlack='\033[1;30m' # Black 16 | BRed='\033[1;31m' # Red 17 | BGreen='\033[1;32m' # Green 18 | BYellow='\033[1;33m' # Yellow 19 | BBlue='\033[1;34m' # Blue 20 | BPurple='\033[1;35m' # Purple 21 | BCyan='\033[1;36m' # Cyan 22 | BWhite='\033[1;37m' # White 23 | 24 | # Underline 25 | UBlack='\033[4;30m' # Black 26 | URed='\033[4;31m' # Red 27 | UGreen='\033[4;32m' # Green 28 | UYellow='\033[4;33m' # Yellow 29 | UBlue='\033[4;34m' # Blue 30 | UPurple='\033[4;35m' # Purple 31 | UCyan='\033[4;36m' # Cyan 32 | UWhite='\033[4;37m' # White 33 | 34 | # Background 35 | On_Black='\033[40m' # Black 36 | On_Red='\033[41m' # Red 37 | On_Green='\033[42m' # Green 38 | On_Yellow='\033[43m' # Yellow 39 | On_Blue='\033[44m' # Blue 40 | On_Purple='\033[45m' # Purple 41 | On_Cyan='\033[46m' # Cyan 42 | On_White='\033[47m' # White 43 | 44 | # High Intensity 45 | IBlack='\033[0;90m' # Black 46 | IRed='\033[0;91m' # Red 47 | IGreen='\033[0;92m' # Green 48 | IYellow='\033[0;93m' # Yellow 49 | IBlue='\033[0;94m' # Blue 50 | IPurple='\033[0;95m' # Purple 51 | ICyan='\033[0;96m' # Cyan 52 | IWhite='\033[0;97m' # White 53 | 54 | # Bold High Intensity 55 | BIBlack='\033[1;90m' # Black 56 | BIRed='\033[1;91m' # Red 57 | BIGreen='\033[1;92m' # Green 58 | BIYellow='\033[1;93m' # Yellow 59 | BIBlue='\033[1;94m' # Blue 60 | BIPurple='\033[1;95m' # Purple 61 | BICyan='\033[1;96m' # Cyan 62 | BIWhite='\033[1;97m' # White 63 | 64 | # High Intensity backgrounds 65 | On_IBlack='\033[0;100m' # Black 66 | On_IRed='\033[0;101m' # Red 67 | On_IGreen='\033[0;102m' # Green 68 | On_IYellow='\033[0;103m' # Yellow 69 | On_IBlue='\033[0;104m' # Blue 70 | On_IPurple='\033[0;105m' # Purple 71 | On_ICyan='\033[0;106m' # Cyan 72 | On_IWhite='\033[0;107m' # White 73 | -------------------------------------------------------------------------------- /10. Basics of Bash Shell Scripting/4.color_codes.txt: -------------------------------------------------------------------------------- 1 | # Reset 2 | Color_Off='\033[0m' # Text Reset 3 | 4 | # Regular Colors 5 | Black='\033[0;30m' # Black 6 | Red='\033[0;31m' # Red 7 | Green='\033[0;32m' # Green 8 | Yellow='\033[0;33m' # Yellow 9 | Blue='\033[0;34m' # Blue 10 | Purple='\033[0;35m' # Purple 11 | Cyan='\033[0;36m' # Cyan 12 | White='\033[0;37m' # White 13 | 14 | # Bold 15 | BBlack='\033[1;30m' # Black 16 | BRed='\033[1;31m' # Red 17 | BGreen='\033[1;32m' # Green 18 | BYellow='\033[1;33m' # Yellow 19 | BBlue='\033[1;34m' # Blue 20 | BPurple='\033[1;35m' # Purple 21 | BCyan='\033[1;36m' # Cyan 22 | BWhite='\033[1;37m' # White 23 | 24 | # Underline 25 | UBlack='\033[4;30m' # Black 26 | URed='\033[4;31m' # Red 27 | UGreen='\033[4;32m' # Green 28 | UYellow='\033[4;33m' # Yellow 29 | UBlue='\033[4;34m' # Blue 30 | UPurple='\033[4;35m' # Purple 31 | UCyan='\033[4;36m' # Cyan 32 | UWhite='\033[4;37m' # White 33 | 34 | # Background 35 | On_Black='\033[40m' # Black 36 | On_Red='\033[41m' # Red 37 | On_Green='\033[42m' # Green 38 | On_Yellow='\033[43m' # Yellow 39 | On_Blue='\033[44m' # Blue 40 | On_Purple='\033[45m' # Purple 41 | On_Cyan='\033[46m' # Cyan 42 | On_White='\033[47m' # White 43 | 44 | # High Intensity 45 | IBlack='\033[0;90m' # Black 46 | IRed='\033[0;91m' # Red 47 | IGreen='\033[0;92m' # Green 48 | IYellow='\033[0;93m' # Yellow 49 | IBlue='\033[0;94m' # Blue 50 | IPurple='\033[0;95m' # Purple 51 | ICyan='\033[0;96m' # Cyan 52 | IWhite='\033[0;97m' # White 53 | 54 | # Bold High Intensity 55 | BIBlack='\033[1;90m' # Black 56 | BIRed='\033[1;91m' # Red 57 | BIGreen='\033[1;92m' # Green 58 | BIYellow='\033[1;93m' # Yellow 59 | BIBlue='\033[1;94m' # Blue 60 | BIPurple='\033[1;95m' # Purple 61 | BICyan='\033[1;96m' # Cyan 62 | BIWhite='\033[1;97m' # White 63 | 64 | # High Intensity backgrounds 65 | On_IBlack='\033[0;100m' # Black 66 | On_IRed='\033[0;101m' # Red 67 | On_IGreen='\033[0;102m' # Green 68 | On_IYellow='\033[0;103m' # Yellow 69 | On_IBlue='\033[0;104m' # Blue 70 | On_IPurple='\033[0;105m' # Purple 71 | On_ICyan='\033[0;106m' # Cyan 72 | On_IWhite='\033[0;107m' # White 73 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------