The Power of Linux Console

Sunday, 18 February 2007, michuk

A console (terminal, terminal emulation) and a shell are equivalent to what is commonly known in Windows as the ‘command line’. For many it’s just a mysterious and unnecessary system tool, reserved only for the ‘1337′. For people like professional system administrators it’s indispensable. The Linux console, in contrast with the Windows command shell, is an extremely powerful user tool, which allows to perform virtually any operation on the system.

Author: Borys Musielak

The combined power of the console and the shell (i.e. Bash) enables us to perform thousands of tasks; here are a few examples:


apt-get install mp3blaster

Pic 1. Software installation requires
no more then just one command.




Alsamixer - system sound mixer

Pic 2. Alsamixer - useful for
system sound settings changes.

  • detailed and extensive system-wide configuration and administration,
  • software installation, updates, and removal,
  • file and folder administration and manipulation (using i.e. Midnight Commander),
  • sharing, accessing, and transferring data between machines using SSH, NFS, or Samba,
  • managing personal email (mutt, pine), web browsing (lynx, elinks), reading discussion groups (slrn),
  • listening to music (mpd/mpc, mp3blaster, xmms-shell),
  • burning CD’s (cdrecord, cdrdao) and DVD’s (growiofs),
  • chatting via IRC or via many popular instant messaging networks like Jabber, ICQ, etc!
  • extensive system monitoring and troubleshooting (top, netstat, io, iptraf),

What differentiates a Linux console from a Windows command line?

Simply said: its architecture and abilities.
Let’s dig a little deeper… First of all, in Linux the shell is a completely system independent entity, it is not an integral part of the operating system. Thanks to this simple architecture we can use several shells for all kinds of different purposes. Note especially that we can launch a large number of consoles for different tasks, using different shells if it’s necessary. It’s the shell that controls the functionality of such events as command history and command line completion, but also any kind of conditional statements, loops, and all other programming concepts used in shell scripting. The most popular shells include: bash, zsh, and ksh.

The terminal emulator on the other hand is a program (usually with graphical user interface, including menus, etc) which helps us to effectively use the console. The most commonly used emulators are: gnome-terminal, konsole, xterm, aterm, Eterm and multi-gnome-terminal. Most of them are simply called “console’ or ‘terminal’ in the system menu. The terminal emulator is responsible for extra stuff like transparency, having multiple terminals in tabs, key shortcuts, etc.

The real terminal and the emulator

In many Linux distribution (especially those dedicated for servers) the default user interface is pure terminal. The graphical interface (X Window System) is optional and can be run independently. In such cases, we have the access to terminal just after logging in so we don’t have to use an emulator run from the GUI. In most cases however (all desktop-oriented Linux systems), the default setting is to use the graphical user interface. In these systems we can also switch to the real terminal using a key shortcut CTRL+ALT+F1 to F6).

This architecture, which does not require a graphical interface to work with the system, is a great advantage of GNU/Linux and other UNIX-like systems. Few remember that a similar division was in place in old versions of Microsoft systems as well. MS Windows, up to version 3.11 could not be run independently and required DOS (”a terminal”) to normally function. In Windows 95 this method was abandoned. The graphical interface is always running, eating up valuable resources for server systems. Being condemned to using graphical interface is also an important restriction in case of system crashes. For instance, in case of problems with a graphics card driver, when Windows does not want to run, we have almost no way to easily correct the error (e.g. by removing the driver and replacing it with a working one). If the plug & play magic fails, we have no option but to call tech support or reinstall the system.

Why use the console if there is GUI?

Indeed… Why the heck should you use the console (except for sorting out system crashes)? Isn’t it way easier and faster to click through things? Linux was supposed to be as easy as Windows you said! And now you come up with this geeky stuff…

Take it easy. Nobody says you have to use the console. You can configure your system and perform all the standard operations in the GUI mode. But.. I’m not sure you really want to. Using the GUI is easy but remember two things: the console is faster and it is more efficient.

Don’t believe me? I’ve got examples:

  • Let’s delete a file. For instance, the file test.txt located in our home folder
    • In a terminal: rm ~/test.txt (the file name is auto-completed when you enter TAB)
    • In GUI: Double-click the “Home” icon on the Desktop. Then find the proper file, select it and use the right mouse button to choose ‘Delete’.
  • Let’s do some configuration now. For instance, let’s configure the Internet access via DHCP
    • In a terminal: sudo dhclient eth0 (and enter your password)
    • In a GUI: Click on the icon representing the Network on the desktop toolbar. A network configuration applet shows up. Choose a network card represented by eth0, and click Activate. If it does not work, then enter the specific configuration for this card, enter the root password, set the DHCP option (probably static IP has been set before), click OK, and again click Activate on the network card. Finally, we can leave the applet.
  • Let’s do some admin stuff now and start the Apache2 web server!
    • In terminal: sudo /etc/init.d/apache2 start (and enter your password)
    • In GUI: Choose System-%lt;Administration-%lt;Services from the GNOME menu. Then look for Apache2 server and select it. Click ‘Apply’ and close the applet.
  • OK, the last example is the least geeky one. Let’s watch a movie in MPlayer!
    • In terminal: mplayer /home/movies/Aviator/AviatorCD1.avi (of course using the TAB completion option for file names!)
    • In GUI: In GNOME menu choose Applications-<Sound & Video-<MPlayer Movie Player. When the program shows up, choose ‘Open’ and navigate to folder /home/movies/Aviator. Then click the first part (AviatorCD1.avi). Alternatively, navigate in your file manager (like Nautilus) to the right folder and then double click the movie file (or, if MPlayer is not your default movie player, select ‘Open With’ and select MPlayer from the list).

konsola w akcji
Pic 3. Console tools in action: mp3blaster, Midnight
Commander, gcc, FvwmConsole and top

These are only four examples. In each one, performing the exact same task was a couple times faster in terminal than in GUI. Of course it’s not always the case. Burning a DVD in console is for hardcore hackers only, since the growisofs program requires many parameters and typing them all manually is harder than choosing ‘Burn as DVD’ in a program like K3B or GnomeBaker. In general however, if we care for efficiency in our work, it is a very good idea to make friends with the terminal. It will take time to get to know the basics, but for a Windows power user like you, the learning curve should not be long and the benefits are faster and more efficient work.

What is worth mentioning, after many years of ignorance, the Microsoft guys finally realized that an efficient console is good for them as well. They have been working for couple years on the new Windows shell called MONAD or msh, designed to make the system’s administration work easier.
The new shell, now called Windows PowerShell was supposed to be available in Vista, but the schedule has changed and it is not part of this release. So, basically if you are a Windows user you are still left with Cygwin, a UNIX shell emulator for Windows, with all the drawbacks of this solution.

Subscribe to RSS feed for this article!

17 Comments

fold this thread Penguin Pete  Monday, 12 March 2007 o godz. 8:28 pm #  Add karma Subtract karma  --1

Great write-up! But just to point out - Windows Power Shell is still available for separate purchase at around $100 (last I checked).

The part that I will NEVER forgive the desktop feng-shui consultants for is the slam-bashing, flaming hell we’ve all had to go through for 20 years because of Linux having a command line, and then Microsoft regrets stripping DOS away and brings up WPS - oh, now all of a sudden command lines are the best thing since sliced bread.

Seen Don Norman lately? He’s cooing like a dove over command lines now, as long as Windows has them.

Incidentally, grab the manual for WPS while you’re there. Read it if you dare. Personally, I’m printing my copy out, just so I can cram it down the throat of the next idiot who complains that Linux commands are unintuitive.

 
fold this thread Karl O. Pinc  Monday, 12 March 2007 o godz. 11:27 pm #  Add karma Subtract karma  +0

The real reason to use the command line is not because it’s faster and more efficient, although it is. The real reason is because the command line is more _stable_. The command lines that worked in 1972 still work today. The GUI changes constantly. Microsoft Windows is a case in point, the GUI changes with every release.

If you stick with the command line you’ll be investing in the future.

 
fold this thread Shelton  Tuesday, 13 March 2007 o godz. 7:23 am #  Add karma Subtract karma  +0

Hey you too - nice comments - very thoughtful - thanks

 
fold this thread frank  Tuesday, 13 March 2007 o godz. 3:14 pm #  Add karma Subtract karma  +0

“Burning a DVD in console is for hardcore hackers only, since the growisofs program requires many parameters and typing them all manually is harder than choosing ‘Burn as DVD’ in a program like K3B or GnomeBaker.”

well, this only works because of somebody has hardwired the parameters in, for example, k3b.
you could write them into a script (or let somebody else do this for you) and call the script from the commandline with ease.

btw, this brings us to the next advantage : it’s scriptable.
for example, you could download a script which does a full set up for an application or downloads and installs stuff with just one command.
or, my favourite example: edit bucketloads of images with just one command, resize them, convert them, you name it.

its all just a matter of a few keystrokes.

 
fold this thread Spanky  Tuesday, 13 March 2007 o godz. 4:57 pm #  Add karma Subtract karma  +0

Great article!

Just because we recognize the power of the command line, that does not indicate we are against an easy point and click GUI. Nor do we need to see new users using anything but what they wish.

Sadly, Microsoft is playing catch up in so many ways and most people don’t see it. If you are a good friend, tell them.

 
fold this thread Mohammad Bahathir Hashim  Wednesday, 14 March 2007 o godz. 4:21 am #  Add karma Subtract karma  +1

With GNU screen, you can enhance console experience into the next level. As you can see in the screenshot, I opened 4 network related applications (iftop, elinks, centericq, irssi) in only one rxvt terminal. I used screen’s capability to split terminals, and I can ’see’ all 4 apps at the same time. Cool isn’t it ? :).

http://img.photobucket.com/albums/v246/bakhtiar/screen.png

 
fold this thread Shlomil  Wednesday, 14 March 2007 o godz. 1:35 pm #  Add karma Subtract karma  +0

I noticed that you use ‘top’ in your screenshot.
‘htop’ is nicer.

http://htop.sourceforge.net/

 
fold this thread Marcus Gravy  Thursday, 15 March 2007 o godz. 4:02 pm #  Add karma Subtract karma  +0

The *real* reason for using a terminal/console/command line interface is this: It has a grammar.

It is a fact, disputable only by the ignorant, that you can express more with a grammar than without. Look up Chomsky language hierarchy for confirmation.

Command lines have looping and if/then/else decisions, and sequencing. They constitute a language. GUIs have none of these. They consitute flash cards, or at best, rebuses.

 
fold this thread Lars Bjerregaard  Friday, 23 March 2007 o godz. 11:57 am #  Add karma Subtract karma  +0

I would add another *huge* benefit of using the command line + a good shell: scripting!

With a few lines of good scripting, you can accomplish amazingly complex things, in an automated fashion, plus you can make repetitive complex tasks simple and quick.

Scripting is king..

 
fold this thread What is Linux?  Saturday, 24 March 2007 o godz. 8:54 pm #  Add karma Subtract karma  +0

Like Karl said, the command line is stable. Although as a sometimes-Windows user I find Vista nice, people used to XP don’t like the change. People want to be familiar with one interface and use it. The command line hasn’t changed in over 20 years.

 
fold this thread EpsDel  Friday, 4 May 2007 o godz. 1:18 pm #  Add karma Subtract karma  +1

Try obtaining the effect of dpkg –configure -a using clicks after your adept manager has failed configuring some packages and won’t work ’till you fix them.
:)

fold this thread euchrid  Thursday, 29 November 2007 o godz. 3:42 am #  Add karma Subtract karma  +0

I’m a novelist too, and I’ve found Linux far superior to Windows, even on the GUI front. I set up Ubuntu easily, and no longer need to use the command line - but after a year of using Linux, I now prefer it. The latest Ubuntu and Knoppix detect a lot of different hardware. Even if they don’t, once it’s set up, what do you have to do? Unless you enjoy playing around with your system, there’s no real need to have to change stuff again for years… by which time Linux may well have caught up with the latest hardware anyway.

I’ve moved on to ‘geek’ tools like Lyx and Scribus and Treeline to write with; all these things take time to learn, but in a year, I have found that the learning has paid off. I get more done now because I’ve learnt to work more efficiently, and not let the GUI slow me down or get in the way. It is a steep learning curve, but it pays off by saving you time in the long run and enabling you to work with any system.

The console seems kind of depressing at first go, because, as a new user you feel hopelessly lost, but I guess that’s how an aircraft pilot feels the first time they step into a cockpit as a learner. It depends if you need to fly a plane or drive a car (and I don’t mean that patronisingly). One is familiar, but you get stuck in jams; the other is complicated and intimidating, but once learnt, you can fly, man, fly!

fold this thread euchrid  Thursday, 29 November 2007 o godz. 3:43 am #  Add karma Subtract karma  --1

Damn. I hit the wrong ‘reply to’ button. Meant for the next comment down. Sorry!

(Comments wont nest below this level)
 
 
 
fold this thread Dr Funfrock  Monday, 19 November 2007 o godz. 1:08 pm #  Add karma Subtract karma  +0

Well this is great and all, but I have to say that so far my experience of Linux continues to be one of fumbling around in the dark because I’ve been forced to learn to use an ancient technology instead of just being able to go with a GUI. Yes, GUIs are not necesarily faster, that’s fair, and a good argument, but they are very often more intuitive. This isn’t an argument for Windows, btw, as I’m aware that their GUI is often slow and confusing. It’s more a serious gripe I have with most Linux distros, which is that the GUI is often either underdeveloped or lacking entirely. Take a look at that screenshot above, of the ALSA sound mixer. It’s a just a GUI that’s been put together in a console, and we’re being told this is somehow better?
I’m not a tech nerd, I’m a novelist. Now I’m sick and tired of Windows as a productivity platform, and I’d really like to buy into this whole “Linux is a better office OS” idea, but it’s just not working. I’m being told Linux is more stable, but it crashes all the time on my machine, whilst Windows XP doesn’t even show a blip. I’m being told Linux is faster, but I get nowhere because instead of just learning a user interface I’m having to learn an entire language. It would be nice if I could hear a fix to a problem that didn’t just consist of a line of text to type into a terminal (followed by six other people replying with different versions of the fix). It would be nice if I actually could set up my system entirely using graphical interfaces, but I can’t. Sooner or later I end having to edit config files or something like that. Hell, it would be nice if I could move a file to a restricted folder and just type my password into a dialogue box, instead of having to SUDO the entire job. Yes, I’m lazy. I’m not here because I believe in this grand and glorious future where everyone is a tech-geek, I’m here because I’d like an OS that works, and all I’m being offered is Windows, which treats me like an idiot, or Linux, which expects me to have a doctorate in comp sci just to use it.

fold this thread trojjer  Tuesday, 20 November 2007 o godz. 11:55 pm #  Add karma Subtract karma  +0

It’s getting better these days, although I have experienced a few similar problems — namely due to trying to install Sun Java and Adobe Flash, etc, that aren’t yet in the Ubuntu repository (please hurry up with OpenJDK/IcedTea! Then again, I’m learning Java a little bit at a time, but I’m still not convinced that it’s such a great platform…). And it would be nice if there was an option to install proprietary codecs with the OS by prompting the user, just to let them know that they’re not always provided by default in Linux distros because of crazy patent/copyright/”IP” legislation that says that it’s somehow illegal for people who have LEGALLY OBTAINED a DVD for to actually watch it on an operating system of their choice. But that’s the DMCA, which represents yet another tangent. My experience of VLC has been pretty good so far, but I mainly use it on Windows. But I accept that, when new codecs are needed on Ubuntu, it’s usually pretty easy to install them from the Universe repo or whatever. Such is the case with win32codecs, apparently. But that probably doesn’t support mangled/encrypted WMA or Real much, if at all. Which is yet another shame, as some websites insist on spouting those horrible files.

My OS-agnostic friend keeps switching back and forth in his appraisal of Ubuntu, Vista and Mac OSX, but he seems quite settled on Vista at the moment, funnily enough. He says that it’s “just easier” to get things like the Windows Media Center to work, and he’s “tried lots of the Linux MCEs to no avail”. I need to give LinuxMCE a shot though; the video I’ve seen on Youtube makes it look like a contender, it’s just a shame about the occasional codec problems and closed-source hardware drivers (he couldn’t get his two monitors to work because nVidia didn’t seem to provide software to handle dual head graphics cards properly).

 
fold this thread Madman  Tuesday, 10 June 2008 o godz. 8:00 pm #  Add karma Subtract karma  --1

You’ve never used the man command, have you?
man apt-get
man sudo
man vlc

etc.
Also, you don’t absolutely HAVE to use the command line (sorry, terminal). When the experts want to help, though, it’s easier to copy-past a command into the terminal then tell the user exactly what to click, which menus to search under etc.

 
 
fold this thread Joel Bennett  Tuesday, 20 May 2008 o godz. 5:01 am #  Add karma Subtract karma  error

Just to be clear … the troll who commented first was just pulling your leg when he said PowerShell costs money and has obscure syntax.

It is and has always been free. It’s now available as an “update” install for Windows XP, Windows Server 2003, and Windows Vista, and it’s built-in from Windows Server 2008 on. It also has a simple, predictable syntax, with rules for how commands are named which I think results in a significantly easier to learn shell … Of couse, if PowerShell isn’t your cup of tea, the Windows Services For Unix (which is also free for download) includes korn and C shell, and the usual utilities and scripting capabilities, and Bash etc are available from Cygwin.

Everything you mention as pluses for the command-line in Linux applies to the command-line in Windows (particularly with PowerShell) … except that *until PowerShell* it was difficult to get a better terminal. Now, of course, you should check out PowerShell Plus or Posh Console — just check out their screenshots…

 
Name (required)
E-mail (required - never shown publicly)
URI

Adjust field size: shrink | enlarge)

You can use simple HTML in your comments. Some examples are as follows:
  • A hyperlink: <a href="polishlinux.org">GNU/Linux for everyone!</a>,
  • Strong text: <strong>Strong text</strong>,
  • Italic text: <em>italic text</em>,
  • Strike: <strike>strike</strike>,
  • Code: <code>printf("hello world");</code>,
  • Block quote: <blockquote>Block quote</blockquote>