I have been using, studying and developing for Linux for quite a few years now, and over time, I have successfully convinced a few people to join the cause, and make the switch to Linux.

However, when these people went discovering this brand new world, every one of them eventually came to me, asking what the command was to do this or that:

  • What's the command to install a piece of software?
  • What's the command to list currently directory contents?
  • What's the command to open my web browser?
  • ...

To me though, it feels like they are asking the wrong questions. Indeed, I would actually expect them to ask:

  • What program do we use to manage software installed on the system?
  • What program can list current directory contents?
  • What are the available web browsing programs?
  • ...

It would seem to me that the term command is a very abstract word used to describe pretty much everything you type after your shell prompt. With this thinking, several of the newcomers I brought started to believe that:

  • Linux is made of a huge amount of commands.
  • There is a command for everything, and every command does one thing specifically.
  • By learning more commands, I'll become more capable as a Linux user/administrator.
  • By running ./something I don't run a command, but a program stored in my current directory, probably something I compiled myself.
  • ...

Due to that, I tend not to use the word command, and prefer to use program or executable file. I also explain that these executable files can be found automatically, without typing their absolute paths, thanks to the $PATH mechanism. Thanks to that, typing ls executes /bin/ls, which is a program stored in /bin, a directory registered within the $PATH variable.

Still, I come across the word command in many books, tutorials, guides, ... which eventually brought this question to my mind: does the word command actually have a meaning in the UNIX/Linux vocabulary? Does it refer to an actual concept other than "whatever you type in your terminal"?

  • there is the command command which, if nothing else, serves to moved the executed command out of command position, like command ls or command while. – mikeserv Sep 1 '14 at 20:01
  • 2
    sudo make me a sandwich... – jasonwryan Sep 1 '14 at 21:06

The POSIX shell spec refers to simple commands, compound commands, command position, and the command command.

The first two reference how/when a shell command is parsed and executed. For instance:

#one compound command
{ simple command; simple command && simple command; } 

The compound command is how much the shell must read in as input before evaluating and executing its constituent simple commands.

command position is the first word in each simple command and it has special significance in that it determines how the rest of the command is to be parsed. Certain reserved words, (such as if and while), when in command position, can indicate to the parser that what follows should be interpreted as a compound command and not merely a simple command.

The command command can serve to move a command out of command position. For instance, these two would be executed identically, but potentially parsed differently:

command simple command
simple command

A command line is the entire line that you type into the shell, which tells the system to perform some action. The command is generally the first word of the command line. It usually identifies a program to run, but it can also be a keyword that's used for control flow (e.g. if or while) or a built-in command for shell-specific operations (e.g. read, set or export). Sometimes command is used to refer to the whole command line; the context makes it clear which is meant.

A common distinction these days is between commands and applications. In a GUI environment, an application is a program started using the graphical shell -- commands are invoked by typing in the shell.

The answers to the example questions you gave would be:

  • What's the command to install a piece of software? Something like apt-get install.
  • What's the command to list current directory contents? ls
  • What's the command to open my web browser? firefox & or chrome &, most likely. Although if you're using a window system, there's probably a menu from which you'd select thr browser, so you wouldn't use a command to do this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.