Cookie
Electronic Team uses cookies to personalize your experience on our website. By continuing to use this site, you agree to our cookie policy. Click here to learn more.

Mac command line tutorial for macOS Monterey

One of the features of the Unix-based operating systems is the command line. Mac сommand line is called Terminal and in this article, we will consider the main aspects of its work and highlight useful tips and tricks to facilitate your workflow.

Top choice
Commander One
4.7 Rank based on 889+ users, Reviews(524)
Commander One is a versatile file manager for Mac
f

Easily use macOS command line with Commander One

If you have ever wondered what the command line on Mac is and what’s the reason to use it, well you have come to the right place. It is a known fact that command-line is a distinctive feature for Unix-like OSes. However, in macOS command line has the name Mac Terminal. It doesn’t have a beautiful GUI, nevertheless, helps perform various actions to configure and debug the operating system. In other words, it is a special window into which you enter commands and can communicate with your computer’s OS without using a mouse.

How to open and use Command Line on Mac

In macOS, the Mac command line interface is available through the Terminal app, which comes with each version of the Apple operating system, as well as through the Terminal emulator apps. Opening a default Terminal on Macs doesn’t differ from opening any other program. Here you can find several ways to open a command line on Mac.

How to Open Terminal via Finder

1

Open Finder and find your Applications folder.

 Applications folder
2

Search for Utilities and click it.

3

Next, find Terminal among the available programs and double click it.

 Find and open Terminal in your Mac

After that, a Terminal window will immediately open, and you can start working with it.

Open Terminal via Spotlight

Mac owners probably know that one can open any application through Spotlight search.

1

Press command+ Space on the keyboard.

 Press command+ Space
2

Start typing Terminal into the search bar.

 Find Terminal in the search bar
3

The operating system will show the found options, among which the Terminal program will be one of the first.

4

Click it to run macOS command line.

Open Terminal via Launchpad

You can also quickly open Terminal from Launchpad. Just follow this simple guide:

1

Click the rocket ship icon in Dock or press F4 on your keyboard to launch it.

 Click the rocket icon
2

When Launchpad opens, type Terminal and press Enter.

 Type Terminal and press Enter
3

Terminal is open and ready for further work.

Open Terminal via Shortcut

The easiest way to open command line in Mac operating system is by using a shortcut to invoke its window, namely command(⌘) + T.

Open Terminal via Shortcut

Using Commander One

Mac task manager | Commander One
Requirements: MacOS 10.12+. 61.07MB of free space. Version 3.4.1(3580). (17 Jun, 2022). 4.7 Reviews(524)
Category: System Utilities

For most users, the built-in Mac Terminal is enough to fulfill their needs. However, there are those users who want to obtain as much as possible from any app. We bring Commander One for your consideration, a versatile file manager for Mac tailored at facilitating your workflow.

open command line on Mac computer via Commander One

The app has gathered everything you need for advanced work: here you will find work with remote servers and cloud storages, work with MTP, Android, and iOS devices, work with archives of different formats, Process viewer, advanced search, built-in Terminal, and much more.

So let’s figure out how to open command line on Mac computer via Commander One:

1

Download and install the app on your Computer.

2

Launch Commander One.

3

To run any command, just type it in the command line in the lower pane of Commander One.

4

To invoke the Terminal use the shortcut Ctrl+O.

  use the shortcut  to invoke the Terminal

The most important thing in Commander One is a two-panel interface that allows you to work without interruption and not be distracted by jumping over windows.

Mac Command Line: understanding the basics

Command line is a tool for controlling your computer using textual commands. It was used before when there were no computer mice and graphical interfaces. Despite the fact that we now have it all, the command line has not gone anywhere and is still used by developers and system administrators. Nevertheless, you can find different terms when speaking about command line in Mac operating system. So let’s take a closer look at all of them for better understanding and for not being confused.

Command line as a tool to control your Mac

Anatomy of the macOS Command Line

Console is a system that includes both the command line and the output from the executed command.

Command line is the line where you input commands.

Prompt is the beginning of the command line. Typically contains information about the users, computer, date, time, etc., and ends with $. Commands are typed and executed after the prompt.

Terminal is the graphical interface of the console allowing you to execute text commands and to interact with your operating system.

Basic principles of work

Now when the definitions are quite clear, there are several points worth consideration when working with Terminal, namely the basic principles of working with the Mac command line. There are several of them:

  • work in the Terminal is carried out only by means of text input;
  • commands are executed after pressing Return;
  • everything you type on the keyboard matters - even spaces;
  • commands are interrupted by pressing the combination Ctrl + C;
  • to indicate the full path to an object, you do not need to type it with your hands;
  • just drag this object to the end of the line. The rest is not your concern.

How to use Command Line on Mac computers

At the end of the prompt, you can see the dollar sign $. This is the character of the line waiting for user input, which is divided into three types:

  • Primary entry of the current user (denoted by the dollar sign $). Indicates that the command line is launched as the current user and is awaiting command input;
  • Primary superuser entry (denoted with hash #). Indicates that the command line is running as superuser (root user with administrator privileges) and is awaiting command input;
  • Secondary input (indicated by an angle bracket "greater than">). Indicates that a command has been entered, for the execution of which you need to specify any parameters, and are currently awaiting the entry of these parameters.

Ok, now that we know about commandLine, it’s time to move further and talk about useful command line Mac commands to continue working with the Terminal.

Table of basics Mac Command Line commands

Here you can find the most popular and frequently used command line Mac commands. If you are a newbie, don’t let them frighten you. Actually, everything is simple, you just need to get used to it a little. Of course, few users use the capabilities of the Terminal in everyday life. But, once you start working with the macOS command line, you quite quickly appreciate the opportunities it provides you.

Command Action
File Size and Disk Space
df shows you the amount of your disk space, including network drives.
du shows a list of all folders available on your system partition
Change Directory
cd ~ helps navigate through various directories
cd - allows returning to the previous directory
cd .. allows going up to the higher directory
List Directory Contents
ls - lists the file names in the specified directory
ls -f - shows files with their extension
ls -a - lists all files, including hidden ones
ls -lo - in addition to listing existing files, also shows their access rights and the date they were created
Copying
cp allows copying files and folders
ditto allows copying the directory, but with the attributes of hidden files
Search
find searches for files that match your criteria
find / -name searches for the file you need across the entire file structure, including all mounted drives, and displays the full path to it
find -x / -name the same, but the search will be carried out exclusively on the boot disk of your system
File and Directory Management
mkdir creates a new directory
rm allows deleting the specified file
rmdir allows removing the specified directory
clear clears Mac command line screen
mv allows renaming files
Processes
ps -x command, issuing in the terminal a list of processes of the current user
ps -ax shows a list of all processes
top lists the main processes involved and constantly updated information about them. The load on the processor, the size of the memory involved, the time, etc.
kill kills a hung process or sends a signal to it
sync forcibly writes the contents of the disk cache to the hard disk
lsof shows a list of open files on your system and files that are currently being accessed by a program

Tips to simplify Command line on Mac

  1. Use autocomplete for the input. For example, you can enter only the first letters of a command and press the Tab, after which the missing letters of the command will be added automatically. If there are several commands that start with the characters you have entered, then pressing Tab twice will display all these commands as a hint.
  2. Use autocomplete also for names and paths to files and directories. This function works similarly to autocomplete commands.
  3. Use autocomplete also for names and paths to files and directories. This function works similarly to autocomplete commands.
  4. If you press the up key ↑ in the Mac command line, the last command you entered will be displayed. If you continue pressing the up key ↑, you will go through the history of the commands you have executed. The full history is stored in the file ~ / .bash_history.
  5. If you enter two exclamation marks !! and press enter, the last command entered will be executed.
  6. If you mess up when typing commands in the command line Mac OS, try pressing Control + C, this combination stops the current command as well as closes it. You can also try pressing Q and Esc.
  7. In order to read the manual for any command and find out what it does, as well as what parameters it has, you need to type man command_name.

Conclusion

We hope that our article sheds light on Mac command line and after reading it you will effectively use Terminal to quickly and efficiently perform trivial actions on your Mac. To facilitate your workflow we recommend Commander One, a versatile tool that would be a cup of tea for both savvy users and newbies that features everything one needs including the command line.

Frequently Asked Questions

Yes, CMD is available on Mac and is called Terminal.
You can use either Teminal.app or Terminal emulator Mac apps to invoke command line in Mac operating system and execute the necessary command.
The list of commands used in Mac command line is huge. You can find the most widely used commands in the following paragraph in this article. However, before executing any command it is highly recommended to check its meaning in the proven sources.
Sudo command grants you admin rights permission and allows you to solve problems with different rights (usually higher) than those that are usually available to you.

Commander One

This dual panel file manager for Mac is fully compatible with MacOS 10.12 and later. Requires 61.07MB of free space, latest version 3.4.1(3580). Released 17 Jun, 2022.

4.7 rank based on 889+ users, Reviews (524)
Editor's Choice