7

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.

9

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.

  • 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 7: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 8:05
  • @Adiii I've clarified this in the answer. – dr01 Apr 26 '18 at 8:10
  • 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
  • 1
    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
1

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.

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.