Mac Terminal Commands You Need to Know to Master the Useful Tool

mac terminal commands

In a previous article, we gave you a primer on Terminal on macOS including how to access the command line. If that primer got you excited and wanting to learn more about the powerful tool, you should begin by knowing the most common Terminal Commands. Learning the basics will expand your perspective on the macOS environment. Read along to find out what these commonly used Mac Terminal Commands are, their uses, and how to execute them.

Launching the Terminal App and How to Change Its Appearance

As a review, you can launch the Terminal app on your Mac in two ways. You can open the Finder app and launch the app by navigating to Applications > Utilities > Terminal. Alternatively, you can use the Spotlight Search. To bring it out press Command + Spacebar and type Terminal.

If you have used it before, you should know that upon launching the Terminal app, a boring and intimidating black box greets you. However, you can change this appearance to suit your preferences, and yes to make the app more vibrant. To do this, simply click Terminal on the menu bar while the Terminal app is open, then select Preferences. Navigate to the Profiles tab and from there you can customize the appearance of the Terminal app.

Once you’re settled with the appearance, you can start running a command. To do that simply type the command, and press Return. The general syntax for every command comprises three elements. These are the command itself, the argument that tells the command what or where it should operate, and a modifier option that affects the command’s output.

Commonly Used Mac Terminal Commands

With tons of Mac Terminal Commands that you can use, it would take a long time for you to master them all. You might not use all of them at all. But if your goal is to maximize these Mac Terminal Commands to expand your horizon when it comes to using your Mac, you should start by learning the Mac Terminal Commands listed below.

Basic Mac Terminal Commands

To help you understand what a particular Terminal command does before executing it, it would be best to bring up its manual. You can do so by simply typing man. This will bring up everything you need to know about a particular command. Other basic Mac Terminal Commands are listed below.

  • sudo: the so-called “god” command, used to give the following command administrator rights. you will be required to enter your administrator password before executing the command.
  • history: Displays all the commands you have executed.
  • history c: deletes the command history of the Terminal.
  • .: denotes the directory you are currently in.
  • .. : refers to the Parent Directory of the directory you are currently in.
  • clear: clears the space of your Terminal.
  • * : wildcard. usually used to search for files with the same extension name. e.g. *.png denotes all PNG files.

Change and List Directory Commands

When it comes to working with your Mac’s directory structure, you can either execute a command to list the contents of a folder or change the directory you are currently in. Below are the commonly used Directory Commands.

  • ls: shows the names of files and subdirectories contained in a folder.
  • ls -l: displays more information about files including file mode, owner, group name, and more.
  • ls -al: includes hidden files when displaying detailed contents of a directory.
  • pwd: print working directory.
  • cd: go to the home directory.
  • cd ..: move up to the Parent Directory.
  • cd [folder name]: Change directory.
  • cd ../..: move up two levels.
  • cd ~: go to Home Directory.

File and Directory Management Commands

You can also create, edit, and delete directories and folders using various Mac Terminal Commands.

  • mkdir : create a new subdirectory in the current directory you’re in.
  • mkdir "": create a folder with a space in its name.
  • rm -R : remove a directory including its contents.
  • mkdir <dir1> <dir2> <dir3>: Create multiple directories at once .
  • cp -R <"newdir">: copy a folder to another folder with spaces in its name.
  • mv *.txt : move all text files of the current folder to a different folder.
  • mv : move a file to another file/ Rename a file.
  • rm : Remove a file completely.
  • rm -i : delete a file after providing confirmation.
  • cp :copy a file to a directory.
  • nano : opens a Terminal file editor to make changes to files right in the Terminal.

Search Commands

When searching through your Mac using Terminal commands, you can do so in two ways using the command line.

  • find . -name “*.doc”: Find all files with the doc extension in the current directory.
  • find -name : find the file in the specified directory.

Final Words: There’s More to Learn About Mac Terminal Commands

As mentioned, the Mac’s Terminal commands listed above are just some of the basic and most commonly used. Mastering those commands will get you started with your journey into the unknown environment of macOS that you can’t access through the traditional GUI (graphical user interface). Meanwhile, you can use keyboard shortcuts to copy and paste on Mac.

To learn more about this powerful tool, you should also check out Apple’s Terminal User Guide support document to learn more about Mac Terminal Commands. Remember, if you are not sure what a particular does, check out its manual.

Leave a Reply

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