Monday, December 27, 2010

Doing everyday tasks on a Linux CLI environment

In my last post, I detailed the horrific digital aftermath of what happened after I had tested out the Ubuntu Natty Alpha 1 release. In short, I was left with a system that refused to boot into a graphical environment at all and was forced to use the command line to do several tasks that would normally be done in a GUI. I was so surprised at how remarkably easy it was to do these tasks(web browsing, torrent downloading, CD burning) on the command line, I announced my intention of going completely GUI-less for two days.

While the "recovery console" session option found in the GDM login screen would be the closest replication of my X-less ordeal, I found that the xterm window it had was too small to show in snapshots. I decided to log into Gnome, but work solely within a maximized xterm window(alternatively you can use gnome-terminal and toggle full-screen with the F11 button). Here are the following applications I've used so far, grouped together according to general tasks:

File Management:

Midnight Commander
There's a few options when it comes to file management on the console. There are, of course, the built-in shell commands(cd, ls, touch, mkdir, rm,rmdir, etc.) ready to be used with just a few keystrokes. But if you want to navigate your filesystem in a more visual way, you can either use the built-in file navigator in the vim text editor(type ":e ." at the vim command line to activate it), or use the Midnight Commander(mc) file manager to do so. Midnight Commander is a two-paned file manager, allowing you to perform file management tasks in two places at once. It can perform file (de)compression, and includes its' own command line when you need to do precise actions on a selection.

Window Management:

Yes, the Linux command line can have a "window manager" of sorts. That window manager is called screen. It allows you to have multiple terminal sessions, similar to managing tabs in GUI terminal emulators. It's a necessity when you want to run several command line tasks at once and backgrounding will not suffice, or when have logged onto a server via SSH and wish to run something after you've exited the session. It should be available in virtually any major distribution's repositories.


While it's true the command line is non-graphical, it is certainly possible to do some multimedia tasks with no problems.

For sound recording, you can use arecord to record sound from your microphone, and then pipe the output to an encoder like so:

arecord -f cd -d numberofseconds -t raw | lame -x -r – out.mp3

arecord -f cd -d numberofseconds -t raw | oggenc – -r -o out.ogg

Music On Console
For listening to audio stored on your computer, there's several console-based music players(such as gst123, aplay and the awesome opencubicplayer), but I like Music-On-Console(moc), as it allows you to play music in the background while doing other tasks. It is invoked as "mocp" on the command line(to avoid clashing with the "meta object compiler" used when compiling Qt/KDE graphical applications). While playing music, press "q" to exit back to the command line, but all the music in mocp's current directory or playlist will continue to play. You can simply re-invoke mocp to get control again.

To rip audio from a CD, cdparanoia does the job well and the output can be sent to an audio encoder just like arecord.

You can also master and burn CDs/DVDs on the command line. As I mentioned in the last blog post, growisofs can be used to both create ISO images and burn them to disc.

You can also watch movies on the command line with mplayer by invoking it like this:

mplayer -vo caca movie.avi


Vim, editing a C header file
Yup, you can do some standard office tasks on the command line. For doing calculations, there's the bc command line calculator. And there's no dearth of command line text editors(nano, vim, emacs, etc.), but there's only two apps specifically geared towards word processing: antiword and wordgrinder.

Antiword allows you to view and convert MS Word files into plain text, PostScript or PDF files. An indispensable tool if working with Word files is unavoidable.

Wordgrinder word processor
Wordgrinder is perhaps the only thing on Linux that can be called a console-based word processor. While it writes in its' own native format, it can import from and export to plain text and HTML files. It supports basic styles and paragraphs, but don't expect anything fancy. Nevertheless, its' better than plain text or forcing yourself to do TeX formatting.

SC spreadsheet calculator
For spreadsheet processing, sc fits the bill perfectly(especially if you like vi/vim). Combined with wordgrinder and abook(console address book), you pretty much have a console office suite at this point.


While Web browsing has evolved into a very multimedia affair(Flash, Youtube, Facebook/Twitter, etc.), there's a surprising amount of things you can do on the Internet without a GUI.

ELinks web browser, viewing
For console web browsing, Ubuntu ships w3m by default. While w3m is okay for viewing individual pages, that's all it's really good for. It's basically like the "less" command for web pages. For a truly decent console web browser, elinks is the way to go. It has bookmarks, download management, color support, CSS support and yet it cuts through all the useless crap(Flash, ads and popups) to get you the content you really want.

For non-interactive web interaction, wget and curl are excellent tools. You can also download torrents with the rtorrent console client(mentioned in the previous blog post and highly recommended).

For email, there's several console email clients to use. There's pine/alpine, the traditional mail command, and mutt. If you're used to using the nano text editor, alpine is the easiest option. Mutt is way more powerful, but requires a bit of configuration to get it working specifically how you want it to.

Irssi, chatting with the Kokua/Imprudence devs
For instant messaging, you can use Finch, the console version of the Pidgin instant messenger. And I've found irssi to be a very capable console IRC chat application.


GoogleCL manpage
Yes, believe it or not, Google has a command line interface for some of its' services(Blogger, Youtube, Picasa, Docs, etc.). And because of that, it gets it's own section. On Ubuntu, you can install the "googlecl" package directly via apt-get. If your distribution's package manager doesn't have it available, you could download the tarball and compile it yourself.


Montage of previous screenshots
You would think that in a command-line only environment, there's not much you can do with graphics. But strangely enough, that's not the case with the ImageMagick suite of command line tools. With ImageMagick, you could create and manipulate pictures in ways that was once the sole domain of GUI image editors like GIMP. The above picture is a montage of all the other pictures I took while creating this blog post, made possible by the montage tool of the ImageMagick suite. You can make composites, animated GIFs, apply various effects, and a whole lot of other things.


Yes, there's some terminal-based gaming options for Linux. You can connect to various text-based MUD(multi-user dungeon) games on the Internet via the telnet command. A good place to start with MUD games is The Mud Connector. If text-only isn't your thing and require something marginally more graphical, the surprisingly challenging nethack game may be right up your alley. If you've got a bunch of old DOS games lying around, you can use dosbox to play them.

Missed stuff:

I'm pretty sure I've missed a few things, so feel free to let me know in the comments.

How Facebook Can Stop Zucc-ing Itself

Earlier today, Facebook and it's users suffered an hours-long outage in which a recently pushed update caused a DNS misconfiguration. As...