Open Source

The Linux desktop invasion: Terminal tricks

If you think the Linux command line is a boring, old-school method of computing, just wait until you see what Jack Wallen, Jr., has in store for you. Take a look at these tips on making your terminals hip, fresh, and useful.

Like a Chevelle Super Sport, the Linux terminal window can be tricked out far beyond the standard nondescript window. Much of this “tricking” is done with various terminal emulators, and some of the newer emulators can be fine-tuned in such a way that you’ll actually want to work with the command line.

In this Daily Feature, I am going to show you how to configure your Linux terminal windows so that you can impress your friends, raise your geek standard, and (most of all) enjoy the Linux command line.

Begin at the beguine
First let me demystify exactly what the console, the command prompt, and the terminal emulators are. It’s a pretty simple task but one that warrants attention. Once I’ve made these definitions clear, I will then dive into the command prompt and help you to configure the prompt to meet your needs.

The Linux console, at its most basic, is a working command prompt without a graphical environment. If you have your Linux machine configured to runlevel 3, the machine will boot to a console login as opposed to a graphical login. The console doesn’t offer a graphical environment, only the command line.

Terminal emulators, such as aterm, Eterm, Gnome-terminal, konsole, and rxvt, take the console and encapsulate it into a single window within a graphical environment. Working with terminal emulators allows you to work within multiple consoles. (You can do this at the console with virtual consoles by hitting [Ctrl][Alt]Fx, where Fx is one of the function keys, but this is not quite as user-friendly as using the terminal emulator.)

The command prompt is used within both console and terminal emulators. The command prompt is, quite simply, where you type your commands—and now is your chance to liven it up a little.

Check out that prompt
The Linux bash prompt is a highly customizable tool that can not only prove you are the alpha geek but can also make some of your work a little easier.

Figure A gives you a bit of an idea where this customization is heading.

Figure A
Using color in the bash prompt will impress your friends and help you keep your ducks in a row.

In Figure A, you can see a Gnome terminal showing a customized bash prompt. In this example, I am using two colors as well as specific text (instead of the old username@host prompt). How is this done, you ask? Well, let's take a look.

The basics
To learn the basics of configuring your command prompt, check out my article ”You're not just a number: Customizing your bash prompt.” In it, you will learn how to use color effectively, as well as how to alter your prompts so they are more useful for individual systems.

One configuration I didn’t cover in that article is using the color red (31m) for a root prompt. I've often had users come up to a station without knowing they were about to work with a root prompt and then issue the wrong command (as root), which would bring the system to a screeching halt. The users always pleaded ignorance ("But I didn't know the $ sign meant it was the administrator!"). To avoid this confusion in the future, I often change my root prompt color to red. With this change in effect, users seeing red will know not to mess with that prompt (unless they are of a deviant nature). To make this prompt, you will add this line to root's .bashrc file, which will result in a prompt akin to Figure B.

Figure B
Red means stop! And you should alert your end users to this fact.

The sections in bold (within the PS1= line) are what you will want to pay attention to. As you can probably discern, 31m designates the color red, ROOT will give the users further warning, 31m again changes the color back to red, and --> (in red) is one final indication that they might be messing around with something they shouldn't.

Of course, this whole scheme could easily backfire on you. Alerting the entire company that, "Hey you! Here's my root prompt!" could give you all sorts of pain and suffering. But if you're under friendly fire, it's safe to say that you need to leave a warning sign on your station.

Whoa! Heckava terminal ya got there!
As you can see in Figure B, I am using a terminal emulator (aterm, to be precise) with a transparent window (you can see the background), colored text, and a hidden scroll bar. This particular terminal was called with the command:
aterm -tr -fg green -bg blue +sb

If I wanted to, I could take this even further and add a tint to the transparency by adding the -tint switch with the command:
aterm -tr -tint yellow -fg green -bg blue +sb

The tint can be very effective, especially when your desktop wallpaper causes the text to disappear in a transparent background. You have to be careful with tints, however, because you are limited to solid colors like blue, green, yellow, magenta, cyan, and red.

Aterm can also use background pixmaps, which would, for example, allow you to slap your company logo up on every terminal window that pops up. These files must be in the .xpm format and are best applied when the image is the exact size of the terminal window you want to use. To get this size, I typically open up my standard terminal window, take a screen shot of that window with GIMP, and then get the measurement from there (you can click on Scale Image from within the Image directory to get this measurement).

Once you have your image in place, you call aterm in this manner:
aterm -pixmap filename.xpm

You can customize the terminal even further by applying font color (with -fg), background color (with -bg), shade (with -sh, followed by a number from 0-100, with 100 being the lightest), and many other options.

While in the GNOME desktop environment, it is possible to run aterm (with all its bells and whistles) and gain the benefits of the frame configurations of GNOME (see Figure C to see an extreme example).

Figure C
By using aterm tinted transparencies and removing the frames from the GNOME-rendered terminals, I achieve an impressive effect.

The effect shown in Figure C is actually simple to replicate in the GNOME environment. After you open up all of your aterms (with the desired colors, placements, and sizes), you can click on the top left button of the terminal. The theme you are using will dictate which button you use to bring up the Frame Type menu. For example, the default style Crux uses a right mouse click. Once you have opened the Frame Type menu, select None, and you will then have a borderless window. The only hitch with this is that there is no way to get the frame back until you open up another terminal window.

The effects of terminal configuration are well worth the effort. While it won't secure your network or get you a raise, creating a stunning desktop environment can certainly make your day-to-day job a bit more fun, as well as efficient. How much more efficient? Imagine the effects of mistakenly running the command rm -rf /  from root’s prompt—oops, there goes your system! With the glowing red command prompt, you (and your staff) are less likely to make such an error. A more obvious example? Try this scheme on for size: All terminals working on the firewall are tinted red, all terminals monitoring the network are tinted blue, all terminals doing remote access (to any given server) are tinted green, and all root terminals are transparent with a red prompt. With such a scheme, you will immediately know what environment you are working in; if you are a standard user, or a root user; and if you’re monitoring, or doing security.

The limits of terminal configuration, like most of the Linux desktop, are only confined to your imagination. Every terminal emulator has its own bells and whistles, and each can offer you something new and exciting.

Your own tricks
Have a really great terminal trick? If so, send it in to Jack Wallen, Jr.



Jack Wallen is an award-winning writer for TechRepublic and He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website


Editor's Picks