10 Need to Know Mac Terminal Commands

10 Need to Know Mac Terminal Commands

If you want to get into web development, knowing what the Terminal is and how to use it is very beneficial. But there are some essential commands that we'll go over, so we feel comfortable using it.

In today's article, we will be going over the 10 need to know Mac Terminal commands - #10 is a fun one! 🙂

The Terminal. So what is it?

The most basic use of the Terminal is being able to navigate throughout your computer's folders and files.

There are commands that you can run inside the Terminal that can create a new ReactJS application, install a new npm package, and so on, but we are not going to discuss those in this article.

Let's focus on the basic commands when navigating your computer using the Terminal.

Want to follow allow? Go ahead and open up the Terminal. The quickest way on a Mac is to hit "command + space bar" and you'll get the computer's "Search" bar. Once that pops up, type in "Terminal" and hit "Enter". A little white box will pop up, and we will see the name of the computer.

The command, pwd, stands for "Print Working Directory." Essentially, you type in that command, and it will spit out the exact file path for the file or folder you are in.

This stands for "change directory" or, in simpler terms, change which folder we are in.

When using the command, cd, we can tell it which way to move by adding more to the command.

  • cd or cd ~ - Takes us to the home directory.
  • cd <folder name> - Takes us forward one step to the folder that is typed in.
  • cd .. - Moves us back one level to the parent folder.
  • cd ../.. - Moves us back two levels. Add more /.. for each level we want to navigate up.

When typing in a folder or file name and it's only one step ahead, you can hit "Tab" and it will autofill in the folder/filename.

Now that we are in a folder, we might want to see what is in that folder. When running the command, ls, it will show us everything in that folder.

If we wanted to see all files, even the hidden ones, we could run ls -a.

This command does exactly what it sounds like; it "clears" your terminal out. Sometimes a clean slate is easier when trying to focus.

If we were to right-click directly onto our Desktop view, that little menu would pop up, we could click on "New Folder", and then a brand new folder would pop up for us to name. This command does that same functionality.

mkdir stands for "Make Directory" or simply, make a new folder.

Wherever this command is ran from, it will create the new folder in that spot. So navigate to the desired location using cd commands, and then type in mkdir <folder name>.

To get into that new folder, we would run the command: cd <folder name>.

Opposite of mkdir? If we want to remove a directory, simply run rmdir <folder name>. The folder must be empty for this to work.

Now that we know how to create a folder let's create some files within that folder. If we followed the commands above:

  1. mkdir new-folder
  2. cd new-folder

We should now be in the "new-folder" directory/folder. Let's create a file within that folder. By running the following command, that would create a file:

touch new-file - this has no extension, so we would want to add .html, .txt, or whichever extension needed.

Opposite of touch? The command to remove a file is rm <file name>.

Open a file or folder by typing in the command:

open <folder/file name>

Want to know all the commands that have been ran in the current terminal session? Run the command, history to see them.

Another trick! Use the "up" and "down" arrows to navigate through previous commands.

Want to limit the number of commands it shows? Add a number to the command: history 10 would show the last 10 commands typed.

This command allows us to see the contents of a particular file. We would need to declare the particular file for this command to work.

If we know the path of to the file, we could run:

cat /Desktop/new-folder/new-file

Or we could navigate from our home folder to new-folder and then run the command.

  1. cd Desktop
  2. cd new-folder
  3. cat new-file

This command is different from open because it shows the contents of the file inside of the Terminal rather than opening it up externally outside of the Terminal.

This one is a fun one. Not necessary for navigation, but it makes your computer SPEAK to you!

Type in: say "anything here" and your computer will say that. Don't forget the quotes in this command!

Want to change the Terminal to look like the Matrix? Black background, green letters?

  1. In the upper left-hand corner of the screen, click where it says, "Terminal".
  2. Click "Preferences…"
  3. Click "Profiles"
  4. In that list on the left-hand side, click on "Homebrew Default"
  5. Click on "Default" at the bottom.

Exit the Terminal and reopen it to see those changes. Now we can code and look cool when our friends look over our shoulder to see what in the world we're doing. Uh, we're just making folders and deleting them, but they don't know that! 🙂

The Terminal is something that takes time and practice.

Definitely go play around with it, navigate through folders, create new ones, and open newly created files up. Or just make your computer say funny things! 👍



As a former flight attendant, Kapehe dove into the world of code at lightning speed. She attended a coding bootcamp and learned full-stack web development in a short 12 weeks.

In this article...


What did you think of the article? Let us know!
(these comments are powered by GitHub issues and use 0 trackers)