Command Line

Navigate the command line using Terminal: Part 1


This quick & dirty tutorial will help newbies get the hang of the Command line in Mac’s Terminal. If you have never used Terminal before, that’s okay, this will guide you through some basics to get you started.

Before we start, let’s ask a question. What is the command line?

The command line interface (in our case Terminal) is a way for the user to control a computer by issuing it text commands. This was the primary way computers were run throughout the 60’s, 70’s & 80’s. Today however, computers have easy to use GUI’s (Graphical User Interfaces) and CLI’s are mainly used by advanced users.

Isn’t that great, after this tutorial you’re on you way to being an Advanced User!

Alright, let’s get started.

Opening Terminal

Open up the terminal app. You may do this by clicking on the icon in your dock or by going to finder and searching for Terminal. The icon looks like the image below.


The First Command you should learn: The List Command

I recommend the List command as the very first one you learn. This command shows you a list of all files (except hidden ones) in the current directory you are in. Right now, you should be in your home directory since you just opened Terminal. Type the following:


You should see something like this:

Last login: Fri Jan 22 20:25:16 on ttys000
Jessicas-MacBook-Pro:~ jessicasuderno$ ls
Creative Cloud Files Websites

note: The contents of your home folder will be slightly different than mine, so don’t worry if it’s not exact.

Congrats! You just ran your first command and now you can see all the files in your home directory. Lets take it a step further. To see a more detailed view of our files type the following command:

ls -l

Now you should see something more like this:

Jessicas-MacBook-Pro:~ jessicasuderno$ ls -l
total 1224
drwx------ 6 jessicasuderno staff 204 Jul 5 2015 Applications
drwxr-xr-x 8 jessicasuderno staff 272 Jan 16 15:17 Apps
drwx------@ 5 jessicasuderno staff 170 Dec 16 11:32 Creative Cloud Files
drwx------+ 73 jessicasuderno staff 2482 Jan 30 23:50 Desktop
drwx------+ 36 jessicasuderno staff 1224 Jan 30 19:59 Documents
drwx------+ 1689 jessicasuderno staff 57426 Jan 30 23:33 Downloads
drwx------@ 63 jessicasuderno staff 2142 Jan 6 12:00 Library
drwx------+ 4 jessicasuderno staff 136 Jul 20 2015 Movies
drwx------+ 4 jessicasuderno staff 136 Jun 4 2014 Music
drwx------+ 9 jessicasuderno staff 306 Jan 15 14:51 Pictures
drwxr-xr-x 4 jessicasuderno staff 136 Jan 19 17:11 Websites

We just used a special flag for the list command that shows all the details of the files and folders in our current directory. There is one more important flag I would like to cover. Type the following command:

ls -a

This command is very helpful because it shows you all the files that are hidden from normal view. You can see hidden files will all start with a period, like so:

Jessicas-MacBook-Pro:~ jessicasuderno$ ls -a
. .npm
.. .plugman

The Change Directory Command

The next command is the one I use most often. The change directory command allows you to get to any folder you want as long as you know it’s absolute path. (Ex of absolute path: Documents/Websites/MyFirstWebsite)

Let’s start by running the following command:

cd Documents

… now type:


You are now inside your documents directory and you have listed all the files & folders it contains.

But how the heck do I get back to where I came from? You may ask.

That’s actually very easy. Just type the following:

cd ..

This moves you into the parent folder of the directory you are currently in, right back to where you came from. If you happen to be deep into a folder structure and you would like to quickly go back to your home directory you can use the following command:

cd ~

And to get instantly into your machines root directory type:

cd /

If you get lost (which can easily happen, especially when learning) there is a magic command to show you exactly where you are in the folder structure. Type the print working directory command by typing:


And, you should see something like this:

Jessicas-MacBook-Pro:Documents jessicasuderno$ pwd

This is the absolute path to the directory you are currently in. It’s your own Terminal GPS! Too bad it doesn’t include Siri.

One last note about the CD command, If you need to change to a directory with white space in the name, wrap the directory name in single quotes like so:

cd Documents/'My First Website'

This concludes Part 1 of this series. Stay tuned for part 2 & more terminal goodness next week! (spoiler: There will be an awesome cheat sheet to download at the end)

Post A Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: