Cooking with Linux - Tricked-Out Terminals
Please, François, do not cry. What is making you so sad? The restaurant looks fantastic, mon ami. Everything is ready. What could possibly be so bad? Quoi? You were reading the menu and saw that we would be featuring terminal programs and that made you sad? Ah, Mon Dieu François, terminal programs have nothing to do with death; they are windows to the shell, much like the GNOME terminal, xterm or the KDE Konsole.
Our guests are arriving, François. Welcome, everyone, to Chez Marcel, where fine Linux fare meets fine wine. Please sit and make yourselves comfortable. François, please go to the wine cellar and bring back the 1999 Côte du Rhône. Vite!
While putting together the menu for this Systems Administration-themed issue, I was somewhat torn. There are, after all, so many different aspects to this topic. Then, I asked myself what systems administration tool I use most and came up with an interesting answer—it's a command shell run inside some kind of terminal emulator. Although this may seem extremely basic, the terminal program has come a long way since the days of the venerable xterm.
For those of you too young to remember, we call them terminal programs or emulators as opposed to shell windows, because they were software desktop equivalents of the terminals that at one time were connected physically to the mainframe system. But I digress, and François has returned with the wine.
I've used quite a number of terminal programs over the years. Originally, it was a plain xterm, still available on most Linux systems. Dressing it up meant changing the font color or background but not much else. For instance, to start a plain xterm with a steel blue background and red text, I would do the following:
xterm -background "SteelBlue" -foreground "Red"
In time, I discovered another terminal program called rxvt that also should be included on most systems. It gave me a little more control over configuration options. It not only looked better than my old xterm, but I could assign an XPM bitmap image for a background, which made it look pretty cool at the time:
rxvt -pixmap /usr/share/themes/BrushedMetal/gtk/bg.xpm -fg black
Then came the first terminal emulator I really fell in love with, one I still enjoy today. It's called Eterm, and although it was designed as an xterm replacement for the Enlightenment window manager, it should work with whatever you have, be it GNOME, XFCE, KDE or anything else. Check your distribution CDs for this one, as it may not be installed already on your system. You also can get the latest Eterm from the Eterm Web site (see the on-line Resources).
Besides looking great, Eterm offers some cool features. For example, Eterm can have a variety of background images, and in fact, it comes with several. Some of these are tiled pixmaps, and others are full background images (Figure 1). Simply click Background on the Eterm menu bar, then Pixmap and select from the tiled or scaled pixmaps available.
You also can change the font size, brightness, contrast, scrollbar style and much more. You even can create and customize your own menu. If you are happy with the settings you have modified, click Eterm on the menu bar and select Save User Settings.
Eterm is themeable as well. Click the Themes link on the Eterm Web site, and you will see several themes that can be downloaded and installed on your system. These all are tarred and gzipped bundles. To install them, create a .Eterm directory in your $HOME directory and then create a themes directory below that. All you have to do now is extract the theme into that directory and it becomes available. To start your next Eterm with the appropriate theme, name it on the command line like this:
Eterm -t theme_name
One of my favorite features of Eterm, however, is the ability to make it transparent. I find this particularly nice because it lets me keep an eye on system logs as they scroll across my desktop and my current favorite wallpaper. All you have to do is click Background on the menu bar and select Toggle Transparency. This option doesn't work on KDE, but it does work on GNOME, WindowMaker and others. To view the Apache logs on my Web server on my transparent Eterm, I would run the following command:
Eterm -O -e sudo tail -f /var/log/httpd/access_log
This doesn't have anything to do with terminal emulators per se, but in the above example, you may need to add yourself to the /etc/sudoers file in order for this to work, unless, of course, you run the Eterm as root. In my case, I added a line in the file right below the definitions for root's privileges:
# User privilege specification root ALL=(ALL) ALL marcel ALL=(ALL) ALL
These days, there's another feature in terminal programs that has me excited, and that's tabs. There is no need to open three or four terminal applications, which can take up a fair amount of real estate. Take a look at the KDE Konsole program, for instance, or the GNOME terminal. Both provide not only basic shell access, but they also allow you to run multiple shells in tabbed sessions. To use tabs on your GNOME terminal, press Shift-Ctrl-T and you are presented with a new session (Figure 2).
The GNOME terminal also supports transparency, so if I want to start up a script that lets my logs scroll across my wallpaper du jour, I can do that as well. With the GNOME terminal, this is done with profiles. To create a profile, click Edit on the GNOME terminal menu bar and select Profiles. Click New and give your profile a name, for example, seethrough. When the Editing Profile dialog appears, click on the Effects tab and click the Transparent background radio button (Figure 3).
Use the slider to adjust the level of transparency and then close the profile dialog. Now, start the GNOME terminal like this:
gnome-terminal --window-with-profile=seethrough \ -e "sudo tail -f /var/log/messages"
If you like the results, use that command in a shell script in order to call it by a name that makes sense to you.
In the KDE world, there's Konsole, which also handles tabs nicely. To start a tabbed Konsole session, click Session on the menu bar and select New Shell. Then, customize the tabs by double-clicking on them and giving them a name. When you are running multiple shells—a compile here, a monitor session there and a root shell in yet another tab—naming your tabs makes a lot of sense. Also notice that when you click the Session menu, several options are available, including starting a session in a bookmarked location (Figure 4).
Bookmarks? As you do your job as administrator, you find yourself going to the same directories over and over again. Sure, you can type quickly and get where you want to go, but Konsole extends its capabilities by letting you assign bookmarks. When you are in that familiar directory seven levels deep, simply click Bookmarks on the menu bar and then select Add Bookmark. You can assign a name to the location you want, and open a shell in that location with a single click.
And, of course, I can't move on without mentioning transparency. To enable transparency in Konsole, click Settings on the menu bar, then Schema and select one of the Konsole transparencies from there. While you are in the Settings menu, you see a ton of configuration options for the Konsole terminal program. Change the font, go to full-screen mode and change the encoding, change the keyboard layout or set an alarm to inform you when changes take place in one of your tabbed sessions. You can explore the Konsole features on your own, but I will leave you with a nice script to start a clean, transparent Konsole to track your log file:
konsole --schema Transparent.schema --nomenubar \ --notabbar --noframe \ -e sudo tail -f /var/log/messages
The final selection on tonight's menu is something so great, I'm frankly amazed I hadn't seen anything like it before. I decided it was great, because I started using it regularly as soon as I discovered it. Using KDE kparts, Simon Perreault created a program called Quadkonsole. As the name implies, it starts up four Konsole programs in a grid (Figure 5). There's no need to line up your Konsoles side by side or click from one shell tab to the next. To make things even nicer, the Quadkonsole creates only one task in the task bar, leaving your Kicker panel uncluttered. That feature is going to be particularly useful as I tell you more about this great terminal program.
Each running Konsole can be modified at will by right-clicking on it, choosing Settings and then selecting the changes you are interested in making from the menu. For instance, you may want one to be transparent, another white on black with smaller fonts and so on. After all, each one is a Konsole and can be modified accordingly.
If you are feeling particularly distracted, you can tell Quadkonsole to start with more than four Konsoles. Simply specify the number of rows and columns, as follows:
quadkonsole --rows 4 --columns 4
This command starts up Quadkonsole with 16 individual terminal sessions (Figure 6). That's why having only one instance in your Kicker panel is such a nice feature. This also might be a good time to start playing with the font size if you want the information to fit. In one of my sessions, I have top, the real-time process and resource monitor, running with a super-tiny font. Of course, now I need to run a desktop magnifier such as kmag in order to see it.
By default, the focus follows the mouse pointer, so if you happen to nudge the mouse accidentally while typing, strange and wonderful things may occur. To override that default, use the --clickfocus command option to start your Quadkonsole program. After doing so, you have to click in each window in order to select a particular Konsole.
I happen to prefer the click-to-focus option, but I don't always like having to reach for the mouse each time. Luckily, Quadkonsole has that covered as well. You can navigate from one Konsole instance to another by using the Shift-Ctrl-arrow key combination. This allows you to move up, down, left or right from one session to another.
Incroyable! It would seem, mes amis, that closing time has once again arrived. If only someone would write an application that could transform our one instance of leisure time into four or 16. Too much wonderful wine to savor, too many programs to explore and certainly not enough time. Do not worry, mes amis, I am more than willing to spend a little more time, and François would be happy to refill your glasses while you chat. Sit back and enjoy that Côte du Rhône. Raise your glasses, mes amis, and let us all drink to one another's health. A votre santsanté Bon appétit!
Resources for this article: /article/8259.
Marcel Gagné is an award-winning writer living in Mississauga, Ontario. He is the author of Moving to the Linux Business Desktop (ISBN 0-131-42192-1), his third book from Addison Wesley. He also makes regular television appearances as Call for Help's Linux guy. Marcel also is a pilot, was a Top-40 disc jockey, writes science fiction and fantasy and folds a mean Origami T-Rex. He can be reached by e-mail at email@example.com. You can discover a lot of other things (including great Wine links) from his Web site at www.marcelgagne.com.
|diff -u: What's New in Kernel Development||Sep 04, 2015|
|Android Candy: Copay—the Next-Generation Bitcoin Wallet||Sep 03, 2015|
|The True Internet of Things||Sep 02, 2015|
|September 2015 Issue of Linux Journal: HOW-TOs||Sep 01, 2015|
|September 2015 Video Preview||Sep 01, 2015|
|Using tshark to Watch and Inspect Network Traffic||Aug 31, 2015|
- diff -u: What's New in Kernel Development
- Using tshark to Watch and Inspect Network Traffic
- Problems with Ubuntu's Software Center and How Canonical Plans to Fix Them
- The True Internet of Things
- Android Candy: Copay—the Next-Generation Bitcoin Wallet
- September 2015 Issue of Linux Journal: HOW-TOs
- Firefox Security Exploit Targets Linux Users and Web Developers
- Concerning Containers' Connections: on Docker Networking
- Where's That Pesky Hidden Word?
- A Project to Guarantee Better Security for Open-Source Projects