Beginner - 5 of the Most Common Shortcuts for Navigating Within the Mac Terminal

David Finkelstein
Sep 3, 2018 · 4 min read

As somebody with a recent interest in software development, I have been exposed to the importance of using the terminal to navigate through my computer.

The terminal is a Command Line Interface, (commonly referred to as a CLI) and comes with all Macintosh OS X computers through Lion.

The terminal is essentially the underlying operating system of the computer. It allows the user to modify many different aspects of the machine, including creating files, folders, altering fonts, accessing hidden programs, and even permanently deleting data (warning: DANGEROUS!). The terminal allows for complete customization and command of your computer, making it a primary source and a powerhouse for software developers.

The terminal is displayed with this icon and can be accessed through a user’s dock or by using the spotlight search (the magnifying glass icon at the top right of your screen, or press command + space bar at the same time to access it).

Upon entering the terminal, you will see a screen similar to the one below.

Ok! Enough with the small-talk! Let’s get to it, the 5 most common and useful commands that will help you navigate around your computer!

1. ls

The ls (list) command (that’s an ‘L’, not an ‘I’) is used to list the content of the current directory (folder) that you are in. You can type in ls and press enter immediately when you open the terminal. This will display the files and folders that are contained inside of your directory.

Quick tip - If you type in ls and enter the name of a directory within your current directory, it will list the content of that directory!

2. cd

Typing in cd (change directory) enables you to move within a folder to see and access what’s inside of it! Say you are in your home folder, and you press ls to view the folders inside of it, and you see your Desktop folder. To enter your desktop folder, you would simply type in cd Desktop and press enter (remember the space!). You will now be inside of your desktop folder and you can press ls again to see the directories your desktop folder contains!

Quick tips - Typing cd and pressing enter will take you back to your home folder, cd .. will take you one level above the directory you’re currently in, and cd ../.. will take you two levels above your current directory.

3. mkdir/touch

To create a file or directory inside of your current folder, simply type in mkdir dirname to make a folder (replace ‘dirname’ with whatever you’d like to call your directory) or touch filename to make a file (replace ‘filename’ with whatever you’d like to call your file).

Quick tip - To make a directory within a directory in one command, you can type in mkdir -p dirname1/dirname2/… etc. You can add as many folders within a folder as you’d like!

4. rm

Here is possibly the most risky command on the list. To PERMANENTLY remove a file from your computer you can simply type in rm filename. To delete a directory, type in rmdir dirname. Removing a directory may not initially work if the folder contains files or other folders within it. There is a little trick that will override this and delete the folder including all of its contents. If you type in rm -r dirname you will, I repeat, successfully and permanently delete the folder and all files/folders within it.

Quick tip - To delete pesky items that are refusing to be permanently removed from your trash, type in rm -r and space, go to your stubborn files in the trash and drag them to your terminal window. You may see a long list after doing so. If you wish to delete these items, press enter.

5. mv

mv (short for move) is a massively useful tool that can both rename a file or move the file to a specified folder. To rename a file, simply type mv originalfilename newfilename (the new file name must be original) and the new file will appear in the same directory. To move a file from one directory to another, you can simply type in mv filename directoryname. Your file will be gone from the original source when you do this.

Quick tip - If you move the file to a folder that contains a file with the same name, the file you move will OVERRIDE and delete that file.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade