Why do Windows & Ubuntu have similar shell commands?
The Windows cmd.exe
does not support ls
, mount
, etc., unless you installed these yourself and added them to the %PATH%
(via Cygwin, MinGW, Subsystem for Unix-based Applications (SUA) or something else). Powershell does. And that's because Powershell has these as aliases to standard Powershell commands, so that Unix users can be more comfortable. See the list of Compatibility Aliases in Powershell. Windows does have rmdir
, mkdir
, etc., but these, of course, don't support the same option syntax that you'd find on Ubuntu.
In Ubuntu, these have nothing to do with Bash. They are all external commands. There are standards for such utilities. POSIX is the most notable (see the list of POSIX-mandated utilities), and Linux Standard Base (LSB) is another that's important for Linux systems (which is mostly based on POSIX, but has some additions). The ones on Ubuntu are mostly provided by GNU, and GNU utilities often have more features than the base required by POSIX.
POSIX also defines the shell language that you mentioned (which is substantially different from the one in cmd.exe
). It is derived from the Bourne shell's syntax. Bash (now you know what the Bourne again refers to), also from GNU, also adds features on top, but can behave in a POSIX-compliant manner when required. The POSIX language is what you'd expect to get with sh
. bash
, ksh
, ash
, dash
, zsh
all use that language, with enhancements. csh
is in a (nightmare) world of its own, and tcsh
enhances csh
.
To understand a bit more, look into the history of Unix and Unix-like systems. Unix pre-dates Windows by over a decade, and these utilities first appeared in Unix.
Windows was, at one time, POSIX-compliant, since the US government required it for OSes used by government agencies (that's when they added the Services for Unix (SFU), from which came the SUA mentioned in the first paragraph). But that requirement was scrapped, and subsequently, SUA was dropped.
Related:
- Evolution of Operating systems from Unix
- Were all Unix commands re-written in Linux?
- Is Linux a Unix?
- What does it mean to be “sh compatible”?
(Note the common part of these posts - they are all on Unix & Linux, and tagged history - you might find browsing through that tag very informative.)