Chapter 3 Running Programs

3.1 Learning objectives

  • Run UNIX commands

  • Wrap UNIX commands in a Bash script

  • Make a Bash script executable

  • Run a Bash script

3.2 Run UNIX commands

  • Start a terminal

  • Run the ls -l command to list files (the -l is a command line argument that instructs the ls program to modify its operation so that longer details are provided about each file)

  • Run echo "Hello, World!" to print text to the terminal

3.3 Wrap commands in a Bash script

  • Create Text File

  • Write your first Bash script

    • Add the following and save the file as 00-hello.sh

3.4 Run a Bash script

Now go back to the terminal:

  • Change to the workspace directory where you saved the file using the cd command
cd workspace/
  • Make the script executable using the chmod command. This command changes the file permissions to allow execution (+x) of the script as a program
chmod +x 00-hello.sh
  • Run the script by typing ./00-hello.sh in the terminal:

3.5 Summary

Congratulations! You have just:

  • Created a Bash script that prints “Hello, World!” to the terminal