In Linux I have shells (for instance bash, csh etc.) and terminal emulators (for instance xterm). Shells execude commands and terminal emulators display black window with white letters.
And how is it in Windows? I know I have cmd.exe there, but what is it? Is it a shell, or is a terminal emulator, or is it both?
And how is called the interpreter that executes bat files? Are they executed by cmd.exe or by something else?
Windows Command Prompt (also known as the command line, cmd.exe or simply cmd) is a command shell based on the MS-DOS operating system from the 1980s that enables a user to interact directly with the operating system.
A physical terminal is referred to as a console. The shell is a command-line interpreter. A command line, also known as a command prompt, is a type of interface. A terminal is a wrapper program that runs a shell and allows us to enter commands.
A shell is a user interface for access to an operating system's services. Most often the user interacts with the shell using a command-line interface (CLI). The terminal is a program that opens a graphical window and lets you interact with the shell.
Windows has two command-line shells: the Command shell and PowerShell. Each shell is a software program that provides direct communication between you and the operating system or application, providing an environment to automate IT operations.
The architecture of Linux and Windows is different. That's really it - you should not look for similarities when there are none.
Linux is based on UNIX, which goes back to the days of dumb terminals. Graphics devices were highly specialised (and expensive), and uncommon. Most UNIX access was through character driven terminals (asynchronous at that).
There were many manufacturers of terminal devices. One of the most successful at that time was DEC (since taken-over by HP) who had a series of terminals used on their VAX computers: vt52 was the most basic, vt100, vt220, vt320 gave increasing functionality. Terminal emulators like putty emulate those. IBM, HP, and others all had their own devices as well.
The problem is that all these terminals were different, and had to be driven differently. So a database of terminal instructions was created, first called termcap
and then terminfo
. The database was accessed depending on the setting of the TERM
environment variable, which is still used.
In comes graphics, specifically Xterm, and a terminal window. The database has control information for xterm, and the TERM
variable is set accordingly.
Of course Microsoft's Windows is a totally alien operating system so far as UNIX is concerned, so it has to pretend to be a UNIX terminal. That is what a terminal emulator like putty is. It will be pretending to be one of those ancient terminals that are nowadays only found in museums.
So, cmd.exe is not a terminal emulator because it is a Windows application running on a Windows machine. There is no need to emulate anything.
It is a shell, depending on your definition of what a shell is. Microsoft consider Windows Explorer to be a shell. In other words a shell is just a program that runs other programs. Most UNIX/Linux people would not call a GUI a shell, but that's just semantics.
cmd.exe is a console program, and there are lots of those. For example telnet
and python
are both console programs. It means they have a console window, that's the monochrome rectangle you see. Some people think that is the same as cmd.exe (and even worse call it a "DOS box"), but it is not, it just uses the same console APIs. A Windows graphics program has a "Main Window" associated with it, but it can if it wishes create a console as well! They don't usually, but they can.
cmd.exe scripts have .bat
(or less common now .cmd
) file extensions by default. But this file extension association is just a set of lookups in the Windows registry (HKEY_CLASSES_ROOT). There is no magic here, it is just like associating .doc
with Microsoft Office Word, instead .bat
is associated with cmd.exe.
One of the clever features of UNIX is the #!
line on scripts. This can be used to run bash, ksh, sed, awk, perl, python, ruby, etc, etc. If you have more than one version of, say, python installed, then you just change the #!
line to pickup the right one. No such flexibility on Windows, you can only associate one program at a time with a file extension.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With