The Terminal, (AKA CLI, or “Command-Line Interface”) is super-powerful and allows you to interface directly with the underlying workings of your operating system. It’s pretty essential you learn how to use the Terminal if you’re going to be developing software or doing any more advanced operations within your operating system as many operations are done exclusively through the Terminal.

In this post, I’ll give you a quick run-down on how to navigate your file system in Terminal. At the end, there is a bonus tip for altering the appearance of your Terminal to make things more efficient for you.

Opening Terminal

You can find Terminal by going to your /Applications/Utilities/ directory in Finder.

Terminal App Icon
Terminal App Icon
Alternatively, you can open it by pressing cmd + space on your keyboard to bring up Spotlight Search, and begin typing terminal. When the application shows, just press enter and up pops the Terminal.

When you open your Terminal, you’ll be greeting with a screen similar to this one:

Terminal Window
Terminal Window

Starting Components Explained

The first part of input prompt, before the colon, is your computer’s name. This can be changed to whatever you want in System Preferences > Sharing.

Computer Name
Computer Name

The tilde (~) represents your home directory.

Home Directory
Home Directory

And finally, the part before the dollar sign ($) is the name of the user account you’re logged in as.

User Name
User Name

You perform actions in Terminal by inputting a command and pressing enter. Here, I will go through the basics of navigating Terminal with some of the most common commands.

Start by typing ls into Terminal and pressing enter.

ls command
ls command
ls is the command for “listing directory contents”. As you are in your home directory, the ls command will show you all the directories inside of your Home directory.

Let’s move into one of the folders. You do this with the cd command. Simple type cd and the folders name, like so:

cd command
cd command

While a “folder” and “directory” are not exactly the same thing, please note that in this tutorial, the terms may be used interchangably, and in general, they refer to practically the same thing.

As you can see now, instead of being in your Home (~) directory, you’re now in your Documents directory.

Documents Directory
Documents Directory

If you want to make a new directory inside Documents, you use the mkdir, followed by a space, followed by the name of the new directory you want to create. In this example, we type mkdir blog.

mkdir command
mkdir command

If you ls now, you see there is a new directory inside of Documents

ls command
ls command again

If you type pwd now and press enter, you can confirm the full path of where you are inside Terminal. pwd stands for “Print Working Directory”.

pwd command
pwd command

To delete the blog directory you just created, you type rm -R followed by the name of the directory. Confirm the directory is gone by using the ls command once again.

Empty Directory
Empty Directory

Be careful when using the rm -R command, as this will delete your directory, plus all of its contents… for good, without confirmation. There is no “Trash Can” in Terminal.

The -R is what is called an “Option”, “Switch” or “Argument”. Commands usually have many Options avialable. To find out more about any command in Terminal, you can do so by typing man (for Manual), followed by the command. This opens up the manual page for the command, where you can read about all the options.

man command
man command

Exit the manual by pressing q.

Finally, to move up one directory, just type cd .. and you’ll move up a directory. Alternatively, if you want to go back to your Home directory from anywhere, just type cd ~.

cd .. command
cd .. command

This concludes the basic Terminal Navigation tutorial. Following is a bonus tip I promised you…

Bonus Terminal Tip

Normally when you use Terminal, you’re presented with this screen, as you saw from the beginning of this tutorial.

Terminal Window
Terminal Window

This contains unnecessary information when using Terminal on a daily basis, so with a very simple command, you can hide the computer name and username in your Terminal. Producing this instead:

Minimal Terminal
Minimal Terminal

I think you’d agree, this makes things a lot more tidy for you and removes additional clutter and distraction – Minimalist.

To accomplish this, simply type (or copy & paste) this command into Terminal and press enter. After this, open a new Terminal window by pressing cmd + n to see your new Terminal prompt.

echo "export PS1='\W \$ '" >> ~/.bash_profile

What this commands does is it appends the line export PS1'\W \$' into a hidden system file in your Home directory called .bash_profile. This file controls what is presented to you when you open a new Terminal window.

Conclusion

This is only barely touching the surface of what can be accomplished in Terminal. As I said before, getting familiar with the Terminal is essential if you’re interesting in going deeper into what is possible with your computer. In other words… becoming a Power User. I hope this tutorial can help you in making those first steps.