Tech, Autos, & Gear in Layman's Terms Since 2006

1079

August 22, 2013 • News

When to Use the Command Line and When to Stick to a GUI

CommandorGUI

Back in the early days of computing there was DOS, and DOS used what we call a command line. A command line or shell is a text interface for interacting with your computer. Today graphical interfaces rule the day, but the command line is still useful … in fact, sometimes it might even be better. Read on for more on how to improve your computing life with the good ol’ command line.

When I bought my first IBM compatible PC, as we called them back in the day, DOS was the only way to interact with the PC. We launched programs by simply typing in the name of the program and pressing enter.  To install them, you just copied them to the hard drive. If the program had graphics, they were EGA or VGA if you were lucky. Most productivity apps were text-based; even Microsoft Word started off as a text-based program.

When Windows came around, I jumped on the bandwagon with a lot of other people. My use of the command line had flagged, as it was so cool just to be able to run multiple programs at the same time and to have fonts!  So why on earth would I want to continue using DOS?

Many years later, I picked up Red Hat Linux at a local office supply store. While I could not get it to work at the time, I did reacquaint my self with the beauty and simplicity of typing in commands. Years later, I still find myself writing scripts that make my life easier, but sometimes it’s just easier to use the graphical interface.  

So when should you use the GUI(Graphical User Interface), and when should you use the command line? That’s a good question and one that I will attempt to answer.  Before I go on, on important thing to note is that with the exception of many mobile devices, there is a command line environment available on every modern operating system — be it Windows, Linux or Mac OS. Although I will not be covering many specifics, each case I mention should be possible on Windows, Mac OS X or Linux.

Copying Directories and Files: Command Line Wins for Me

Every modern OS comes with a graphical file browser.  While it works well for digging in folders and finding things, I find it inefficient when I want to do simple copies of one directory to another drive or subdirectory. For example, in the Command Prompt on Windows, I can copy a directory like this:

xcopy <directory1> <directory2>

On Linux and Mac, it should look something like this:

cp -R <directory1> <directory2>

For me, this is much easier than using a graphical browser, because it’s quick and does not require anything but the keyboard once the command prompt or terminal (for Mac and Linux) has been launched.

Using the command line to do this also brings with it the ability to write a simple script to backup one directory to another on the same drive or even on another physical drive.  The destination could even be a network drive. The key here is you can repeat the same set of commands over and over again.  This is much better, to me, than dragging and dropping in a GUI.

 

Batch Processing Images: Command Line Wins Again

One program that started out on Linux but has made its way to both Windows and Mac OS X is Imagemagick. Imagemagick isn’t the only command line batch image processing program available, but it’s one I have used in the past.

The word ‘batch’ is used whenever you want to do the same thing over and over again on a set of files.  The key here is that it will take you MUCH less time to issue a one line command on a group of images than it will doing the same thing in a graphical editor. For example, let’s say you needed to rescale a group of images so they would be no larger than 700 by 700.  To use Imagemagick to do this when you are in a directory full of images, you’d do the following on a Linux or Mac OS X computer:

 

for file in *.png; do convert $file -resize 700x700 resize-$file; done

 

The above command utilizes a unix shell, specifically the Bourne Again Shell(also known as bash), to resize a bunch of png (Portable Network Graphics) files so that they would fit inside 700×700 as best as they can. This command will also respect the aspect ratio of the image, so the file will not appear stretched or squashed. Notice the word convert in the above line. This is the command that is a part of Imagemagick.  You can take the same main logic for this and make it work on Windows with PowerShell. PowerShell is a powerful shell that was first included with Windows XP and is available on Windows 7 as well as current versions of Windows Server.

For more on Imagemagick, check out the main Imagemagick project page.

Batch processing images from the command line can save loads of time and allow you to do something else while the images are resizing. Now if I could only figure out how to both resize and water mark in one script (but that’s another article…).

Partitioning Drives: I like the GUI

Some of the hard-core Linux guys will tell you to use the command line tools to do this. While I have done this using the fdisk program on Linux (and on Windows), I find graphical tools like Gparted on Linux and the standard graphical tools on Windows and Mac OS X to be much more convenient. First, it really helps to set up the drive when you can visualize it. Second, I find it difficult to get the partitions the exact size I want them with command line tools. Lastly, with Gparted I can partition and format in one fell swoop.

Now I know that not everyone has a need to do this kind of thing. Many probably won’t even need to consider it.  However, it’s something you will want to do especially if you decide that you want to try Linux but you don’t want to sacrifice the ability to run Windows software. This is especially true if you have something that relies on Windows drivers to function.  You can even download a Linux distribution called GParted Live that will let you use Gparted to partition your PC’s drive.  Just boot GParted Live, and then resize your drive as needed.

For more on drive partitioning, check out this PC World article.

Conclusion

The command line is not dead, not by a long shot.  It probably never will completely die off, thanks to some of the reasons above. So in what other cases should you investigate using the command line?  I say use it whenever you have to repeat the same thing over and over again. Why sit at your computer and do the same thing 500 times when you can run a script and make the computer do it for you?

To help you on your journey of learning to become a command line guru, you might want to pick up a reference on the command line, PowerShell or the BASH Shell depending on whether you are on Windows, Linux or Mac OS X. Learning a little bit of this will help you save time that can be better spent with friends and family.

Leave a Reply