DEV Community

Andrea Esparza
Andrea Esparza

Posted on

Navigating the Terminal for the First Time (on a Mac)

Many years ago, I watched a friend of mine access a file in my computer using solely the terminal and it blew my mind. She moved so quickly and was unfazed by what seemed like gibberish to me. I remember thinking there was no way I could ever do that. And yet I am here now, by no means an expert, feeling confident that I can get from point A to point B using only terminal commands.

Opening the Terminal

Starting from the very beginning, it's important that you, the user, are feeling confident as soon as that terminal window pops up.
Image description

Print Working Directory

Now is the time to introduce our first command (don't type the "~"):
~ pwd

"pwd" stands for "print working directory," which is not very helpful if you've never done this before. What "pwd" does is it shows you a path from the very beginning to where you are now. It might not show much the first time you run it:
Image description
That just means I am at the beginning and there is no other folder (or directory) left.

List Directories

Let's take a look at our next command (again, don't type the "~"):
~ ls

That's a lowercase L as in Larry, by the way. "ls" means "list", as in list all the folders (directories) ahead of us. It's a list of ~possibilities~.
Image description

"pwd" and "ls" are both very helpful to see where we are, where we've been, and where we can go in the terminal.

Change Directory

Buuuuuut those two don't actually do anything or take us anywhere. That's where this next command comes in (don't type the "~" or the brackets):
~ cd [directory-name]

"cd" (to me) means "go to." It actually stands for "change directory" but you already know how I feel about that word by now. So if we look at the image above one more time, we can navigate to "Users" by typing the following command:
Image description
The change here is subtle, but you can see the "/Users" is now before the "%" meaning we are inside of the directory (ugh) called Users.

There are many other commands in the terminal, but these three are the ones I use the most and I think are the most essential.

Tl;dr
pwd to see where you are and where you've been
ls to see where you can go
cd to go!

Top comments (0)