Learn the Command Line: Confusing instructions, bad explainations

https://www.codecademy.com/learn/learn-the-command-line
While I’ve been taking the Learn the Command Line course, there have been some bugs.
For example in some of the interactive lessons, telling me to write cd …/…/comedy for example, which throws an error but passes the step, but when I write cd comedy which takes me to the right place, but doesn’t pass the step??
This was the one I was talking about: https://www.codecademy.com/courses/learn-the-command-line/lessons/command-line-manipulation/exercises/cp-ii

I got to Learn Bash Scripting and just got lost on some of the instructions, even needing to go to the solution because of poorly worded instructions? Like on this exercise:
https://www.codecademy.com/courses/learn-the-command-line/lessons/learn-bash-scripting/exercises/inputs
They expect you to nest an if statement inside a while loop without even explaining how??

They say you need to run chmod +x script.sh so the script could execute, but don’t expand into it and then you go into the next few modules and don’t even need it?

It’s not like you can’t learn it from this, but this entire thing has been so confusing and frustrating.

Hello! I recently finished this course so I might be able to help out with some of your questions.

Throughout the course, I too noticed that there were a few bugs. In order to get past the steps where you’re supposed to navigate to a certain directory, you have to use the exact code provided in the instructions to access those directories. This is because the lesson assumes that you are still in the same directory as where you finished the last lesson. For the first exercise you mentioned, you have to enter cd …/…/comedy to get to the comedy directory in order to pass. This means that you have to navigate to /home/ccuser/workspace/movies/drama/historical (or any other directory two levels below the movies directory) and then use cd …/…/comedy.

As for nesting an if statement inside a while loop, take a look at some of the previous lessons and the examples provided in previous lessons. The information in the Conditionals and Loops lessons in the same unit should provide enough information to accomplish what you are trying to do.

In the case of chmod +x script.sh, I’m a bit baffled by that too. It wasn’t very well explained and it wasn’t necessary for the solutions to the lessons. Maybe someone else can comment on that?

3 Likes

What previous lessons? I’ve seen loops for the first time in this course.

They should be the two lessons directly before the one you’re working one. Here’s Conditionals and here’s Loops.

1 Like

I see the lessons, but still, nowhere do they explain to nest an if statement. In my opinion there isn’t enough information to figure that out. Oh, and I forgot to mention that countless times, I have typed correct solutions, but the step says its wrong.

chmod +x script.sh simply makes the script executable.

Meaning that once you run the file the script inside will execute.

In any programming language, how would you nest an if statement in a while loop? The same logic can be applied in this case.

1 Like

Oh, so instead of having to run the script, then typing the script name in bash and running that, you can just type chmod +x script.sh in bash and now when you run the script it outputs whatever you wrote.

What do you mean in any programming language? This is the solution.

while [ $greeting_occasion -lt 3 ]
do
  if [ $greeting_occasion -lt 1 ]
  then
    echo $first_greeting
  else
    echo $later_greeting
  fi
  greeting_occasion=$((greeting_occasion + 1))
done
 

But I would expect it to look something like this (based on my current knowledge of Python and JavaScript):

while [ $greeting_occasion -lt 3 ]
do
  if [ $greeting_occasion -lt 1 ]
  then
    echo $first_greeting
    greeting_occasion=$((greeting_occasion + 1))
  else
    echo $later_greeting
  fi
done
 

Codecademy’s solution is correct. When you execute the first code, would greeting_occasion increase by 1 every time the loop is run and a greeting is printed? What about in the second example?

In the second example, greeting_occasion is only increased by 1 every time the first greeting is printed. It does not increase when the later greeting is printed. This means that greeting_occasion will never be less than the greeting limit and that you have an infinite loop.

1 Like

So is chmod +x only necessary when you’re running the script on your computer? Because script.sh runs fine in the Codecademy lessons without this code.

Well chmod has to do with user permissions etc. The chmod +x line is a pretty standard technique. I guess that means CC is giving some sort of pseudo-root access within the framework of their terminals? I honestly don’t know :sweat_smile:

1 Like

I see my mistake, however what if you have no prior programming experience? You can’t put something like that in a course that stands alone by itself and expect people to get it because it’s similar syntax to other programming languages. I stand by what I originally said, I don’t think this course is explaining things well enough.
I was a beginner, never TOUCHED Python or JavaScript before, but got the hang of it quickly because the explanations made sense.

Tbf I think this course is embedded in one of the career paths.

I don’t think it was expected to be a standalone course. It is an oversight that they don’t link though to review concepts knowing this.

1 Like

Seems that whilst permission editing is touched upon briefly in the instructions it isn’t actually necessary for the lessons. You have full permissions set automatically for the file you have to edit so it’s a little redundant (for those lessons at least).

1 Like

It’s interesting they bring it up if it’s not necessary for their exercises (hmm). They should clarify in normal scripting it is quite necessary and they are just letting the “leash off” so to speak in this sandbox.

Even if it’s not a standalone course, I still think that the explanations could use some work, and maybe some more review material is needed. And of course, the bugs need to be fixed.