Command-line interface basics

A command-line interface is a powerful and a flexible way for humans to interact with computers. Here we explain the basics of it for beginners.


The command-line interface (CLI), also known as "command prompt" or "console", or sometimes referred to as "terminal", allows the user to issue commands to the underlying software. The commands are typically lines of text that the user could type in, for example through a physical or on-screen keyboard, or the underlying software could read from a file. The main software program that deals with commands is often called a "shell" or a "command interpreter". It reads the input text lines from the user or from a file, interprets them as commands and acts accordingly. The resulting actions may include starting other programs or calling functions of the operating system, for example.

Nowadays, casual computer users would generally prefer to use a graphical user interface (GUI) and so they do not need to use CLI, but a CLI is nonetheless a part of most modern operating systems like GNU/Linux, BSD-style operating systems and Windows, including Windows 8.1. Due to its special abilities and wide availability the CLI is a powerful, flexible tool for accomplishing some non trivial tasks or troubleshooting problems. From a developer's perspective, it is sometimes cheaper, faster and more deterministic to develop, or even just use, a CLI based program rather than a GUI based program. For example, if you need to create a list of all and only the new pictures within a huge directory tree against a backup archive, then you might well prefer to write a few clever commands and let the computer do the job for you automatically, rather than reviewing the pictures one by one through a GUI based program. Of course, there could be the opposite situation that you may want, for example, to draw a diagram, and although there are CLI programs that would allow you to type in drawing commands and then export to a graphical file format, it is faster and more efficient to draw the diagram with a GUI program.

A screenshot from a GNU/Linux system, which demonstrates a GUI window running Bash shell as a command-line interpreter
A GUI window running Bash shell as a command-line interpretter

In order to improve the readability, our command line examples employ simplified text representations instead of screenshots. An initially blank CLI window, without any user input, may look like one of the following three blocks of text.


In the examples above the symbols $, # and > are just command prompts; they are printed by the system; the user does not type them. We sometimes include them in our CLI examples, whenever the context of which the user works with CLI has any importance. The dollar sign ($) prompt means an ordinary user in GNU/Linux or MinGW/MSYS environment, the number sign or hash (#) prompt means a super user in GNU/Linux, and the greater-than sign (>) prompt means native Windows operating system or Wine emulator under GNU/Linux.

Were the operating system and the environment do not matter, a CLI example shows only the user input, that is what you have to type in. For example, to check the version of your installed GNU Compiler Collection (GCC), you need to type in:

gcc --version

Nevertheless a more complete example, including the output of a given command, may look like this:

$ gcc --version
gcc (Gentoo 4.6.3 p1.11, pie-0.5.2) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

In any case you should remember not to type in the symbols $, # and > if a command line example starts with any of them.

Copyright (C) 2017 Terms of use and legal disclaimer

This page is valid XHTML 1.0 Transitional with valid CSS