12

Almost every programming tool has a command line version; many of which also have a gui version. It takes a lot of time and memorization effort to learn the different commands and various options/switches of the command line version.

So I have a couple of questions (which are not necessarily mutually exclusive):

1) When would you bother learning/memorizing the commands in the command line version of a tool which also comes in a gui version ?

2) What tools should I learn the command line version of ? .... compilers ? version control system ? etc, etc

1
  • If the tool that you are using provides a command-line interface, but does not have decent documentation for it, then I would be cautious about using such tool. If it does, then RTFM. It is not that hard, and if it gets to that point, then ask a question on StackOverflow.com If you need to figure out how to do something from command line, I have faith that you can. If you are not sure whether you need to figure something out, then you probably do not. Life is full of interesting things outside of work, if only there was enough time ...
    – Job
    Feb 5, 2011 at 18:10

10 Answers 10

21

I can see two reasons why you should learn the command line options of a program:

  1. When you need to automate the program in some way - build scripts, batch processing etc.

  2. When you need to optimise the behaviour of the program - reduce memory footprint etc.

As to which tools you should learn - well that totally depends on what you want to do next.

3
  • 1
    You always want to be able to script a program to be able to automate it...
    – user1249
    Feb 5, 2011 at 19:17
  • 1
    @Thorbjørn - isn't that what I said? Or wasn't I clear?
    – ChrisF
    Feb 5, 2011 at 19:19
  • 3
    Yes. I just stressed the automation part - not understanding that up front will cause pain later when trying to adapt the current methodologies into something scriptable.
    – user1249
    Feb 5, 2011 at 19:41
9

Lots of good answers already. I add one more additional point of view.

You replace GUI with command line tools, when you want to get the human out of the equation/process. Some reasons and/or benefits for doing this:

  • You get rid of the human error (when repeating the command)
  • Excellent for all kind of automation, for example deployment, building or running tests with randomized inputs.
  • You get to be really a power user. It gives you an option of climbing on the ladder of meta programming. You don't have to make every action (click on the GUI) yourself, you can easily script it!
  • You can chain tools together (think Unix pipes).
  • Make computers do the work -- you don't scale, computers do!

When to do it? When you find repeating yourself.

Of course there is place and time for GUI. But if you really want to harness the power of computers and surf the wave of Moore's Law, you need to learn scripting your tasks.

Edit: Extra bonus. You get to wear this T-shirt :)

7

Mines are:

1) To become more productive. For me, it is faster to do things in a shell than just clicking. I'm talking about using a tool, not setting up a service/tool/etc, because sometimes it's faster to have a wizard and just click on Next Next Next, although those wizards also exist in command-line versions :)

2) To use the command-line version in your applications. For example, let's suppose you want to convert a PDF to a text file. If you use the GUI version, it's fine. But if it also provides a command-line interface where you can do something like: ./pdf2text input.pdf output.txt, then if you need to develop an application that reads text from a PDF, you can easily use it, without using any APIs, or doing some tweaks...

3) To learn the general things of an application. For example, if you have diff installed on Windows, and a front-end for it to compare two files. That's perfect. But what if you need to use it on Linux? You can find the same front-end for Linux, but what if it doesn't exist? You'll have to learn again how to use it on Linux, install a new front-end and get used to work with it. If you have learned how to use the command-line version, you wouldn't have needed it ;)

About 3)... some people have lots of troubles getting used to work with Git on Windows. They say there are no good front-ends of it on Windows, but if you just learn the command-line way, you won't have problems. It works the same way. Of course, the problem is that sometimes peoples are scared of command-line ;)

I suggest you learning command line versions of:

  • Compilers like gcc
  • Debuggers like gdb
  • Git ;)
  • and lots of tools in GNU/Linux that you can get working on Windows like egrep, awk, find,...
5
  • Yeahhhh +1 for git :D Although diff is the one example I wouldn't use the real command for; I prefer vimdiff (although I guess technically thats terminal too so whatever) Feb 5, 2011 at 20:07
  • @mathepic you're right, but vimdiff is also a command-line tool, isn't it? Feb 5, 2011 at 20:12
  • At the same time its ncurses (I think, not sure) so I make a small distinction. Feb 5, 2011 at 20:12
  • yes, but I'm taking those as command-line tools too :) Feb 5, 2011 at 20:17
  • @mathepic: The answer to your concern: gvimdiff
    – Lie Ryan
    Feb 15, 2011 at 6:03
3

Why do you need to commit the parameter syntax to memory? That's why man exists and --help (/? if you are in winblowz land).

I find I can look up the options for just about anything in under a minute. The objective is to remember what the commands do, so you know what to look up!

1

Pragmatically, it comes down to whether or not the gui tool is missing a feature, or if it's faster from the command line.

The side-benefit of using a command line, however, is that you'll be more likely to read the documentation and figure out what's really going on. Especially with your example of version control, doing this from the command line will teach you quite a bit.

1
  • Compiler: Will be neededing for automated builds
  • Make or your build system: automated builds catch errors
  • Version control: I think so, but it is the least important of the three. But then I can do other command line operations, e.g. grep through the change messages.

But you don't need to memorize the options for the compiler or make; once those are set up for the project you don't have to change them frequently.

1

The benefits of learning a command line tool, I feel, far out-weigh the benefits of use the GUI. There are many times that GUI's lose features, however, it would not be fair to say that this is always the case (i.e. look at cmake on Windows - there is no reason to use command line outside of normal circumstances).

As far as memorization goes, there is no particular need to remember that program's command set the first time you use it. Just bookmark the manual (if you use the online manual otherwise use "man" on *nix) and if you need a particular functionality (which you have not memorized), just refer to the manual. Memorization on these things should come naturally by use. For instance, I run "tar" and "gzip" from the command line very often, but I would have to reference the manual to accomplish tasks which I do not ordinarily do.

Above all, if you are shipping a product or sending some sort of source code or otherwise to a fellow developer, it is much easier to include a skeleton of commands than it is to write detailed instructions on using the GUI. If the developer does not understand the command line options you used, he or she can simply look them up. To explain a GUI to someone is not always the most portable solution.

Regards,
Dennis M.

0

Everything, so that you aren't dependent on X11/Windows for development. Its nice to be able to completely develop from a terminal.

1
0

Short answer: The best time to change (i.e., use commandline) is NOW. Real men use keyboard. Real men DO NOT click. Period.

Longer answer: In long-term perspective, in addition to being more productive and hence more valuable (less likely to be laid off), using commandline can/will/should make you smarter (due to substantial practice/memorization) and healthier (because using both hands simultaneously in commandline interface instead of one with mouse is more suitable for ergonomics).

Here is a highly recommended article/essay, "Why Windows Causes Stupidity", at http://www.over-yonder.net/~fullermd/rants/winstupid/1

1
  • 3
    Joking or not, that real men crap is not going to win any prizes, even though I 100% agree that using CLI is so much more productive, the macho noise is just dumb.
    – ocodo
    Feb 15, 2011 at 7:15
0

I'm not sure that you should ever try to memorize the switches on a command-line tool. If you're creating a shell script or whatever to automate some task, you'd better look all that stuff up-- spend the thirty seconds now, to avoid hours of pain figuring out what went wrong later. If you're using the same command-line tool over and over again, maybe you should make a shell script...

Not the answer you're looking for? Browse other questions tagged or ask your own question.