Mac OS: Command basics – “cd” and “ls”

Termianl-IconFor those out there that are new to using Terminal, or need a quick review, this is a quick overview of the “cd” and “ls” commands. These two commands are the basic tools for navigating the file structure “inside” of your Mac. Once these two are mastered, you will be able to comfortably move onto doing cooler, more complicated commands that can be run in Terminal.

Where’s My Terminal?

Ok, to start let’s open the Terminal application. Press Cmd + N to open a new window. It starts at your home folder, so to start the Terminal program you fill first need to go to  the Applications folder, then the Utilities folder. If you don’t know where your Applications folder is, you can press Cmd + Shift + A to bring it up.

Ok, what you just did is exactly how the “cd” command works! First you looked at your home folder, then looked into the folder called “Applications”, then you looked for a folder called “Utilities” in the “Applications” folder. As a computer address it look like:

/Applications/Utilities

Inside the folder “Applications” is the folder “Utilities”.

Using ls

In Terminal (you should have it open), type “ls”, the list command, and press the return keyYou should see something similar to this:

Desktop Downloads Movies Pictures Sites
Documents Library Music Public

Do those names look familiar? Your terminal opens to your home folder, just like a new window.

Using cd

Next, type the following in terminal:

cd /Applications/Utilities

Press the return key and see what happens. Doesn’t look like anything happened, right? Type the list command again, “ls”, to see where we are looking at. We should be looking at your Utilities folder.

Let’s look at the Applications folder:

cd ..

Once again type the list command again, “ls”, to see the contents of your folder. The “cd ..” command takes us down one level of folder.

Ok, Let’s go back to our home folder. We can always go back to our home folder by typing the following:

cd ~/

From there we can go to our Documents folder:

cd Documents

And from there we can go back to our home folder by using either method, “cd ..” or “cd ~/”.

Play around with these two commands to explore your computer the way many programs do. Once you feel comfortable using these, you are ready to start trying other commands that can be run in Terminal.

One thought on “Mac OS: Command basics – “cd” and “ls”

  1. Pingback: Mac OS: Zipping with your terminal | Information To Share

Leave a comment