3

I'm trying to figure out the correct term(s) for Unix/Linux "commands." Specifically, I have always understood that technically commands (e.g., cd) are built into the shell, and that other "commands" (e.g., rm, ls, mkdir, cp, mv) are better termed utilities, as they are stand-alone programs. (As far as I can tell, rm, etc. are all in /bin.) Furthermore, one way to tell whether something is a command is to see if it has a man page: commands don't, but utilities do. However, all of the sources I've found via Google use "commands" exclusively. Can someone set me straight on this or point me towards an appropriate reference?

Since exit doesn't have a man page and isn't in /bin, is it, like cd, a true command?

3
  • to add a small amount of confusion, there's also an external cd command/utility! :) I'm not sure if a good terminology-based answer exists; my inclination is to point to the type utility: if it points to a path on disk, it's a "utility" with a separate man page; if it replies with "builtin", then it's a shell built-in, etc. Commented May 26, 2022 at 1:25
  • This distinction was IMO arbitrary in the first place and has become even more so as time has gone by. I don't pay attention to them, and haven't noticed people doing this either. Commented May 26, 2022 at 9:32
  • 1
    I would say that when you refer to something you have typed (note that you can replace the word typed with executed), e.g., cd, ls, or even vim, it is more correct to call it a "command". Commented May 9, 2024 at 0:53

3 Answers 3

3

The Open Group Base Specifications (POSIX) defines the utility as:

A program, excluding special built-in utilities provided as part of the Shell Command Language, that can be called by name from a shell to perform a specific task, or related set of tasks.

The section Special Built-In Utilities explains that the implementation can decide to make any utility a built-in, meaning that the utility is a part of the shell and not an external program. Some utilities are guaranteed to be built-in; they are named Special Built-In Utilities. The section then explains two additional distinctions between Special Built-In Utilities and other utilities, and exhaustively lists all of the special built-in utilities. They are:

break : continue . eval exec exit export readonly return set shift times trap unset

(The text of the standard uses the words "colon" and "dot" instead of the symbols, but the actual names of those two built-in utilities are the symbols : and ..)

Command is defined as:

A directive to the shell to perform a particular task.

In the section Shell Commands, they are classified into one of the five categories: simple commands, pipelines, list compounds, compound commands and function definitions.

Thus, a "command" is different than a "utility" in the above sense (external program or a built-in). An invocation of an external utility or a built-in utility can be just part of a command.

1

The command vs utility debate goes all the way back to DOS (Microsoft) days. Prior to DOS most "commands" were entered at a terminal or located in what was called the "monitor" (keyboard i/o). Programs and Utilities were things you loaded via medium such as punch card, cassette tape, or disks.

The Unix/Linux/VMS/CPM way of doing things was to provide a multitude of commands that did a narrow job extremely well. From the very beginning IBM and Microsoft supported desktop computers with more of a Swiss Army knife approach of having multipurpose "utilities".

There is no genuine or official difference, but "utilities" are more often referred to as general purpose programs and "commands" refer to narrow purpose programs.

For example FDISK is usually referred to as a "disk utility" because of it's multipurpose role, and FORMAT is usually considered a command because of it's narrow purpose. (But I can show you where occasionaly people say FORMAT utility!)

New programmers soon learn the traditional names quickly - though admittedly it is quite arbitrary.

0

Commands are things that run when you type them at the command prompt. Some are built into the shell, some are external executables, some are both. The technical terms for this are "built in" and "external". There is no "true" command vs false command (but there are commands that can return true or false).

"utility" is has no particular technical meaning in unix and doesn't distinguish anything special. Any such distinction is in the documentation only and does not affect operating system function or operation, or distinguish between different types of executables or sources of executables.

Since there is no technical meaning for "utility" different documentation defines it differently and leaves some abiguity.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.