This page is powered by Blogger. Isn't yours? tech

qptech blog

The companion to qpmarl blog. Here you will find all technical related posts (mostly computer and linux stuff)

Sunday, September 17, 2006

 

The Virtues of the Command Prompt

I've always been a fan of the command prompt - even before I got into linux and knew nothing what so ever about *nix or the Bourne Again Shell. (I'm not going to bother creating links for any of this stuff - you know how to use google)

Maybe it's because I was introduced to computers back when MS-DOS was still king of the PC and Windows was just his court jester or something (sorry - the analogy is failing me here). I dabbled with batch file "programming" (if you can call it that), but the documentation that was included at that time didn't get into very advanced topics. The internet wasn't available to me then, but I learned a little from reading the install scripts that came with various games (I was like "Wow, I didn't know you could do that in a batch file" (the term "script" was foreign to me at the time))

Now-a-days the MS command prompt is pretty much useless. I suppose that professional System Administrators might use it now and then for some administration task. When I was still a MS drone I'd use it occasionally to launch some program or diagnose some network issue or something - but scripting or doing any real work was really not possible - I've heard that MS is creating a new command line interface for Vista that's supposed to be more like unix without actually being unix - it sounds pretty craptacular. (If MS wants an operating system that is unix, they should just make their own flavor (it wouldn't be that hard, they'd just have to buy out some company that already develops some proprietary flavor) and stop half-ass copying ideas from real unices)

Now I use linux (I'm currently running gentoo on both of my computers - and I've been thinking of setting up some old junk with it too). I quickly warmed up to the *nix command line environment and I prefer it over whatever gui tools might be available. And I just realized one of the reasons for this - I pretty much thought that it was just my nerdish nature, but a few practical benefits have been discovered.

Scripting is awesome - you can write pretty elaborate applications in nothing more than bash scripts - I guess that it's sometimes used to prototype C applications.

But even without scripting, I'd still use the command prompt a lot - My preferred text editor is nano inside a terminal emulator - the only disadvantage to this is that you can't paste things from the window manager's clipboard. And I do all my system maintenance from the command line.

This (System Maintenance) is how it occurred to me that the command line is superior. There are gui tools available for portage (the gentoo system management system), but I doubt they'd be as flexible as the command line tools.

Say you want to perform some routine system maintenance - update all the packages on the system and install some new ones. In gentoo you have to run emerge --sync to update the portage snapshot and emerge -u world to update all packages currently installed on the system then emerge <1st> [<2nd>] - all of these steps take a while to perform and usually involve downloading a bunch of stuff from the internet. The portage system is one reason that I like gentoo. So with the gui tools - I'd have to open the portage gui, start the sync and when that's done start the update and when that's done start the other packages. So sure, you don't have to remember any complicated text commands, but you have to wait for each step to complete to start the next.

On the command line, I just use the following single command to do it all
emerge --sync && emerge -u world && emerge somepackage
those &&'s tell bash to wait for the previous command to complete successfully before executing the next - if one command fails, then the whole chain will terminate and you'll have to find out what went wrong - which will be pretty easy since the output of the failed command along with some hopefully useful error messages will be right there on the terminal above the awaiting command promp.

As far as remembering all those complicated commands - well, they're really not all that complicated and the names are usually pretty intuitive. I don't find it any harder to remember commands than to remember where to find some windows system setting buried in the control panel or some other place. When using windows, I usually find it easier to hit Win+R to get the run dialog and type the command corresponding to the program I want to run (calc or notepad). It's faster and easier than digging through 3 or 4 layers of the start menu to find the stinking shortcut - that is assuming that I don't have a desktop or quick launch icon setup for it - which few people do for calc or notepad (or cmd).

Labels: , , ,


Comments: Post a Comment

<< Home