2

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?

Kusalananda
  • 333,661
  • 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. – Jeff Schaller May 26 '22 at 01: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. – Artem S. Tashkinov May 26 '22 at 09:32

3 Answers3

2

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 then lists the built-in utilities.

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 a utility or a built-in can be just part of a command.

Vilinkameni
  • 781
  • 1
  • 4
  • 12
0

Commands are things that run when you type them at the command prompt. Some are built into the shell, some are external collectables, 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.

user10489
  • 6,740
0

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.

jwzumwalt
  • 259