April 6, 2007

An interactive Linux command line tutorial

Edit: A new version of cmd-tutor is now available. See here.


There has been a gradually increasing influx into the linux community in recent years. The release of Vista has encouraged a lot of people to take the plunge and switch to linux. And while it is not any more essential to use the command line to manage your linux desktop today, many newcomers are interested in knowing what it is all about.

A lot of excellent tutorials are available, like this for example, but there were some requests for an interactive tutorial. Those who have tried the online ruby tutorial will know what I am talking about.

So, I wrote this tutorial in python. Keeping in line with Unix philosophy, the mechanism for presenting the lessons is kept separate from the lessons itself. Therefore it is easy to extend it by adding more lessons later. Currently there are 5 lessons that I have written. These would serve as a gentle introduction to a newcomer.

You have to be running linux to use this. You can download cmd_tutor here. The instructions to install are in the package. Briefly, you have to extract the package somewhere, navigate to the src directory from the terminal and then type 'python install.py install' with superuser privileges. Once installed, you can type 'cmd_tutor' in the terminal to start the tutor.

Any comments and suggestions will be welcome.

2 comments:

Anonymous said...

Pretty cool - I got caught up in lesson 3 when it wouldn't let me go "up" a directory, though. I wanted to see the creation of inner/innermost and then I backed out too far and couldn't get back to cmd_test (and it doesn't allow tab completion?):

To make a series of folders in one go, we can use mkdir like this mkdir -p
testthree/inner/innermost. The '-p' instructs mkdir to make the /innermost
folder with its parents.

Tutor>>> mkdir -p testthree/inner/innermost


--------------------------------------------------------------------------------
If you try to remove the testthree folder now with rmdir, you find that non-
empty directories cannot be removed like that. You can use the command rm
-r testthree instead. '-r' here stands for recursive, so that the top
folder and anything inside are removed.

Tutor>>> ls -la

total 20
drwxrwxrwx 5 root root 4096 2009-02-02 20:30 .
drwxr-xr-x 3 root root 4096 2009-02-02 20:27 ..
drwxrwxrwx 2 root root 4096 2009-02-02 20:29 testone
drwxr-xr-x 3 root root 4096 2009-02-02 20:30 testthree
drwxrwxrwx 2 root root 4096 2009-02-02 20:28 testtwo

Tutor>>> cd testhree

Checkl ifs - youla typed
the command correctly

Tutor>>> ls -la

total 20
drwxrwxrwx 5 root root 4096 2009-02-02 20:30 .
drwxr-xr-x 3 root root 4096 2009-02-02 20:27 ..
drwxrwxrwx 2 root root 4096 2009-02-02 20:29 testone
drwxr-xr-x 3 root root 4096 2009-02-02 20:30 testthree
drwxrwxrwx 2 root root 4096 2009-02-02 20:28 testtwo

Tutor>>> cd testthree


Tutor>>> ls -la

total 12
drwxr-xr-x 3 root root 4096 2009-02-02 20:30 .
drwxrwxrwx 5 root root 4096 2009-02-02 20:30 ..
drwxr-xr-x 3 root root 4096 2009-02-02 20:30 inner

Tutor>>> cd inner


Tutor>>> ls -la

total 12
drwxr-xr-x 3 root root 4096 2009-02-02 20:30 .
drwxr-xr-x 3 root root 4096 2009-02-02 20:30 ..
drwxr-xr-x 2 root root 4096 2009-02-02 20:30 innermost

Tutor>>> cd ..


Tutor>>> cd ..


Tutor>>> ls -la

total 20
drwxrwxrwx 5 root root 4096 2009-02-02 20:30 .
drwxr-xr-x 3 root root 4096 2009-02-02 20:27 ..
drwxrwxrwx 2 root root 4096 2009-02-02 20:29 testone
drwxr-xr-x 3 root root 4096 2009-02-02 20:30 testthree
drwxrwxrwx 2 root root 4096 2009-02-02 20:28 testtwo

Tutor>>> cd ..


Tutor>>> ls -la

total 12
drwxr-xr-x 3 root root 4096 2009-02-02 20:27 .
drwxr-xr-x 9 root root 4096 2009-02-02 20:22 ..
drwxrwxrwx 5 root root 4096 2009-02-02 20:30 cmd_test

Tutor>>> cd cmd_test

Check if your typedm the command correctly

Tutor>>> cd cmd_test

Check if you typed the command correctly

Tutor>>> cd cmd_test

Check if you typed the command correctly

Tutor>>> cd cmd_test

Check if you typed the command correctly

Tutor>>> help

sh: help: not found
Check if you typed the command correctly

Tutor>>> ls -la

total 12
drwxr-xr-x 3 root root 4096 2009-02-02 20:27 .
drwxr-xr-x 9 root root 4096 2009-02-02 20:22 ..
drwxrwxrwx 5 root root 4096 2009-02-02 20:30 cmd_test

Tutor>>> cd c

Check if you typed the command correctly

Tutor>>> cd c*

Check if you typed the command correctly

Anonymous said...

hi, I think the file has been removed.