8

I was trying to find the naming convention for Linux commands.

For commands like cp, rm, mv, etc it seems to be based on first and second last character like

  • move is mv
  • list is ls
  • copy is cp
  • change directory is cd, the first character of two words, which makes sense

while sometimes ignoring vowels in some commands, which makes sense.

On the other hand, the command mkdir is not based on the previous perception: "make directory" is mkdir which should be more like md.

As we have naming convention for a variable in a bash script and another guide line (for example 1, 2), I am wondering whether any similar convention exists for these commands.

Michael Homer
  • 76,565
Adiii
  • 183

2 Answers2

11

Historically, UNIX commands are short because, at the time the OS was created, memory was scarce, networks were slow, keyboard were hard to use, and terminals (when available -- most of the times you got the output as a paper print) had small resolution. So it made sense to try to economise as much as possible.

Clearly one couldn't shorten at maximum any arbitrary command and yours is a good example: md could better be attributed to a command to generate a MD hash, and a shorthand for "directory" is "dir", so choosing mkdir for a command that creates a directory makes perfect sense.

See also my answer here: Why are UNIX/POSIX system call namings so illegible?

To sum up, there is no convention - as far as I know - for UNIX command names, apart from the guidelines above mentioned which come from historical technical limitations.

Romeo Ninov
  • 17,484
dr_
  • 29,602
  • Thanks for your good and concise answer and good point of MD but for directory why not dr first and 2nd last so its should be mkdr instead of mkdir. You are right I am agreed with you as was the constraint of time. its mean there is no such convention ? – Adiii Apr 26 '18 at 07:19
  • 1
    @Adiii You are free to create an alias called "mkdr" if you think that this is clearer and/or faster to type. – Kusalananda Apr 26 '18 at 08:05
  • @Adiii I've clarified this in the answer. – dr_ Apr 26 '18 at 08:10
  • @dr01 thank you and Kusalananda Yes we can – Adiii Apr 26 '18 at 08:39
  • 3
    @dr01, a good amount of short command are created by striping vowels (started by IBM long time ago). So there is kind of logic :) – Romeo Ninov Apr 26 '18 at 13:20
  • mkdir is also available as md... on DOS! – Stephen Kitt Apr 26 '18 at 18:28
  • 2
    Multics had short names for many commands, and Unix mostly used the same ones. But Multics used cwd to change the working directory and cd to create a directory. – Mark Plotnick Apr 26 '18 at 18:48
2

Unix was built by hackers for their own use. Short names mean less typing, that the names are "really mnemonic for use of casual users" (i.e., call them "copy", "list-files", "change-directory" or whatnot) was completely out of the question. So very common commands have two-letter names, vaguely mnemonic if possible (rm, cp, cd, ed, ln, cc, as, ld, ...), some have names honoring their autors (awk), still others are abbreviations of commands (grep is for "g/Regular Expression/p" in ed(1)).

Historical vagaries galore.

vonbrand
  • 18,253