Intro to command line

Introduction to the Command Line

July 11, 2015|Terminal, IRB

I remember the first time I used terminal, which is Mac’s version of the command line. It was scary. In fact, I was scared or at least nervous for the first month or so as I got comfortable and familiar with it. It was so foreign and different that I was worried that I would do something and not be sure how to undo it. I’m here to help you feel comfortable and confident using terminal.

The best way to learn and feel comfortable is by using it. Trust me. The more you use it the more familiar and comfortable it will feel. So, let’s get started.

First, you need to open it up. Go to: Applications > Utilities > Terminal

Finding Terminal using Mac's Finder

Double click on Terminal and you will be brought to something like this:


Yours won’t look exactly like mine as I’ve customized the way mine looks. I’ll show you how to do that later. But, for now, let’s learn a few commands and do a few things.

The first and most important commands you’ll learn are related to your directories - how to view the contents and change your location. You’ll use at least one of these commands pretty much every single time you interact with the command line.

pwd - tells you where you are (you’re inside a folder and this is showing you which folder you’re in)

open . (start . on pc) - opens up whatever you tell it to.

ls - lists all folders and/or documents inside the folder you’re currently in

cd - change directory: type cd and then the name of the folder you want to move into.

cd .. - sends you back to the previous directory

You may be wondering why you should go through the process of learning to use the command line. If you plan to do rails development, or pretty much any development you’ll need to learn to use the command line. The other benefit of the command line is that you can run way more commands in the command line than you could visually. For example, ls -a will list all files (including hidden files).

Let’s walk through a typical use case.

  1. You open terminal.
  2. Where am I? You type pwd to see where you are. Now you know you’re at your root directory.
  3. What folders/files are available to me? You type ls to see all folders and/or documents are there. You see one of the folders is “code” and that’s where you want to go.
  4. Let’s move into the “code” file. You type cd code to move into the code folder.
  5. Am I in the code folder now? You type pwd to see where you are. Now you know you’re in the code directory.
  6. What folders and/or documents are in the code folder? You type ls to see what’s inside the “code” folder. You seem to remember you created a “ruby on rails” folder. You see a folder named “rails” and realize that’s the one you’re looking for. You want to move into that folder.

What do you think is the next thing you will do to move into the “rails” folder? You got it. You type cd rails.

The command line isn’t so hard after all. :)

If you want to learn more here is a free command line crash course.

Learn to Effortlessly Create Anything in CSS

Get access to my free courses, best articles, and tips once a week.

I won't send you spam, promise. If it ever feels that way you can unsubscribe at any time.

Sign Up For Free


Sign In