This post will be mainly about the command line. Unlike some mainstream Operating Systems, Unix still uses heavily the command line as a primary way of interacting with the computer. Viewed from a distance, it seems weird that we'd still use it. After all we're in 2011, we have these cool desktop with 3D effects, transparency and high definition. Why would you want to use your computer through text-based commands? I'll tell you why: Because the command line is the most powerful tool ever invented in human-computer interaction, and will likely be forever. In this post, I thought I would present some of the things the command line is capable of doing that have proven to be a hassle with your standard point-and-click interface.
1- Bulk operations
The most commonly given example of command line advantages is bulk operations. This actually one of the things that command line does best. Have you ever had to rename a huge number of files, or copy multiple files from one place to the other? Then you know that the mouse and pointer aren't the best tools for the job at all. A real life example that happened today with me at work. I had to find every occurrence of a word "foo" in a pack of 500 XML files spread across 30 folders. There was over 4000 occurrences. Then I needed to store each of these occurrences in a temp file in order to show some statistics. All it took was one single command:
$ grep -r "foo" * > tmp_file
13 seconds later I had my results. Granted, I get to work on extremely powerful machines, but in a graphical environment, it would have taken me over a week to do this.
2- Scripting
This is actually where lies the real power of the command line. Originally, scripts were just a batch of commands you could launch at once. But today they have evolved to the point where they've become as powerful as full blown compiled programs. They have flow control, variables, conditionals, modules and everything you'd expect from a modern programming tool. Let's give a simple example. What if I asked you right now to create 100 folders/directories called tmp1 to tmp100. A real pain right? Here's how complicated it would be in command line:
for i in `seq 1 100`;
do
mkdir "tmp$i"
done
Of course today's scripts can be so much more powerful. You can find public repositories of scripts that would do all sorts of things, from backup scripts to internet info fetching, machine parc monitoring, load balancing, and it goes a long way.
3- Uniformity
A great thing about text commands is that they always follow the same format.
CMD [OPTION]... [ARGUMENT]...
It can roughly be explained by:
CMD: the name of the command
OPTION: command modifier, like -s or -v.
ARGUMENT: the "targets" of the function
...: None, one or many.
I like this because every time I am in front of a Unix terminal I can get started right away. Graphical interfaces (GUI) on the other hand can be quite misleading. If one item on the menu gets changed then you're lost. And that happens with every new version. When Vista came out, the new menu was very unsettling for me. Same thing goes for a new version (I don't remember which one) of Adobe Photoshop. Menu entries had changed place and there I was completely lost.
4- I don't like the mouse
I don't. There are number of studies that show how much time you lose moving from the keyboard to the mouse. And the injuries such movements can afflict. I don't even like the arrow keys on my keyboard. It's no surprise that I like text-based interfaces, Vim text editors and the likes. By keeping my hands steady in the same position all the time, I'm able to achieve levels of speed and comfort that the mouse and point and click interface simply won't allow me.
That's it for me. I'll let maybe some other CLI aficionados add why they enjoy the command line so much.