Computing stuff tied to the physical world

More tools for your tool belt

Linux is like a human language: at first nothing makes any sense, then you start to see patterns, then you try a few words commands, often making mistakes and not getting anywhere initially. From then on, you’re on a fast upward trajectory: learning more words commands every day, combining them to get even more done, looking up the finer details, all the way to becoming really proficient and creative with these new-found language skills.

The alternative is the arcade game GUI, with lots of flashy visual effects, lots of buttons to press, and never-ending hunting and clicking. But no matter how you look at it, it’s still all about a person giving commands to a machine.

A GUI is like a dictionary: everything is in there, ya’ just gotta find it…

A command-line interface is like Meccano – i.e. erector set for US people. The pieces are all there to build anything, but you have to plan and plot your path or you won’t get anywhere.

With Linux’s command line, we’re going to construct, extend, and streamline – day in day out. No, not just the project we’re working on, but the environment we’re working in.

Just as Lisp has been called the programmable programming language, one could call the command line in Linux the sophisticated developer’s self-automation setup. If you need to do something more than once, you can usually find a way to create a tool or shortcut which will help you do it faster (including the time to make that tool or shortcut!).

There are several implications with this approach:

  • you need to learn commands, plus their features and options – lots of ’em
  • you’ll forget them again, so above all you need to learn how to find commands
  • some things you’ll do so often that they become second nature and reflex-like
  • the rabbit hole is real: anything is possible, but watch the time you spend on it
  • lastly, a warning regarding all this: there plenty of rope to hang yourself!

But don’t worry, the journey is an exciting one. A long and winding road, as they say…


Some commands in Linux are so basic, they won’t be covered here: cd, ls, cat, rm, grep, etc.

Getting and sharing source code – you’re going to need git right from day one:

    sudo apt-get install git

Then type “git --help” to get a quick summary, or “man git” to view over a dozen pages of information. To grab a copy of the embello sources, for example, you could type:

cd $HOME        # go to your home directory
mkdir github    # create a subdirectory called "github"
cd github       # go into that new subdirectory
git clone

This creates a directory called embello will all the latest files downloaded from GitHub.

Everything in open-source land lives on GitHub nowadays. Or nearly everything.

Git is a revision control system. Put your (developer’s) life in it, and you’ll never ever lose a change again. All changes, deletions, even complete rewrites, are tracked. Git never forgets.

But the big thing about git is something else: when you edit files in your “clone” made by git, you can still track updates made in the original by typing “git pull“. If the changes don’t interfere with the ones you made, they’ll be merged into your copy, without losing your own changes – even within the same source file. Which, dear reader, is a huge deal.

(if the changes do interfere, your files will contain both versions, very clearly marked)

Warning: git can be incredibly complex. And it always wins. If you try to fight the way it’s intended to be used, you will lose. Getting started with git is easy, learning it well is not.

Perhaps the best way to get started is to set up an account on GitHub via its help site.

The shell – this is Unix/Linux-speak for the software which presents itself as a command line. You type commands, it interprets them and performs the requested action.

No need to download or install anything, /bash is present as default shell in most Linux distributions, as well as in the Terminal on Mac OSX. There are dozens of other shells.

It’s important to learn the basics: commands, “pipes”, redirection, variables, scripts. Numerous tutorials can be found online. Pick one, so you know what it’s all about.

Make – the Make command was installed as part of the setup information given earlier. It should be the second tool after the shell to get quite familiar with, because it can do all the repetitive work for you.

Bash is about commands, options, input / output, and about how to combine it all.

Make is about rules, containing dependencies and commands, and when to execute them.

There’s a manual online, but that’s a long read. Here’s an old but useful quick intro.

Very useful

Diff is a tool to compare two text files. Extremely useful for source code, if you want to figure out differences between an old version and a new one, for example.

With git, there’s also “git diff ...“, which performs a similar task but now comparing versions stored in git. For example, with “git diff HEAD^ HEAD” you get an overview of everything that’s changed between the current version and the previous one.

Lua, Python, Ruby – these scripting languages are great to glue anything to anything. Need to massage a text file, extract specific data, launch a complex set steps, and much, much more? Lots of power under the hood of each of these languages – even a little experimentation goes a long way. Many people do all their programming with these tools.

All two-letter commands – at, bg, cd, df, du, fg, if, ls, mv, nc, ps, rm, su, tr, vi, wc, …

Many of these are classics from the Unix era. Most of them are very useful, and of course there are tons more – wait till you get to the 3-letter and 4-letter commands out there!

Finding your way around

With so many commands pre-installed, and tens of thousands more not installed by default but available by simply typing “sudo apt-get install <package-name>“, it can be hard to get to grips with it all. These commands will get you going:

Apropos – type “apropos blah” and you’ll get a list of all the installed packages with “blah” in their name or brief description (spoiler alert: no matches). The search term is actually a regular expression, so to get a list of all the package names or descriptions starting with “make”, type “apropos '^make'” to get over two dozen packages.

Try “apropos sort” for example.

Manual pages – type “man ls” to get 3 pages of explanation about the “ls” command. Try the same for “bash”, and you get 60+ pages of a well-written manual to dive into.

Try “man sort” for example.

Note: sometimes you get better information using the “info” command instead of “man“.

Keep in mind that both apropos and man only report what’s currently installed on your system. What if you need to find out about other packages? More commands, of course…

Apt/dpkg – the “apt” package system in Ubuntu comes from Debian Linux. It’s easy to use from the command line. Here are a few examples:

    apt-cache search blah       # list all packages mentioning "blah"
    sudo apt-get install blah   # this will fail, but you get the idea
    sudo apt-get remove blah    # not hard to guess what this does...

Warning: “apt-cache search sort” will return hundreds of matching packages.

Aptitude – this is a more advanced tool built around the apt/dpkg system. When run as “sudo aptitude“, you get a text-mode screen display, with a menu at the top – and some instructions on how to use it. Takes some getting used to, but it’s a quick way to install anything available in Ubuntu and Debian – all dependencies are automatically handled.

Aptitude is a nice way to look around and prepare for installing larger packages and combinations, because you can browse and select what to install and uninstall, and then view what aptitude is about to do (type “g”) before it starts doing it (type “g” again).

To quit aptitude, type “q” (sometimes more than once), and then “y” to confirm it.

Built-in help – last but not least: almost every single command in Linux will understand the “--help” (or sometimes “-h“) option to show a brief summary of the command.

Compare “make --help” with “man make” for example.

What’s this “sudo” thing?

The “sudo” command is a way to briefly gain “superuser” privileges. Anything potentially dangerous or harmful in Linux is protected from accidental use, and requires extra super powers. Things like formatting a disk, changing key system files, configuring hardware.

If you’re not allowed to run command “foo bar“, then you can force your way through by typing “sudo foo bar” instead, but you better be careful and know what you’re doing.

Sudo is a way of getting “administrator permissions” for the duration of that command. Tip: look up “sudo -i” if you need to be superuser for a while, but again be careful.

This brief Linux intro should be enough to get started. Welcome to the command line!

[Back to article index]