by

Terminal Commands For Mac

In this article, we explain what is Mac Terminal, how to use it and what it can do for you. In many macreports.com articles, we recommend our readers to use the Terminal app to troubleshoot various problems that our readers may be having with your Mac. Basically, Terminal is a command line interface (CLI – or the language you type to interact with your computer) for macOS. It is an app included in the Mac operating system.

  1. Terminal Commands For Macbook Pro
  2. Windows Terminal Commands List

Mac Terminal Cheat Sheet. GitHub Gist: instantly share code, notes, and snippets.

What is the Mac Terminal

How to Show Every Terminal Command Available in Mac OS. This trick will reveal every single possible terminal command available to Mac OS and Mac OS X. It works in all versions of Mac OS X system software as long as you are using the bash shell, which is the default in all modern releases. The following shows how to run a Terminal command with a keyboard shortcut using this app. Launch the TextEdit app on your Mac. Click on the Format menu and select Make Plain Text to remove formatting. Enter all the Terminal commands you wish to execute in the file.

Terminal is a utility app. The Terminal app provides a command line interface to let you to control and customize your Mac. The command line interface (CLI) is called bash (Bourne again shell).

See also: macOS Won’t Go To Sleep? Fix

How to open Terminal

There are a number of different ways to launch Terminal. So you may do one of the following:

As I stated above Terminal an app that can be found in /Applications/Utilities. To open it:

  1. Open Finder
  2. Click Applications
  3. Click Utilities
  4. And Click Terminal

Another way to open the Terminal app is to use Spotlight (Spotlight not working?). Here is how:

  1. Open the Spotlight window (you may press the Command and Space keys together or you may use the search icon in the menu bar)
  2. Type Terminal
  3. When it is highlighted, click to open it.

And a different way to open is to use Launchpad. Here is how:

  1. Click Launchpad in the Dock
  2. In the search field, type Terminal
  3. And the click Terminal

Now, you’ll see a small window open on your desktop, as you can see below. The window will say your username and the word bash in the title. The window will include your last login info. Now you can run commands. Simply type it and hit enter to execute. Let’s try.

To quit Terminal, you may go to Terminal > Quit Terminal.

See also: How Do I Password Protect My Files & Folders In macOS?

Basic Terminal Commands

If you look at the Terminal window above, it says:

Serhats-MacBook-Pro:~ fskurt$

This means that the user (fskurt – this is me) is logged in to a Mac named Serthats-MacBook-Pro. The ~ sing indicates that my current folder is my home folder.

If you want to use Terminal, you need to know the most important commands. In this article, we will not give a lot of details but we will give you a few examples to give you ideas:

Please note that be extra careful when executing the sudo command. This command requires you to be logged in with an administrator account. Red alert for mac.

Example 1:

Terminal Commands For Macbook Pro

Let’s use Terminal to lists files and directories within a directory. Enter the following code in Terminal and hit enter:

ls -l ~


In this command, ls is short for list. -l is an option, short for long. This means that with this option ls command will list out files and directories in long list format. And ~ is object. ~ means home folder. So this command will list list all of our files in our home folder in long list format.

Example 2

Let’s ping a website. Please note that we can also do this using Network Utility.

Enter the following command in Terminal:

ping macreports.com

Please note that completing this command may take a little longer.

Similarly, you can also run a traceroute command:

traceroute macreports.com

Example 3

Do you want your Mac talking? Here is how you can do this. Enter the following command:

say hello macreports.com

and hit enter.

Now you computer will say hello macreports.com

How to change the look of the Terminal window

Windows Terminal Commands List

You can customize your Terminal window. You can customize many elements such as colors, fonts, background styles etc. Here is how:

  1. Open the Terminal app
  2. Click Terminal and Preferences (from the Terminal’s menu bar).
  3. Click the Profiles tab.

On the left pane, there are a number of pre-existing profiles. You can select one. And then customize it. The one you are using will say “Default” under it.

If you want to change it, select one then click the Default icon.

You can also further customize this profile, if you want to do so. You can also create your own custom profiles by clicking the (+) plus sign. You can also remove any of the pre-set profiles by clicking the (-) minus sign. You can also rename a profile by double-clicking the name of the profile and entering a new name.

With the built-in Terminal app on your Mac, you can run a number of commands to execute various actions on your machine. From taking screenshots of your screens to renaming a whole bunch of files at once, Terminal commands cover a lot of things that you usually do on your machines.

The only thing that you may not find to be inconvenient is having to launch the Terminal app each time you want to run a command. What if there was a better and quicker way to run Terminal commands on a Mac?

Well, there is actually. In fact, there are multiple ways to run a Terminal command using a keyboard shortcut on Mac. You can assign your favorite key combination to your specific command, and pressing the combination will execute that command on your machine.

Use An App To Run Commands Using a Shortcut On Mac

The most easiest way to assign keyboard shortcuts to your commands is to use a third-party app called iCanHazShortcut. This app makes it a whole lot easier to assign any keyboard shortcut to literally any command on your Mac.

To configure the app, all you need to know is the keyboard shortcut you want to assign and the command that is to be executed.

Download the free and open-source app on your Mac and move it to the Applications folder. Launch the app once it’s installed.

When the app interface loads-up, you’ll be in the Shortcuts tab by default. On this screen, find the button with a + (plus) sign in it at the bottom and click on it to add a new shortcut.

The following screen lets you configure the shortcut as well as the command it needs to execute. Here’s what you need to enter in each of the fields on the screen.
Shortcut – put your cursor in this field and type in the shortcut you want to assign to the command.
Action – it’s an optional name you can assign to later find the shortcut in the list.
Command – enter the exact command you want to be executed here.
Workdir – if your command requires a specific directory as the work directory, select it here.
You can do a test run by clicking on the play icon at the bottom. Once you’re satisfied, click on the icon next to it and it’ll save the shortcut.

The Preferences tab in the app also has a few options you can customize. This should give you more control as to how the app works on your Mac.

From now on, whenever you press the specified keyboard shortcut, it’ll run your Terminal command.

If there are more than one commands to be executed, you can add those to the app as well. Shortcuts can be modified and even deleted as well if you’d like to do it.

Execute Commands With a Shortcut Using Automator

Automator also allows you to run your commands using a keyboard shortcut. First you need to create a service containing your command and then assign the service a keyboard shortcut.

Launch the Automator app on your Mac. When the new document screen appears, click on Service and select Choose.

On the following screen, search for the action named Run Shell Script in the actions list. When you find it, drag it over to the main pane on the right-hand side.

You’ll see a large white box beneath the newly added action. Enter in all the commands you want to execute in this box. Think of this box as a Terminal window where you type your commands.

When you’ve entered your commands, click on the File menu at the top and select Save to save your service. Enter a meaningful name for the service and hit Save.

Now that the service is created, it’s time to assign it a keyboard shortcut. To do so, click on the Apple logo at the top-left corner and select System Preferences. Choose Keyboard on the following screen.

Head to the Shortcuts tab and then select Services from the list on the left. Then find your service in the right-hand side list, click on it, and press the desired keyboard shortcut.

Your service will be assigned your chosen keyboard shortcut.

When you press this shortcut, it’ll run the service which in turn will execute your Terminal command on your Mac.

Use ActionShortcuts To Run Commands Using a Shortcut

ActionShortcuts lets you run more things than just traditional Terminal commands. It lets you run Apple scripts, workflows, services, and of course, the Terminal commands.

Unlike other methods, this app isn’t free and costs $2.99. You can use the 7 day trial period though if you want to try it out first.

The following shows how to run a Terminal command with a keyboard shortcut using this app.

Launch the TextEdit app on your Mac. Click on the Format menu and select Make Plain Text to remove formatting.

Enter all the Terminal commands you wish to execute in the file. Then save the file by clicking on the File menu and selecting Save.

In the Save As dialog box, enter any name for the file but make sure the extension is command. Hit Save to save the file.

Download, install, and open the ActionShortcuts app on your Mac. Click on the Open Scripts Folder button on the main interface.

When the folder opens, drag and drop your command file onto it. Get back to the app and you’ll see your file in the list. Click on the Record Shortcut button next to your file to assign a keyboard shortcut.

Once a shortcut is assigned, pressing the shortcut will launch the .command file containing your commands on your Mac.

If you’d like to add additional files for execution, you can do so by clicking on the app icon in your menu bar and selecting Open Scripts Folder. All the commands that are to be executed must be placed in this folder and the app will recognize them.