Learn is a Computer-Based Teaching tool that gives basic training in using UNIX and Linux. (Linux is a version of UNIX.) Learn was written in the 1970s at AT&T Bell Laboratories by Mike Lesk with some contributions from Brian Kernighan.

Back in the 1970's, computers were controlled using a command-line interface. you typed a command, the computer ran it and when it was finished, it came back for more. The learn software was created to teach people to use the commands that ran on the UNIX system.

Later, a free version of UNIX appeared called Linux, but by then point and click windowing systems had replaced the command line and the learn system was forgotten.

With the growth of Virtual Private Server (VPS) systems AKA cloud computing, the situation has changed again. Most cloud servers run Linux but they only have a command-line interface. So a lot more people have a use for UNIX commands and the learn software is useful again.

A well as cloud computers, Apple Macs run UNIX. It's heavily disguised behind a nice windows-style interface, but you can run the learn software on a Mac. Very cheap single-board computers such as the Raspberry Pi also run UNIX in the form of Linux. You can run the learn software on one of them too.

Learn works by introducing commands one by one and driving you through a series of lessons each of which involves using the commands to achieve some goal, such as creating a file with a specified contents. When you announce that you have finished the lesson, the software checks the result, marks the lesson and moves on to the next one.

Although a little antiquated, learn is valuable because it works by getting you to use real UNIX commands on a real UNIX system.

Learn offers a number of courses, the most useful being Files and More Files. With good progress, it should be possible to get through both of those in one day, but it would probably be better done in a series of short sessions.

The learn software was aimed at an American audience, specifically colleagues at Bell labs in the 1970s. Some of the lessons have a marked cultural bias. One requires a knowledge of baseball stars of the day. Being a Brit, I didn't have a clue what the answer was when I used learn back in the 1980s. I suspect that many Americans would have difficulty answering that one today.

Another lesson asks about "an unsuccessful English king". The answer is George III who was king when England lost the American colony. That may make sense to an American, but over here in the UK we remember George for being mad, not unsuccessful. People in other countries probably don't remember him at all.

A more serious problem with learn is that occasionally it can produces an impossible task. For example, it may ask you to find a file that it has failed to set up.

If you can't make sense of a lesson, skip it and move on to the next one. Nobody's watching you.


You need to install git and Docker.

You must get these commands exactly right, so copy and past them. To paste into a command window, right click anywhere in the window and use the Paste option in the menu that appears.

Installing Git and Docker on a Digital Ocean Droplet

See this page

Installing Git and Docker on a Mac

Start a command window, which is described here.

Then follow these instructions:

installing git

installing docker

Installing Learn

Once you've installed git and docker, install learn like so:

    git clone https://github.com/goblimey/learn-unix

    cd learn-unix

    docker build . -t learnunix

That last command will take a few minutes and display a running commentary. If all goes well, the last two lines should be something like:

    Successfully built 68b1841290ef
    Successfully tagged learnunix:latest

The first of those lines means that docker has built an image with ID 68b1841290ef. You get a different image ID each time you run this command. (You should only have to run it once.)

The second line says that the image is tagged with the name "learnunix". You can refer to it by this name rather than the image name.

Running Learn

Run the image like so:

    docker run -it --entrypoint=/bin/bash learnunix

which starts the docker image running within a container and produces a prompt something like this:


Within the Docker session a user called "learner" is logged in. You will use that user to run learn. The system is prompting for a command. Run this command:

    learn files

and you will see this:

        If you were in the middle of this subject
        and want to start where you left off, type
        the last lesson number the computer printed.
        To start at the beginning, just hit return.

Press the Return key and the first lesson will begin.

You can do the lessons at your own speed.

If you want to give up at any point, note the number of the last lesson you completed and shut the learn system down. To do that, hold down the CTRL key and type a single d (no return key needed). The learn command exits and you can type more commands into your command window.

When you end the docker session, all the files that you created in it are tidied away. Unfortunately, learn also forgets how far you got. That's why you need to keep a note of your last lesson number. When learn starts, you can give it a lesson number and it continues from that point.

Once you've finished the Files course, do the More Files course.

Shutting Down the Learn System

If you don't end the docker session tidily by typing ctrl/d, it will continue to run in the background, using up computer memory. You can end the session forcibly if you know its container ID. To find that out, start another comand window and do this:

    sudo docker ps

That produces a list of running docker containers, something like:

    CONTAINER ID  IMAGE        COMMAND                CREATED        STATUS       PORTS     NAMES
    a5666adfd5d5  68b1841290ef "/bin/sh -c /usr/loc…" 2 minutes ago  Up 2 minutes 2101/tcp  happy_bassi

So in this example, docker is running image 68b1841290ef in container ID a5666adfd5d5. Stop that container like so, using its container ID:

    docker stop a5666adfd5d5

Other Courses

Learn offers other courses, apart from files and more files, but the software that they teach about is of limited use these days.

The Editor course covers regular expressions, which are useful, but the editor it describes is an ancient command-driven tool. You will probably learn more by typing "regular expressions" into Google.

The first lesson in the Macros course begins "WARNING: This course was written for UNIX in 1979, not 1999, and has not yet been updated. Some details may be way out of date!"

Twenty years further on, that's not a good sign. Actually the macros involved could be useful, but only to people who wish to create and update UNIX man pages.

The eqn course covers a typesetting tool that is still used, but the subject is somewhat of a niche.

About the Learn Software

Learn was written at AT&T Bell Laboratories by Mike Lesk with some contributions from Brian Kernighan. This was part of the much bigger project that produced the UNIX system.

The learn software is not strictly open-source in the conventional sense. The material is copyright AT&T, but a note in the source code gives permission for fairly free use. For the precise conditions, see the file LICENSE or any of the C source files.

The software was originally included in version 7 UNIX which was released in 1978. The software and the lessons were not reworked as UNIX developed and they became increasingly out of date. Later versions of UNIX didn't have the learn software installed. The material was preserved by the OpenBSD group.

The software was written in the C programming language, and that language also evolved. Eventually it became impossible even to build and run learn.

In 2002 I reworked the learn source code so that it would compile and run. At the time this work didn't gain traction, partly because of a chicken and egg problem. Learn is aimed at people who don't know much about UNIX, but back then they needed to know quite a lot just to install and run it. Also, they needed access to a computer running UNIX. That could be done by installing Linux on an old Windows machine, but that involved knowing some UNIX commands ...

To get round that problem, in 2019 I reworked learn to run under Docker, making it easy to install.

Now with Raspberry Pi systems costing less than $50 and Digital Ocean droplets costing $5 per month, many more people are using UNIX systems, so the potential audience for learn is much bigger. If you're one of those people, Happy Learning!

Permanent Installation

Docker just packages up the compiling and installing of learn. If you don't want to bother with all that, you can clone the github repository and install learn permanently like so:

    git clone https://github.com/goblimey/learn-unix

    cd learn-unix/learn



    sudo make install

Users of the same computer can then run it like so:

    learn files

See the INSTALL file in the learn directory for more complex installations.

There are three programs, learn, lcount and learn.tee. Learn is the front end and the user only needs to find that.

The lessons are text files. They are stored in the lib directory which contains a directory for each course. Lesson 3.1a is in the file L3.1a, and so on.

The directory man contains the manual entry in nroff (man) format. When running the docker image, type "man learn" to read it.

A paper by Lesk in volume 2 of the version 7 UNIX manual explains how to write new lessons. Now over forty years old, the software looks clunky compared to modern computer-based training systems, but it runs under UNIX and the student is driven through a series of exercises using UNIX commands. I think that's what gives it its power as a teaching tool.

As Lesk explains in his paper, the main hurdle is to get the user started. To run learn, she has to understand how to type commands. This is the first thing that learn teaches, could she figure out how to run it ...