1.4. Unix User Interfaces

A user interface, or UI, refers to the software that allows a person to interact with the computer. The UI provides the look and feel of the system, and determines how easily and efficiently it can be used. ( Note that ease of use and efficiency are not the same! )

The term "Windows" refers to a a specific proprietary operating system, and implies all of the features of that system including the API and the UI. When people think of Windows, they think of the Start menu, the Control Panel, etc.

Likewise, "Macintosh" refers to a specific product and invokes images of the "Dock" and a menu bar at the top of the screen vs. attached to a window.

The term "Unix", on the other hand, implies an API, but does not imply a specific UI. There are many UIs available for Unix systems. In fact, a computer running Unix can have many UIs installed, and each user can choose the one they want when the log in.

1.4.1. Graphical User Interfaces (GUIs)

Unlike Microsoft Windows, which has a unique look and feel, there are many different GUIs (pronounced goo-ee) available for Unix. Some of the more popular ones include KDE, Gnome, XFCE, LXDE, OpenBox, CDE, and Java Desktop.

Gnome desktop
A FreeBSD system running Gnome desktop.
KDE desktop
A FreeBSD system running KDE desktop.
Lumina desktop
A FreeBSD system running Lumina desktop.
XFCE desktop
A FreeBSD system running XFCE desktop.

Practice Break

If you have access to a Unix GUI, log into your Unix system via the GUI interface now.

All Unix GUIs are built on top of the X11 networked graphics API. As a result, all Unix systems have the inherent ability to display graphics on other Unix systems. I.e., you can remotely log into another Unix computer over a network and run graphical programs that display output wherever you're sitting.

Note

This is not the same as a remote desktop system, which only mirrors the console display on a remote system. Unix systems allow multiple users in different locations to run graphical programs independent of each other. In other words, Unix supports multiple independent graphical displays on remote computers.

Most Unix GUIs support multiple virtual desktops, also known as workspaces. Virtual desktops allow a single monitor to support multiple separate desktop images. It's like having multiple monitors without the expense and clutter. The user can switch between virtual desktops by clicking on a panel of thumbnail images, or in some cases by simply moving the mouse over the edge of the screen.

1.4.2. X11 on Mac OS X

Mac OS X is Unix compatible, derived largely from FreeBSD and the Mach kernel project, with components from GNU and other Unix-based projects.

It differs from more traditional Unix systems like BSD and Linux, though, in that it runs Apple's proprietary graphical API and GUI. Native OS X programs don't use the X11 API, but OS X can also run X11-based programs. See Section 1.20, “Remote Graphics” for instructions on enabling X11 for Mac.

1.4.3. Command Line Interfaces (CLIs): Unix Shells

There are two basic type of user interfaces:

  • Menu-driven, where choices are displayed on the screen and the user selects one.
  • Command-driven, where the user types commands that they have memorized.

A GUI is a type of menu-driven interface, where the menu items are graphical icons. Some menu systems are simply text.

While modern Unix systems have GUIs, much work is still done via the command line, or shell.

Menu-driven systems are much easier to use if you're new to the system or use it infrequently, but can become cumbersome for everyday use. For example, an ATM (automatic teller machine) with a command-driven interface would likely be unpopular among banking customers.

If a user needs access to dozens or hundreds of features, they cannot all be displayed on the screen as icons at the same time. Hence, it will be necessary to navigate through multiple levels of menus or screens to find the functionality you need. Even if they could be displayed all at once, it would be a nightmare to find the one you want among such clutter.

Because of these limitations, most GUIs support hot keys, special key combinations that can be used to access certain features without navigating the menus. Hot keys are often shown in menus alongside the features they activate. For example, Command+q can be used on Mac OS X to terminate most graphical applications.

It is also difficult to automate tasks in a menu-driven system. Some systems have this capability, but most do not, and the method of automating is different for each system.

Perhaps the most important drawback of menu-driven systems is non-existence. Programming a menu system, and especially a GUI, requires a lot of grunt-work and testing. As a result, the vast majority of open source software does not and never will have a GUI interface. Open source developers generally don't have the time or programming skills to build and maintain a comprehensive GUI interface.

Caution

If you lack command-line skills, you will be limited to using a small fraction of available open source software.

In the tight competition for research grants, those who can use the command-line will usually win.

A command line interface, on the other hand, provides instant access to an unlimited number of commands and is easy to automate. We can simply store a sequence of commands in a file, called a script.

A command line interface requires some learning, since we need to memorize some commands in order to use it efficiently. However, we usually need only learn a few commands to get started, and once the basics are learned, a command line interface allows for much greater efficiency and flexibility than a GUI.

The small investment in learning a command line interface can have a huge payoff, and yet many people try to avoid it. The result is usually an enormous amount of wasted effort dealing with limited and poorly designed custom user interfaces before eventually realizing that things would have been much easier had they learned to use the command line in the first place. It's amazing how much effort people put into avoiding effort...

A shell is a program that provides the command line interface. It inputs commands from the user, interprets them, and executes them.

Using a shell, you type a command, press enter, and the command is immediately executed.

Command Line Interface
Unix Shell

The term shell comes from the view of Unix as three layers of software wrapped around the hardware:

Unix layers
A 3-layer Model of Unix
  • The innermost layer, which handles all hardware interaction for Unix programs, is called the kernel, named after the core of a seed. The Unix kernel effectively hides the hardware from user programs and provides a standard API. This is what allows Unix programs to run on different kinds of computers.
  • The middle layer, the libraries, provide a wealth of standard functionality for Unix programmers to utilize. The libraries are like a huge box of Legos that can be used to build all kinds of sophisticated programs.
  • The outermost layer, the CLI, is called a shell.

1.4.4. Terminals

All that is needed to use a Unix shell is a keyboard and a screen. In the olden days, these were provided by a simple hardware device called a terminal, which connected a keyboard and screen to the system through a simple communication cable. These terminals typically did not have a mouse or any graphics capabilities. They usually had a text-only screen of 80 columns by 24 lines, and offered limited capabilities such as moving the cursor, scrolling the screen, and perhaps a limited number of colors.

Hardware Terminal

Hardware terminals lost popularity with the advent of cheap personal computers, which can perform the function of a terminal, as well as running programs of their own. Terminals have been largely replaced by terminal emulators. A terminal emulator is a simple program that emulates an old style terminal within a window on your desktop.

Terminal emulator
A Terminal emulator.

All Unix systems come with a terminal emulator program. There are also free terminal emulators for Windows, which are discussed in Section 1.6, “Logging In Remotely”.

For purists who really want to emulate a terminal, there's Cool Retro Terminal (CRT for short, which also happens to stand for cathode ray tube). This emulator comes complete with screen distortion and jitter to provide a genuine nostalgic 1970s experience.

Cool Retro Terminal
Cool Retro Terminal

1.4.5. Basic Shell Use

Once you're logged in and have a shell running in your terminal window, you're ready to start entering Unix commands.

The shell displays a prompt (such as "FreeBSD manta bacon ~ 392:" in the image above) to indicate that it's waiting for you to enter the next command. The shell prompt can be customized by each user, so it may be different on each Unix system you use.

Note

For clarity, we primarily use the following to indicate a shell prompt in this text:

shell-prompt:
	    

The actual shell prompt you see may be different on each individual Unix system you use.

Including the hostname, user name, and other information in a shell prompt is a common practice and very helpful for users who are logged into multiple Unix systems at the same time from the same desktop. This discourages users from running a command on the wrong computer!

Section 1.17, “Shell Variables” explains how to set your shell prompt in common Unix shells.

The shell prompt in the terminal window above is "FreeBSD manta bacon ~ 392:". At the first prompt, the user entered the command ls, which lists the files in the current directory. After ls finished, the shell printed another prompt.

To enter a Unix command, you type the command on a single line, edit if necessary (using arrow keys to move around), and press Enter or Return.

Note

Modern Unix shells allow commands to be extensively edited. Assuming your terminal type is properly identified by the Unix system, you can use the left and right arrow keys to move around, backspace and delete to remove characters (Ctrl+h serves as a backspace in some cases), and other key combinations to remove words, the rest of the line, etc. Learning the editing capabilities of your shell will make you a much faster Unix user, so it's a great investment of a small amount of time.

Practice Break

Log into your Unix system, open a terminal if necessary, and run the following commands:

shell-prompt: ls
shell-prompt: ls /
shell-prompt: ls -al
shell-prompt: mkdir -p Data/IRC
shell-prompt: cd Data/IRC
shell-prompt: nano sample.txt

Type in some text, then save the file (press Ctrl+o), and exit nano
(press Ctrl+x).

shell-prompt: ls
shell-prompt: cat sample.txt
shell-prompt: wc sample.txt
shell-prompt: whoami
shell-prompt: hostname
shell-prompt: uname
shell-prompt: date
shell-prompt: cal
shell-prompt: cal nov 2018
shell-prompt: bc -l
scale=50
sqrt(2)
8^2
2^8
a=1
b=2
c=1
(-b+sqrt(b^2-4*a*c))/2*a
2*a
quit

shell-prompt: w
shell-prompt: ls /bin

1.4.6. Self-test

  1. What is a UI?
  2. What is a GUI?
  3. What is the difference between Unix and other operating systems with respect to the GUI?
  4. What is a CLI?
  5. What are the advantages and disadvantages of a CLI vs. a GUI?
  6. What is a shell?
  7. What is a kernel?
  8. What are libraries?
  9. What is a terminal?
  10. Do people still use hardware terminals today? Explain.
  11. What is a shell prompt?