SlideShare a Scribd company logo
RedHat Enterprise Linux Essential
        Unit 6: The bash shell
Objectives
Upon completion of this unit, you should be able to:
 Use command-line shortcuts

 Use command-line expansion

 Use history and editing tricks

 Use the gnome-terminal
Bash Introduction

 "bourne Again Shell"

 Successor to sh, the original Unix shell
Bash Introduction
Bash Heritage
Command Line Shortcuts: File Globbing

 Globbing is wildcard expansion:

      .*                  matches zero or more characters

      .?                  matches any single character

      .[a-z]              matches a range of characters

      . [^a-z]            matches all except the range

ex:   touch test1.txt test2.txt test11.txt test1.mp3 test2.mp3

      ls *.txt ; ls test??.txt ; ls test[1-2].txt; ls test[^1].*
Command Line Shortcuts: The Tab Key

 Type Tab to complete command lines:
    For the command name, it will complete a command name

    For an argument, it will complete a file name

 Examples:
       $ xte<Tab>
       $ xterm
       $ ls myf<Tab>
       $ ls myfile.txt
Command Line Shortcuts: history


 Ex: history

 Try: !3

 Try: ^2^1

  example: ping 192.168.1.2

  try: ^2^1
Command Line Expansion: Tilde (~)

 Ex:    pwd

 cd ~

 cd /etc/

 cd ~

 cd ~user1
Command Line Expansion: Variable and Curly braces ({})



 echo $HOME

 cd /tmp

 touch {a,b}

 touch a{a,b}

 touch {a,b}.{1,2}
Command Line Expansion : Command and Math
Command Line Expansion : Command and Math


 hostname => localhost.localdomain (?)

 echo 'Hostname: "

 Echo Hostname: `hostname`“ ; echo Hostname:$(hostname)"

 Math: echo a, echo $HOME,

  echo $a . a=3 , echo $a

  echo $[$a + $c] ; echo $[$b + $c];

  echo $[$c / $b]; echo $[$b%$c]

  echo $[$a**$c]
Command Line Expansion: Backslash ()


 Backslash () is the escape character and makes the next
  character literal

       ex : echo Your cost is $5.00

 Used and last character on line to "continue command on
  next line“

  ex : ls
Command line expansion: Quotes

 Single quotes (')      inhibit all expansion

 Double quotes ('')     inhibit all expansion,

    except:
       • $

       •   `

       •   

       •   !
History Tricks

 use the up and down arrow keys to scroll throuht previous commans

 Type <CTRL-R> to search for a command in command history.

    (reverse-i-search)":

 To recall last argument from previous command:
    <ESC>.

    <ALT + .>

   Ex: ping 192.168.1.1

       telnet   <ESC> .
Command Editing Tricks
 Ctrl-a moves to beginning of line

 Ctrl-e moves to end of line

 Ctrl-u deletes to beginning of line

 Ctrl-k deletes to end of line

 Ctrl-arrow moves left or right by word
gnome - terminal
 Applications/ System Tools / Terminal

 <Ctr - shift -t>             open a new tab

 <Ctrl - pgUp/ PgDn>          Next/ Prev tab

 <Alt-"N">                    changr to go to "N" tab

 <Ctrl - Shift-c/v>           Copy/ Paste

 <Ctrl-Shift-w>               Close a tab
Scripting Basics
 Shell scripts are text files that contain a series of commands or
  statements to be executed.

 Shell scripts are useful for:
    Automating commonly used commands

    Performing system administration and troubleshooting

    Creating simple applications

    Manipulation of text or files
Creating Shell Scripts
 Step 1: Use such as vi to create a text file containing
  commands
    First line contains the magic shebang sequence: #!

      • #!/bin/bash

 Comment your scripts!
    Comments start with a #
Creating Shell Scripts
                             continued
 Step 2: Make the script executable:

       $ chmod u+x myscript.sh

 To execute the new script:
    Place the script file in a directory in the executable path -OR-

    Specify the absolute or relative path to the script on the command line
Sample Shell Script
#!/bin/bash

# This script displays some information about your
  environment

echo "Greetings. The date and time are $(date)"

echo "Your working directory is: $(pwd)"
Unit 6 bash shell

More Related Content

PDF
Unit 11 configuring the bash shell – shell script
PDF
Unit 5 vim an advanced text editor
PPTX
Shell scripting
PDF
PPTX
Unix - Shell Scripts
PDF
Quick start bash script
ODP
PPTX
Linux Basic commands and VI Editor
Unit 11 configuring the bash shell – shell script
Unit 5 vim an advanced text editor
Shell scripting
Unix - Shell Scripts
Quick start bash script
Linux Basic commands and VI Editor

What's hot (20)

PPT
Linux shell scripting
PPTX
SHELL PROGRAMMING
PPT
Shell programming
PPTX
Basics of shell programming
PPTX
Linux shell env
PDF
Shell scripting
PPTX
Shell & Shell Script
ODP
Shellscripting
PPTX
system management -shell programming by gaurav raikar
PPTX
Pipes and filters
PDF
Unix shell scripting tutorial
PDF
Scripting and the shell in LINUX
PPT
Unix Shell Scripting Basics
ODP
DevChatt 2010 - *nix Cmd Line Kung Foo
PDF
Unix Commands
PDF
Intro to Linux Shell Scripting
PDF
Unix Shell Scripting
PDF
Linux basic commands with examples
PPTX
Linux basics
PDF
Course 102: Lecture 7: Simple Utilities
Linux shell scripting
SHELL PROGRAMMING
Shell programming
Basics of shell programming
Linux shell env
Shell scripting
Shell & Shell Script
Shellscripting
system management -shell programming by gaurav raikar
Pipes and filters
Unix shell scripting tutorial
Scripting and the shell in LINUX
Unix Shell Scripting Basics
DevChatt 2010 - *nix Cmd Line Kung Foo
Unix Commands
Intro to Linux Shell Scripting
Unix Shell Scripting
Linux basic commands with examples
Linux basics
Course 102: Lecture 7: Simple Utilities
Ad

Viewers also liked (6)

PDF
Unit 4 user and group
PDF
Unit2 help
PDF
Unit 13 network client
PDF
Unit 9 basic system configuration tools
PPTX
Administration 1 sw2012
PDF
Unit 12 finding and processing files
Unit 4 user and group
Unit2 help
Unit 13 network client
Unit 9 basic system configuration tools
Administration 1 sw2012
Unit 12 finding and processing files
Ad

Similar to Unit 6 bash shell (20)

PPT
Using Unix
PDF
Session3
PPT
Linux commands
PPT
PPT
101 3.1 gnu and unix commands
PPT
Unix tutorial-08
PPTX
OS-Module 2 Linux Programming Important topics
PDF
60761 linux
PDF
basic shell scripting syntex
PPTX
Shell Scripting and Programming.pptx
PPTX
Shell Scripting and Programming.pptx
PPT
IntroCommandLine.ppt
PPT
IntroCommandLine.ppt
ODP
PPT
ODP
PDF
Complete Guide for Linux shell programming
PPT
Introduction to shell scripting ____.ppt
Using Unix
Session3
Linux commands
101 3.1 gnu and unix commands
Unix tutorial-08
OS-Module 2 Linux Programming Important topics
60761 linux
basic shell scripting syntex
Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptx
IntroCommandLine.ppt
IntroCommandLine.ppt
Complete Guide for Linux shell programming
Introduction to shell scripting ____.ppt

Recently uploaded (20)

PDF
KodekX | Application Modernization Development
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Machine learning based COVID-19 study performance prediction
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
KodekX | Application Modernization Development
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Empathic Computing: Creating Shared Understanding
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
NewMind AI Weekly Chronicles - August'25 Week I
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
MIND Revenue Release Quarter 2 2025 Press Release
Machine learning based COVID-19 study performance prediction
Unlocking AI with Model Context Protocol (MCP)
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Electronic commerce courselecture one. Pdf
Digital-Transformation-Roadmap-for-Companies.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Review of recent advances in non-invasive hemoglobin estimation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
sap open course for s4hana steps from ECC to s4
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...

Unit 6 bash shell

  • 1. RedHat Enterprise Linux Essential Unit 6: The bash shell
  • 2. Objectives Upon completion of this unit, you should be able to:  Use command-line shortcuts  Use command-line expansion  Use history and editing tricks  Use the gnome-terminal
  • 3. Bash Introduction  "bourne Again Shell"  Successor to sh, the original Unix shell
  • 6. Command Line Shortcuts: File Globbing  Globbing is wildcard expansion: .* matches zero or more characters .? matches any single character .[a-z] matches a range of characters . [^a-z] matches all except the range ex: touch test1.txt test2.txt test11.txt test1.mp3 test2.mp3 ls *.txt ; ls test??.txt ; ls test[1-2].txt; ls test[^1].*
  • 7. Command Line Shortcuts: The Tab Key  Type Tab to complete command lines:  For the command name, it will complete a command name  For an argument, it will complete a file name  Examples: $ xte<Tab> $ xterm $ ls myf<Tab> $ ls myfile.txt
  • 8. Command Line Shortcuts: history  Ex: history  Try: !3  Try: ^2^1 example: ping 192.168.1.2 try: ^2^1
  • 9. Command Line Expansion: Tilde (~)  Ex: pwd  cd ~  cd /etc/  cd ~  cd ~user1
  • 10. Command Line Expansion: Variable and Curly braces ({})  echo $HOME  cd /tmp  touch {a,b}  touch a{a,b}  touch {a,b}.{1,2}
  • 11. Command Line Expansion : Command and Math
  • 12. Command Line Expansion : Command and Math  hostname => localhost.localdomain (?)  echo 'Hostname: "  Echo Hostname: `hostname`“ ; echo Hostname:$(hostname)"  Math: echo a, echo $HOME, echo $a . a=3 , echo $a echo $[$a + $c] ; echo $[$b + $c]; echo $[$c / $b]; echo $[$b%$c] echo $[$a**$c]
  • 13. Command Line Expansion: Backslash ()  Backslash () is the escape character and makes the next character literal ex : echo Your cost is $5.00  Used and last character on line to "continue command on next line“ ex : ls
  • 14. Command line expansion: Quotes  Single quotes (') inhibit all expansion  Double quotes ('') inhibit all expansion,  except: • $ • ` • • !
  • 15. History Tricks  use the up and down arrow keys to scroll throuht previous commans  Type <CTRL-R> to search for a command in command history.  (reverse-i-search)":  To recall last argument from previous command:  <ESC>.  <ALT + .> Ex: ping 192.168.1.1 telnet <ESC> .
  • 16. Command Editing Tricks  Ctrl-a moves to beginning of line  Ctrl-e moves to end of line  Ctrl-u deletes to beginning of line  Ctrl-k deletes to end of line  Ctrl-arrow moves left or right by word
  • 17. gnome - terminal  Applications/ System Tools / Terminal  <Ctr - shift -t> open a new tab  <Ctrl - pgUp/ PgDn> Next/ Prev tab  <Alt-"N"> changr to go to "N" tab  <Ctrl - Shift-c/v> Copy/ Paste  <Ctrl-Shift-w> Close a tab
  • 18. Scripting Basics  Shell scripts are text files that contain a series of commands or statements to be executed.  Shell scripts are useful for:  Automating commonly used commands  Performing system administration and troubleshooting  Creating simple applications  Manipulation of text or files
  • 19. Creating Shell Scripts  Step 1: Use such as vi to create a text file containing commands  First line contains the magic shebang sequence: #! • #!/bin/bash  Comment your scripts!  Comments start with a #
  • 20. Creating Shell Scripts continued  Step 2: Make the script executable: $ chmod u+x myscript.sh  To execute the new script:  Place the script file in a directory in the executable path -OR-  Specify the absolute or relative path to the script on the command line
  • 21. Sample Shell Script #!/bin/bash # This script displays some information about your environment echo "Greetings. The date and time are $(date)" echo "Your working directory is: $(pwd)"