Essential Command Line Basics for Python Setup

Learn to use the terminal by entering text-based commands and observing the command-response cycle.

Master the fundamentals of using the terminal as part of your local Python setup, whether you're on macOS or Windows. Understand the command-response cycle and how to interact with Terminal Emulators through simple commands like echo.

Key Insights

  • Users on macOS should launch the Terminal app, while Windows users should use the Anaconda Prompt, which is installed with Anaconda; if the Anaconda Prompt is missing, reinstalling Anaconda is recommended.
  • Terminal Emulators such as Terminal and Anaconda Prompt operate on a command-response cycle, where users input text-based commands and receive output before the prompt reappears for the next command.
  • Noble Desktop's course emphasizes getting comfortable with the terminal early, using basic commands like echo "hello there" as a starting point to understand how command-line interfaces function.

This lesson is a preview from our Data Analytics Certificate Online (includes software). Enroll in this course for detailed lessons, live instructor support, and project-based training.

The next part of setup is using, getting used to, the terminal. Now if you've used the terminal before, this should be maybe just a refresher, but using the terminal is central to having a local Python setup, and we'll be using it extensively here in this course. So the app to launch is on macOS the Terminal app, so you can see it says up here Terminal, and on Windows you're going to use the Anaconda Prompt app, which should have been installed if you installed Anaconda.

If you, on Windows, if you hit the Windows button, you should be able to start typing in Anaconda and see an app called Anaconda Prompt, and if you don't, reinstall Anaconda. It's possible something went wrong in that installation. For the Mac, you're going to go to the spotlight up here, there's a keyboard shortcut for that, and type in Terminal.

Now the Anaconda Prompt and the Terminal app on macOS are both what's called Terminal Emulators, and a Terminal Emulator is just a kind of app, but you'll hear it called a Terminal, a Command Line, a CLI for Command Line Interface, or a Command Prompt. If you've never used a Terminal, these apps work in a different way than most interfaces you've encountered. It's a purely text-based interface.

They work on what's called a command response cycle. The user types in a command and hits return or enter, and if there's a response, it'll appear underneath, and whether there's a response or not, the Command Prompt will appear again, so you can enter your next command, and that cycle continues. So if you look here, I have a Command Prompt.

We'll be diving more into what this text is, but this is a prompt that tells you you could start typing in your command now. We see this base and a bunch of text and a bunch of symbols, and again, we'll talk about what those are, but then we have a cursor to the right, and that means it's prompting us, it's waiting for us to type in our command. Let's try a simple one, which is echo space.

The spaces are important in a Terminal, any Terminal, and then in quotes, I'm going to type in hello there, and make sure to end your quote. Now, nothing's happening now. It doesn't know if we're done yet with our command.

If we hit return, it printed out hello there. That's output from the computer, from the Terminal, and then it gave us our prompt again, and that's the cycle. If I type in another one, echo hello right back, and hit return or enter, hello right back, but it's not really anybody saying hello to each other.

It's us telling the computer with the echo command to print out this string, and if you're used to Python, which you should be, this is the equivalent of, you know, print hello there, like so. One of the main things that I, as an instructor, have seen over the years is people getting confused about this prompt, about this cycle, about when they can type in a command and when they can't, and what this means. So, we're going to spend the next little bit understanding what's happening here, but if this is your first Terminal command you've typed in, congratulations.

It won't be your last. We'll dive more into that in a moment.

How to Learn Python

Build practical programming skills with hands-on Python training. Python is a widely used, versatile programming language applied across data analysis, automation, artificial intelligence, and software development.

Yelp Facebook LinkedIn YouTube Twitter Instagram