11

I wish to understand at a conceptual level, the difference between a terminal app, Command Line Interface (CLI), Command Line Tools (CLT) and Prompt. I am confused as to what the difference is between them?

The thing that threw me off was realizing that Apple does not ship macOS with CLT (Command Line Tools) pre-installed, and I have to download and install it separately. Doesn't that mean that Terminal.app is useless unless I download the CLT?

I am using zsh as my shell running on macOS Catalina 10.15.6.

Clarification

My confusion is stemming from Xcode CLT. I don't understand what a CLT is?

  1. Is Xcode CLT a compiler? And if it is built into macOS, why do I need to download Xcode's CLT?

  2. Why do I need an app like Terminal.app to access the CLI. Isn't the CLI an interface to begin with?

  3. Does Homebrew (which is a package manager) considered a CLT that has its own CLI that I interact with using Terminal?

I can't seem to wrap my head around these concepts and the connection between them.

5 Answers5

17

CLI (Command Line Interface) is a general description of an interface that you interact with by typing commands. On the Mac your primary CLI is Terminal.app. On Windows it is PowerShell or Command Prompt. On the old Amiga OS it is simply called "CLI".

Terminal is the program or application ("app") that is used to access the Command Line Interface. On macOS terminal is located in the /Applications/Utility folder and called Terminal.app. There are alternate terminal applications (on macOS and Linux/Unix) that provide other features in the same way that Apple's Pages app offers word processing features presented in and implemented in different way that Microsoft Word.

Command Line Tools Are indeed shipped with and easily accessible in macOS using the Terminal.app. Since macOS is based (originally) on the Berkeley Standard Distribution Unix (usually called BSD Unix, or just BSD), it comes with (pretty much) the standard suite of Unix command line tools. This will be similar (with some significant differences) to the command line tools shipped with most Linux distributions.

Shell Though you did not mention this it is important to understand that macOS (and many Unix and Linux distributions) ship with a number of shell programs. Until recently macOS shipped with BASH as the default shell, more recently changed to ZSH, though BASH is still available. The differences in shells are subtle (to casual users) but define, in (slightly) different ways, the environment we use to run the command line tools. For most people the actual shell you use is unimportant. For programmers and system administrators the shell they use is vitally important to provide a customizable environment suitable to their specific needs.

Prompt is the character or characters that the shell presents in the terminal.app to indicate it is waiting for input. EG it is prompting you to type something. I have modified my prompt from the default so yours will look different than mine (below) where the prompt character is %:

My terminal prompt

TDLR

You have the command line tools built-into macOS. They are accessed using the Terminal.app (that then uses the ZSH shell).

You can download other standard Unix versions of these commands if the current ones don't do the job you want, the way you want them to, or are just plain missing. One of the more popular repositories of open source commands is Homebrew.

Homebrew is by no means necessary to the functioning of macOS but depending on your needs and desires in an operating system, they may provide good (or just familiar) alternatives to what Apple ships with its operating systems.

  • 10
    There are also the Xcode Command Line Tools which indeed need to be downloaded/installed separately. – nohillside Sep 10 '20 at 19:51
  • Is CLT a compiler? And if it is built in macOS, why do I need to download Xcode's CLT?
  • Why do I need an app like Terminal to access the CLI. Isn't the CLI an interface to begin with?
  • Does Homebrew (which is a package manager) considered a CLT that has its own CLI that I interact with using Terminal?
  • – captaincustard Sep 11 '20 at 03:47
  • 3
    @CaptainCustard Xcode Command Line Tools are an additional install which allows to compile applications from the command line (instead of using the Xcode application). – nohillside Sep 11 '20 at 12:21
  • @nohillside Does that mean I can't compile from the CLI by itself without Xcode's CLT? Why wouldn't the builtin CLT compile? Is it because different CLT support different languages (Ruby, C++ etc.)? – captaincustard Sep 11 '20 at 19:29
  • @CaptainCustard compilers are specific for each language, Xcode supports C, ObjectiveC and Swift (and probably C++). If you want to use Ruby you can install it via Homebrew. – nohillside Sep 11 '20 at 19:32
  • @nohillside when you say "install it", what do you mean by "it"? A compiler for the Ruby language? And if so, how would Homebrew be able to run Ruby code if the CLT it requires (Xcode's CLT) doesn't compile Ruby? – captaincustard Sep 11 '20 at 19:34
  • 1
    @CaptainCustard Ah, my bad. ruby is (as are perl or bash part of each macOS installation, you don't need to install it separately. And it's not a compiler (which compiles/transforms source code into machine language), it's an interpreter which executes source code directly. – nohillside Sep 12 '20 at 05:00
  • @nohillside Do you mind explaining where "prompt" would fall into all of that? – captaincustard Sep 12 '20 at 10:12
  • 2
    @CaptainCustard I have added that (prompt) to my answer. – Steve Chambers Sep 12 '20 at 13:44