1

When I install some Linux distros with a GUI, they come with the shells sh and Bash. The CLI let you operate the system through sh and Bash, but what about the GUI? Does the GUI let you operate the system through sh and Bash or it has it's own shell to intermediate between you and the kernel?

  • 2
    This is not unclear at all. I suggest that close voters go and read https://superuser.com/a/329479/38062 and learn the metaphor. – JdeBP Nov 13 '17 at 04:26
  • Shells like sh or bash are made for humans to interact with the system. For a GUI, it would be a detour to use such a shell: Convert the thing to do into a textual form, that will get parsed by the shell. The command line shells use a C API that can be used directly by the GUI. – Philippos Nov 13 '17 at 08:30

1 Answers1

3

A shell, in computing terminology, is the outermost layer of the operating system, i.e. the part of the operating system with which the user interacts. (See also JdeBP’s excellent exposition on SuperUser.) Thus on Windows, the typical shell is Explorer (which manages the desktop); on Mac OS in its various incarnations it’s the finder; on Unix-style systems it’s whatever the user has configured as the primary interface to the system (it could be /bin/bash, or /bin/ksh, or some other /bin/*sh in a console, or GNOME, or Looking Glass, or CDE, or twm, the list goes on and on and on).

Many readers however will refer to POSIX, where the shell has a specific definition:

The shell is a command language interpreter.

... with specific syntax and commands, all defined in POSIX and variously extended by common shell implementations nowadays.

Both categories of shell use the same type of method to interact with the kernel, at least on Unix-style systems: they ultimately use system calls, albeit usually wrapped by some sort of library (the C library). That’s the central command interface between the kernel and all running programs, including shells of various types: Bash uses system calls, GNOME Shell uses system calls, Nautilus uses system calls, etc. A GUI can be implemented entirely without using /bin/sh.

(All this ends up being somewhat confusing when one realises that various components of a typical GUI can be implemented using different tools, including of course the “CLI” shell — so there are typically parts of a Linux GUI implemented using /bin/sh, but they don’t have to be.)

Stephen Kitt
  • 434,908