Introduction to Linux and history

Learning outcomes:

  • Create and use a basic shellscript that includes a shebang line, comment and echo
  • Explain the different quotes and their uses
  • Modify a script using a text editor

Would you like to download my PowerPoint to follow along?

  • What is a script and why do we care?
    • Small programs that can be used for multiple things including repetitive tasks and repeated activities
    • A text file with 1 command per line
    • Scripts are also good for Complicated things you don't use often, If you need to figure it out once, why not make a script so you don't have to do it again?
    • Comments use a #
    • Always start with shbang to specify shell type, it's not required, but it makes it more clear what kind of script you're writing
    • An example tutorial for scripting can be found here includes some history of scripting and BASH as well
  • Types of text in scripts/li>
    • Plain (no quotes)
      echo hello
    • Semi-opaque (double quotes, expands variables)
      echo "hello $name"
    • Opaque (single quote, shows exactly what's in quotes)
       echo 'hello $name'
  • Important things to know
    • Backticks
      `this is an example of a backtick`
    • Shbang line
      #!/bin/sh
    • To run, file must be executable (it's not by default so you will need to change the file permissions There is a video example of me showing how to do that here)
    • To run you need to use the path of your script (unless in PATH)
    • It is important to TEST YOUR CODE
  • Sequence of a successful script
    • Test commands at command prompt
    • Create and edit the file in an editor (VIM)
    • Start script with shbang line ( such as: #!/bin/bash)
    • Add comment with function, name and date
    • Save
    • Change permissions
    • Test!!
    • Rinse and repeat

Suggested Activities and Discussion Topics:

  • Watch this video and follow along to create a shell script.
  • Activity: Listen to This Podcast That was created using AI from these materials. Transcript for the Podcast What are your thoughts? Did the AI do a good job representing the materials? Did you find any mistakes?
  • Go through This AI generated study guide, what do you think? Did it capture the week materials well? How did you do on the self quiz? Do you know all the vocab used?
  • Go through This AI generated briefing document, what do you think? Did it capture the week materials well? Was there anything it missed? Do you know all the vocab used?

Would you like to see some more classes? Click here