The Command Line

By | March 16, 2019

The text terminal can be a scary place for those that are new to the Unix/Linux world. That’s where we come in. The terminal has been around since the beginning of Unix in the yearly 1970’s and has yet to be matched in ability and flexibility. The goal of this site is to make sense of the terminal and bring its power to everyone’s finger tips.

Terminal-Make-Sense.png

Computers, in general, are complicated machines. When they were first made available, it took very dedicated and talented people to program them to do even the simplest of tasks. This involved directly telling the computer processor what to do initially with punch cards but eventually with assembly languages. A simple Hello World program would have looked something like:

section     .text
global      _start

_start:

    mov     edx, length
    mov     ecx, message
    mov     ebx, 1
    mov     eax, 4
    int     0x80

    mov     eax, 1
    int     0x80

section     .data

message   db  'Hello, world!', 0xa
length    equ $ - message

This is in stark contrast to the computer we know today. The graphical interfaces used today make computers very easy to learn and use and is what makes computers extremely popular. Unfortunately the down side is the complexity and resource usage of even the simplest of programs. Even today, computer power is trying to keep up with this type of software. Consider how your computer gets “slower” over time.

220px-X-Window-System.png

The middle ground between these two extremes is the command line. This is where you meet the computer half way. This simple interface keeps the programs fast and lean and can still output a great amount of information. It’s a powerful place to work from, but it takes some knowledge to do so.

We’re primarily going to be focus on Linux/GNU operating systems. FreeBSD will be included from time to time. Also a lot of this knowledge can be used on MacOS 10 and new systems as well since a large part of the OS came from FreeBSD.

A Brief History of Unix

Ken_Thompson_and_Dennis_Ritchie-1973.jpg

To understand all the components of the command line interface and it’s design, we’re going to take a small trip down memory lane. In 1971, the first edition of Unix was released by Ken Thompson (left) and Dennis Ritchie (right) for the PDP-11/20. At this time, the purchase of a computer was a serious investment (the personal computer wasn’t available yet). For a company to fully utilize a computer, it would need to have several people able to share and work on it at the same time. Computers at this time didn’t just come with a monitor and keyboard like today’s PCs. Rather they came with several serial ports in which dumb terminals were connected.

Dumb terminals were a keyboard and monitor with a text only interface. But in it’s simplicity some of Unix most powerful frameworks and ideas were born. First it was a multi-user/multi-tasking system. Microsoft Windows first came out as a multi-tasking system in the 1990’s. That’s almost 20 years after Unix. Next was the idea of Unix as a toolbox, where a program did one thing only, did it well and worked with other programs. Because of this, the command line is a very powerful interface to work from, even after almost 50 years after it’s inception.

The Parts of the Command Line

Although the command line seems very basic, it has three parts to it, the shell, the terminal and the tty device.

Terminal-Diagram.png

The tty Device
The tty device, also known as the teletype device, is one of the most unappreciated and unnoticed parts of this combination. It use to be an actual hardware serial device, and still can be, that a physical terminal connected to. Now a days, like terminals, it’s emulated with software call pseudo tty devices. The pseudo devices act exactly like a serial device but is a lot more flexible.
The Terminal
In the past, a terminal would have been a keyboard and monitor that connected to a serial port. Today, terminals are emulated with software like xterm, gnome-terminal, konsole and rvxt. It’s your view and interface to the computer itself.
The Shell
This is the actual program that you interact with. It’s what reads in commands and is responsible for executing them. The most common shell on Linux systems is bash, but it’s not the only one. Some of the other shells are tcsh, zsh, korn and fish. These shells are not just basic programs either. They come with advanced command editing, searchable command histories, auto completions and are endlessly configurable. They are meant to work for you.

Most of the software for the command line has been updated over the years with many advanced features but a lot of it’s history still remains. It’s a fascinating view into computing over the last 50 years.

Now lets look at “Command Line TTY Devices”…

2 thoughts on “The Command Line

  1. Pingback: Command Line TTY Devices – Digital Combine

  2. Pingback: Command Line Terminals – Digital Combine

Comments are closed.