1. Home
  2. Training Library
  3. Cloud Computing Fundamentals
  4. Courses
  5. Creating a Local Linux Shell Scripting Environment

Vagrant and VirtualBox Troubleshooting Tips

Start course
Overview
Difficulty
Beginner
Duration
53m
Students
167
Ratings
5/5
starstarstarstarstar
Description

In this course, you're going to learn how to set up a local Linux shell scripting environment, whether you're using Windows, MacOS, or Red Hat Enterprise Linux. You'll be guided through the installation processes of Vagrant and VirtualBox—two tools that we will make your life easier as we work our way through the Linux Shell Scripting learning path. We'll also carry out some troubleshooting of the most common issues, should you face them.

This course is part of the Linux Shell Scripting learning path. To follow along with this course, you can download all the necessary resources here.

Learning Objectives

  • Set up a local Linux environment using Vagrant and VirtualBox
  • Troubleshoot any issues/errors

Intended Audience

  • Anyone who wants to learn Linux shell scripting 
  • Linux system administrators, developers, or programmers

Prerequisites

To get the most out of this course, you should have a basic understanding of the Linux command line.

Transcript

Someone sent me their script to check today, and I thought it might be interesting to some of you to see the process I use when you do this, and maybe it will help with your own troubleshooting. So someone sent me this script, so the first thing I do actually is I make a backup of it, name it something else like .jason, and then I just start executing it and see what happens. Okay, so that looks good. Here it says there's an error on line 13. So let me just edit that script, I'm going to go to line 13. I can see right here that there's no space between echo and this string, so I'm gonna put one there. I'm gonna do it again. Okay, no error this time, but it's telling me I need to add a user. So let me do this, I'll add user Fred. And here we see an error on line 22, it has this big long string command not found. So what's going on in line 22? Well, let's find out. Line 22 password equals and there's a space here. So when you're doing variable assignment, you do not use spaces around the equal sign, it has to be exactly like this, no spaces whatsoever. Okay, so I fix that one, let's try it again. Okay, good it knows Fred exists. So let's try another user. Okay, now we have an error on line 36, conditional binary operator expected. Okay, I have no idea what's going on, but let me go to line 36. And I don't see anything wrong with line 36. So what I'm gonna do is start looking above. And so if I get up here, I can quickly see the missing pair of this double quotation mark there. So I'm gonna add that and then I'm gonna do it again. So now we get an error on line 50, unexpected end of file while looking for matching double quotation mark. Okay, so if I look nothing's wrong on line 50, but again I'm gonna look above it and I can see here we have a double quote, starting the string and a single quote ending the string. So either I need to change this to a single quote, or this to a double quote. and I'm just gonna change it to a single quote. Okay, so now let's see what happens. Ah ha, okay, so it looks like this is getting better, but now I see we have an error on line 40. Let me get back on my script, go to line 40. Password -E username. Oh, okay, I think the command is actually PASSWD, so let me PASSWD, very easy mistake to make. So let's do it again, let's add another user. Okay, so it looks like this part is looking good except for this, it's displaying host name instead of the value of this variable. And let me go back to the bottom here, and I can just see that there system missing dollar sign in front of this variable. So now let's add it again. Great, so now we have no errors and it looks like everything is good. So let me switch to Fred5 here, use this password. Not sure if it works and I can change the password and so on from there I'm just gonna hit control C to quit. So there is one other thing I do after I get it to work. So I don't know if you remember earlier I made the copy here. And so what I'm going to do is actually do a diff on this, to show the differences between those files and let me actually pipe that to less. And then, so you can see the original was this, the new one is this with a space, original was password with this additional space, and the new one here is without the space. So this arrow means it comes from the first file specified, and this one means it comes from the second file specified. And here, 13 represents the line number of the first file, C represents change, 13 represents the line number in the second file. So this can be a change or a deletion or something like that. So these are gonna match because all of our little errors here were all on the exact same line in this new file. So hopefully that gives you an idea of what I do when you send me your script, and maybe what you can do on your own as some troubleshooting steps. Just read the error messages, go to the line, start looking for syntax errors, spelling mistakes, unmatched quotation marks, unmatched brackets, there's nothing on that line. It means typically that the error is above that line somewhere in the script. All right, hopefully that helps.

About the Author
Avatar
Jason Cannon
Founder, Linux Training Academy
Students
3386
Courses
60
Learning Paths
8

Jason is the founder of the Linux Training Academy as well as the author of "Linux for Beginners" and "Command Line Kung Fu." He has over 20 years of professional Linux experience, having worked for industry leaders such as Hewlett-Packard, Xerox, UPS, FireEye, and Amazon.com. Nothing gives him more satisfaction than knowing he has helped thousands of IT professionals level up their careers through his many books and courses.

Covered Topics