Mac OSX

How to use terminal on macOS

Terminal on macOS allows you to use laptop in Unix style. You have the liberty to write commands to control and perform various tasks such as navigating folders, copying files and running applications. It’s important to remember that every space, character and line matters when it comes to terminal. You can end up having a different output if you are not conscious about space, characters and other intricacies.

Open terminal on Mac

MacOS has a built-in terminal program. You can open terminal using two methods:

  • First method is, press Command + Space, you’ll view spotlight. Type Terminal and hit Enter key.
  • Second method is, go to applications and search for Terminal, double-click and launch it.
Terminal macOS
Write relevant command in terminal window and hit enter

Opening terminal is such an easy job on macOS. You can also open it from applications drawer. Similarly, you can go to Applications in Finder and open it from the Utilities folder.

Otherwise, for an easy access you can pin terminal in the dock of macOS. Simply drag terminal application and place it in the dock for an easy access.

Basic commands for macOS terminal

You can do anything using a terminal which you do while using your laptop for example, compressing folders, navigating computer and copying files. Let’s share some basic things which you can do using terminal commands.

Open an application

Running an application using terminal is as simple as using this command format:

  • Open -a APPLICATION_NAME

If you want to run Google Chrome using terminal, then you’ve to use Open -a “Google Chrome” in the terminal window and hit enter. You’ll have to use inverted commas if application has space in its name.

Open a file

MacOS terminal allows you to open file, it can be of any type, media, document or database. However, before you open a file, you’ve to provide the accurate path. Follow this procedure:

  • Drag file into the terminal for providing its path. Otherwise, you’ll need to use CD command in terminal to navigate to that file’s folder. For example, if the file is at path /users/documents then write cd /users/documents inside terminal and hit enter.
  • Once you are in the directory of the concerned file, write open FILE_NAME and hit enter.

You can also open a file with a specific application by using the following command:

  • Open -a APPPLICATION_NAME FILE_NAME

Cancel an ongoing command

In case if you want to cancel an ongoing command, or quit a running terminal application, simply use the following key combination:

  • Press CTRL + C and this will end the terminal process/command.

Delete files in a folder

Rm command is used to delete any file present inside a folder. However, first you need to head to that directory in which you want to perform delete operation. Suppose, you want to delete some file in the Documents folder, the name of the file is delete_me.png, then use the following procedure:

  • Type cd ~Documents and hit Enter.
  • Type rm delete_me.png and hit Enter. (It’s important to add extension if you want to delete a file otherwise macOS will recognise it as a directory.)

Deleting files using a terminal is not a good idea, as the files are not recoverable. Under normal procedure the deleted files are transferred to Bin which isn’t the case with rm command.

Copy files from one folder to another

Ditto is the command to copy content of one folder into another one. It’s a simple command which can be used in the following format:

  • Make sure that the terminal is directed to the concerned directories using cd, or the path is mentioned accurately.
  • In the terminal window, use ditto FOLDER_A FOLDER B and hit enter. This will copy content of the FOLDER_A into FOLDER_B.

Conclusion:

Terminal is one of the important components of macOS using which you can perform various tasks like installing applications, deleting, opening and copying files. Furthermore, some applications are actually built only for the terminal, therefore, you need to use it. The earlier you get yourself accustomed to terminal, the better it is; this guide is first step towards opening a terminal and using it for basic operations.