Skip to main content

Command Line Interface

CLI

Pronunciation
see-el-EYE
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/command-line-interface

In short

A command line interface (CLI) is a text-based way of using a computer: you type a command with options and arguments, press Enter, and read its output.

What is a command line interface?

Instead of clicking through menus, you write what you want: git commit -m "Fix login" or docker run -p 8080:80 nginx. A command has a name, arguments such as file names, and options or flags that change its behavior, written as -v or --verbose. Almost every tool prints its usage with --help.

Developers rely on CLIs because they are fast, precise and scriptable. Anything typed can be saved in a script, repeated in a CI pipeline or combined with other commands through pipes. Tools such as git, npm, docker, kubectl and cloud CLIs are often more capable than their graphical counterparts, and remote servers are usually managed entirely through the command line over SSH.

Well-behaved CLI programs follow shared conventions: they read input from standard input, write results to standard output and errors to standard error, and return an exit code, where 0 means success and anything else means failure. Following these rules is what lets small tools be chained together reliably.

A common misconception is that the command line, the terminal and the shell are the same thing. The terminal is the window that shows text, the shell, such as Bash or PowerShell, interprets what you type, and a CLI is the text interface of a particular program, such as git's.

Key takeaways

  • A CLI is a text interface: type a command, read the output.
  • Commands take arguments and options such as --verbose.
  • CLIs are fast, precise and easy to script and automate.
  • Exit code 0 means success; stdout and stderr carry output and errors.
  • Terminal, shell and CLI are different layers.

Example

Anatomy of a commandbash
#  program  subcommand  options                   argument
   git      commit      --amend --no-edit         # (no argument)
   grep     -rin        --include="*.ts" "TODO"   src/

# Most tools explain themselves
docker run --help

# Exit codes make commands scriptable
npm test && echo "Tests passed" || echo "Tests failed: exit code $?"

Readers ask

What is the difference between a CLI and a GUI?

A CLI is operated by typing text commands; a GUI, a graphical user interface, by clicking windows, buttons and menus. CLIs are easier to automate and script, while GUIs are easier to discover for new users.

Why do developers use the command line?

It is faster for many tasks, works the same on remote servers, can be scripted and automated, and many developer tools offer their full functionality only through a CLI.

What is an exit code?

A number a program returns when it finishes. Zero means success and any other value signals an error, which scripts and CI pipelines check to decide what to do next.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings