Sunday, October 16, 2022

A command is worth a dozen mouse-clicks

Linux users should not fear the command line.  One simple command could save you dozens of mouse-clicks to do the same task. I know, the command line isn’t a great option when using a tablet, but you can’t do any real computer work on one of those, anyway.

commandline-title.jpg

In order to make people feel less intimidated, software developers have put in a lot of effort into making the modern day computer desktop as “intuitive” and “user friendly” as possible. This means, to get the computer to do what you want it to do, you don’t need to know what commands to give it. You just need to tap or click on the picture representation of that action and the computer does the rest.

This may make it easy for the “average Joe or Jane” to use a computer, but it’s not the most efficient way of doing things. These graphic user interfaces (aka GUIs) also add a level of complexity to the computer’s functionality, which also results in an increase demand in resources (like storage space and memory) that the computer needs to work. This is why every time Microsoft, Apple, and now many Linux operating systems comes out with a new release of their operating systems, you need to upgrade your PC. To me, this is a unnecessary waste of money and resources. I think all of these fancy interfaces just get in the way and greatly handicaps the user.

Much of this overhead could be avoided if people just weren’t so afraid of using the command line more often. I’ve also fallen prey to the convenience of the GUI, too. But, since deciding to move back to ALT Linux and Window Maker as my desktop, I’ve really been enjoying my command line “rehabilitation”. I’ve forgotten how much less effort it takes to use the command line, than to rely on a “modern” and “intuitive” desktop environment.

Let me give you just a few examples as to how easy using the command line can be.

One really good example relates directly to how I go about compiling a typical blog post. When ever possible, I like to include screenshots or images in my blog posts that relates to what I’m writing. I find that, not only do they help illustrate what I’m trying to communicate to my readers, but they also act as a nice break in the text; giving you a place to rest a bit before moving on.

To capture these screenshots, you could either use the GUI desktop and mouse to bring up the application menu, and then select the image editor software you wish to use. Once the program is running, you would then most likely click on the menu toolbar to choose the “screen capture” function, then activate it to capture the screen, the proceed to save and probably edit the image to your needs. Straight forward enough, but lots of mouse-pointer work and clicking around.

Now, this is how I take a screenshot of my desktop, save it to my hard drive and then launch Phototonic to make any necessary adjustments. It’s just one simple command:

scrot -c -d 5 -e phototonic

In actuality, I could even do without the -c -d 5 portion and just go with:

scrot -e phototonic 

What would have taken a couple of minutes fiddling with the mouse and the desktop interface, takes me just 15 seconds to type a few characters at the command line and press the ENTER key.

command-line-scrot.jpg
Command line screenshot

Another thing I like to do every now and again is to backup certain files I have on my computer to either a USB storage device or optical disc (aka DVD or CD). I could spend a lot of time, once again, navigating around the GUI desktop interface to start up my archiving application, then dragging and dropping files around to choose what I want to back up and where I want to store them. Or, once again, I can just type in a single line and let the computer do the work, saving me a lot of time. Like this:

tar -cvzf /media/usbstick/documents-backup.tgz /home/david/Documents 

This would back up the Documents folder and put it onto my USB stick. If I wanted to take that back up file and burn it to a DVD, I’d just follow up with:

growisofs -use-the-force-luke=tty -Z /dev/sr0 -J -r -speed=8 -dvd-compat -pad -graft-points 
/media/usbstick/documents-backup.tgz 

I know, understanding this sort of thing isn’t “intuitive”, you need to learn the commands. But, the powerful thing about it is, once you know these commands and use them a few times, you start to understand them and they soon become second nature.  However, even if typing such a long and obscure command really isn’t something you’d care to remember, Linux also has these things called “Aliases”. I’ll talk more about those in the next installment.

I don’t know how well know this fact is with today’s “average” Linux user, but just about every task or application used on the Linux desktop can be launched from the command line.  Even if you just use the command line to run your most commonly used applications, it can save you a lot of “mouse-work” and menu navigating on your GUI desktop.

If you use the command line enough, you may even discover that you don’t need to run a fancy and “heavy” desktop interface, leaving more computer resources to the applications, rather than the desktop environment.  This could, in fact, save you some money down the road by NOT having to upgrade your system the next time your Linux distro of choice adds more complexity to it’s interface and requires their users to upgrade their systems, once again.

I could go on and on about all the little different ways I’ve learned to simply bypass the complexity of the GUI desktop and just use the command line, but there’s just too much to include in one blog post. The point is, sometimes the convenience of a fancy desktop can make doing those (what should be) simple computing tasks a real chore. If you’re not afraid to learn a few commands, the command line can provide a much faster and less complex way of doing things.

Sometimes, a picture is worth a thousand words. But, when time is important and it takes an illustrator hours to draw what an author can write in two or three sentances, I say it’s more efficient to just go with the words.
[tag]linux, how-to[/tag]