CLI or the Command Line Interface

The Command Line Interface is the most common and pervasive interface directly linking fingers typing on a keyboard (text) and the computer (commands). The CLI is a legacy mode of operating computing system which can be traced back to early telegraphic devices. In this lesson we will look at your computer’s own CLI and present ways in which you can use it to write, manipulate, analyse and transform text on your own computer system.

Goals

The aim of this lesson is for readers to develop an appreciation of the advantages of using the CLI for certain types of work involving text editing on a computer. As the CLI itself is text based, our goal is to present the history of the CLI and discuss how text-based computer interfaces are still up to this day on of the most important ways to communicate with the computer systems.

The goals of the lesson are:

  1. Understand the historical precedents leading to the development of modern CLI.
  2. Acquire basic knowledge on how to operate the CLI of your own computer.
  3. Develop the ability to recognize where and when the CLI is a better alternative than other types of computer interfaces (mainly graphical).
  4. Develop a critical perspective on why the CLI matters in some situation and when it does not.
  5. Acquire just-enough basic CLI vocabulary to be used in future (research) work.

History

We can trace back the history of the text-based interface as mode operating computers to the telegraph and of course the typewriter. Years before computing (as we know it) was invented, the telegraph was already a ubiquitous telecommunication system. Early operators of the telegraph used hand-operated devices, the Morse key, to send Morse codes down the communication cable, an interface that had many limitations due to it’s rather crude operation mode. From the mid 19th century on, a few devices were invented that featured a multiple keys keyboard interface and related receiver apparatus that would print messages sent using the keyboard input device. These greatly improved the speed in which messages could be sent and received. However, messages printed using these devices were still encoded raw; a received message would usually be in punched holes format on a piece of paper tape. For this reason, trained operators capable of deciphering such codes were still key interpreters of the wired cables.

It is not until the beginning of the 20th century, with the advent of the Teletype (TTY), that sending and receiving tele-typed text over telegraph lines was fully automated. Quite similar to the typewriter, a TTY made reading and writing encoded text seamless: the teletypewriter would encode typed alphabetic characters and the teletypeprinter would decode received encoded characters in an alphabetic format. Hence sending a message to an endpoint would be as easy as typing on a normal typewriter. This new type of telecommunication interface greatly changed the face of news and print media as it enable reporters and writers to send and receive “cables” on their own (without the need to be trained operators themselves).

But why is the history of the TTY important for our concern here? Well there’s two major reasons. First, the Teletype was historically important for the development of text encoding (Lesson1). Early Teletype machines used the Baudot code encoding scheme but Teletype Model 33 (a standard TTY device in the 1960’s and 1970’s) used the ASCII encoding scheme. For this reason, ASCII (and modern UTF-8) has, still to this days, control codes that refer to networking operational commands. These characters attest the legacy of TTY devices. Second, as a result of ASCII integration in Model 33, the TTY became an central interface to mainframe computing machinery in the 1960’s and 1970’s. Before the advent of the TTY, the standard computing interface was the punch card format. TTY introduced direct input of computing commands from the teletypewriter and formalised the output as teleprinted on paper (ASCII also have printing control codes). For a long period of time, the main medium of computing was printed paper.1

A quick note here to emphasize the fact that computing was done on mainframes back in these days. The “mainframe” was a “colossus” computer residing somewhere in a local or remote building. As explained above, interfacing with the mainframe was done on a TTY device. This type of topology lead to the term “terminal” to signify a user’s endpoint (where the fingers and the eyes are) and “time-sharing” to signify that the mainframe shared its computing time between multiple users and their respective terminals. Much like the early TTY/telegraph coupling, a user would send computing commands on his TTY device over a network cable and receive the results back from the mainframe onto the same device. Rather than “discuss” with another fellow human over the network, you would now “discuss” with the shared computer.

Datapoint3300

The first terminal to showcase a screen as output device (rather than paper) was the Datapoint 3300 by Computer Terminal Corporation (CTC).2 Other than having a glassy CTR screen, the main feature of the Datapoint 3300 was that it could seamlessly replace the Teletype Model 33 terminal and perform paperless the same operations. However, the Datapoint 3300 had obviously different circuitry than the Model 33. In order to drive its CTR monitor, CTC devised special electronic circuitry that kept track of the characters displayed on screen (shift-registers - a type of operational memory). The story goes that CTC, having a need to upgrade its circuitry, asked Intel and Texas Instrument (which are integrated circuit manufacturer) to produce a special ship that would be used to program its future screen-based terminals.3 This challenge lead to the development of one Intel’s first 8-bit microprocessor - the Intel 8008.4

The direct descendant of the Datapoint 3300, the Datapoint 2200 was the first programmable terminal, viewed by many as the first personal computer. The fact that the Datapoint 2200 was programmable, meaning that code could be written for and ran on the terminal’s circuit itself and not on a mainframe made it very attractive to computer programmers. Commands could be issued on the Command Line Interface and directly resolved locally without the need of an (expensive) mainframe.

This is were the story of terminals ends. If code is executed locally and not remotely, it is erroneous to talk about a terminal porperly saying but instead once must talk about the CLI (i.e., no more remote terminal but he emulation of the mainframe, as for the Datapoint 2200).

How

To access to the Command Line Interface of your computer you need a Command Line Interpreter. Every mdoern Operating System (OS) have such interpreter built-in. In fact, the Command Line Interpreter are legacy systems on most OS (OSX, Windows, Linux, Unix, etc.) because there was a time when interfacing with a computer was solely done typing commands on a terminal.5 Most computer programmers, even nowadays, use the computer CLI on a daily basis to write and run software and even to debug hardware.

Depending on which OS you are using, accessing its CLI is quite simple:

On OSX your CLI should look like:

Bingo! Say hello to the computer’s CLI!

Now in order to utilise the CLI in a productive way you need to learn a couple of fundamental commands.

  1. “ls” (OSX, Linux, Unix) and “dir” (Windows): lists all files and folders inside the directory your CLI’s current working directory.

  2. “cd”: changes the CLI’s current working directory

Using both commands, you can basically navigate your whole filesystem. It is important at this point to understand the idea of a “working directory” as commands issued on the CLI usually depends in the files present in its “working directory”.

We are now going to illustrate some useful commands (under OSX) that deal with text files and the likes. Hence, we will point our “shell” (another common name for the CLI) to the folder containing the files of this site.

Issuing the “ls” command results in:

Gauthiier:wwwriting gauthiier$ ls
Lesson1.html  Lesson2.md    Lesson5.md    index.html    wwwrite.bib
Lesson1.md    Lesson3.md    Lesson6.md    index.md
Lesson2.html  Lesson4.md    img/          style/

As you can see, directories are denoted with a leading “/” while files are not. Hence, “img/” is a directory and “Lesson1.md” is a file.

It is possible to list the content of directories using “ls” without changing the “working directory”. For example, let’s list the content of the directory “style/”:

Gauthiier:wwwriting gauthiier$ ls style/
style.css       template.html5

Ok now let’s play with file (meta)data.

The command “file” can tell you what type a file is. For example:

Gauthiier:wwwriting gauthiier$ file wwwrite.bib 
wwwrite.bib: UTF-8 Unicode English text, with very long lines

The command “wc” (word count) returns information about the content of the file:

Gauthiier:wwwriting gauthiier$ wc Lesson1.md
 118    1995   13100 Lesson1.md

where (1) the first column indicates the number of lines, (2) the second column the number of words and (3) the third column the number of bytes.

The command “grep” matches words to files that contain them (search). “grep” can search a specific file or lookup files recursively in a directory.

Let’s look up the word: wwword.

Gauthiier:wwwriting gauthiier$ grep "wwword" Lesson2.md
Let's look up the word: wwword.

“grep” gives the exact line-text where the word in found in the file.

Similarly we can look up the number of times a word appears in each files ending with .md or .html in the current working directory:

Gauthiier:wwwriting gauthiier$ grep -rc --include=*.{md,html} "wwword" .
./index.html:0
./index.md:0
./Lesson1.html:0
./Lesson1.md:0
./Lesson2.html:3
./Lesson2.md:3
./Lesson3.md:0
./Lesson4.md:0
./Lesson5.md:0
./Lesson6.md:0

As you can see the command “grep” can be instructed, using certain command parameters, to perform quite advanced searches. In general all commands from the CLI have specific parameters that can be set to specify a specific ways in which to conduct their operations.

It is, of course, out of the scope of this lesson to present all possible commands one can use to manipulate files and directories. For the remaining lessons, you only have to remember how to point your CLI to a specific working directory.

Extra

Unix Tutorial for Beginners

A beginners guide to the Command Prompt (Windows)

A list of all commands: OSX Windows Linux (bash)

References


  1. Something that is easily forgotten in the era of ubiquitous computer screens. For a discussion on the topic see Nick Montfort’s essay Continuous Paper: The Early Materiality and Workings of Electronic Literature.↩︎

  2. Datapoint 3300 brochure.↩︎

  3. In fact Victor Poor from CTC devised the architecture and instruction set. The instruction set is, to this day, found (a revised version of course) on Intel’s flagship x86 architecture, the most pervasive microprocessor architecture of all time (typing this text was processed by a x86 microprocessor).↩︎

  4. And subsequently the legacy 8-bit Intel 8080, 16-bit Intel 8086 and the whole x86 family of microprocessors. For all the details of the development of the Intel 8008, please refer to this document.↩︎

  5. Something that is easily forgotten in the era of ubiquitous computer Graphical User Interface (GUI). The CLI is to some degree reminescent of the Teletype (TTY).↩︎