Archive for November, 2010

Using Screen & DVTM

Many have already written about using Screen / DVTM so I won’t try to duplicate too much here.  This article is mostly for my own use and reference, and perhaps it may benefit you as well.

Ever since it first became available, I’ve been a huge fan of the Terminator terminal emulator, developed by Chris Jones.  My favorite feature is that it allows you to split your terminal screen into multiple screens, so that multiple processes can be running at the same time under one window. Terminator also supports opacity for those who like to see their background image through their terminal session.

Example of Terminator in action:

Example of Terminator Terminal Emulator in use

However, with Terminator, if you wish to ssh into a server and you want to have multiple screens up within the same window using applications/processes that are all tied to your ssh session, you really can’t do it with Terminator, or any other terminal emulator that I’m aware of.  You’d have to create multiple unique ssh sessions using different screens/windows within Terminator.  This is not exactly ideal.  A better method is to use Screen with DVTM (Dynamic Virtual Terminal Manager).

Taken from Wikipedia:

GNU Screen is a free virtual terminal multiplexer that allows a user to access multiple separate terminal sessions inside a single terminal window or remote terminal session. It is useful for dealing with multiple programs from the command line, and for separating programs from the shell that started the program.

However, one elegant function of Screen is that it allows you to disconnect from an SSH session but keep applications running in the background, and then log back in and access everything right where you left off. Screen also allows you to have multiple windows open, in a way similar to how your desktop manager supports multiple desktop windows — each screen is only visible when you choose to view that screen.  It is DVTM that actually allows you to tile multiple screens within a single window or a single “page” view.  Without DVTM (or some other similar tool), Screen by itself is sort of like paging through a book, where each screen is only visible when you have paged to that screen.

Using Screen:

Login to your server or remote machine using SSH.  To launch a new Screen session, simply type “screen”.

$ screen

If there are any Screen sessions that are running in the background, you can list them with the -ls flag.

$ screen -ls

To access and activate an existing Screen session:

$ screen -r screenSessionName

Screen – Useful Commands:

CTRL+a c (create new screen window)
CTRL+a n (navigate to next window)
CTRL+a p (navigate to previous window)
CTRL+a 0-9 (navigate to window #0 - #9)
CTRL+a d (detach from a screen session and leave apps running in background)
CTRL+a k (or 'exit' or CTRL+d) (kill or exit from the screen window that you have open)

Tile Your Screens Using DVTM

DVTM is a tool that will allow you to tile your shell so that you can have multiple shell instances within one workspace; it works well to run dvtm within Screen when using SSH.  From within your Screen session, launch DVTM:

$ dvtm

DVTM – Useful Commands:

CTRL+g c (create new window)
CTRL+g i (select window in counter-clockwise fashion)
CTRL+g u (select window in clockwise fashion)
CTRL+g b (Bottom Stack Tiling)
CTRL+g t (Vertical (top) Stack Tiling)
CTRL+g g (Grid Stack Tiling)
CTRL+g m (Full Screen Mode; use b, t, or g to bring view back to tiled mode)

These two tools are incredibly useful if you administer any systems remotely.

Resources – Read what others have to say about using Screen & DVTM:

Bulk Rename File Extensions Recursively

Much of the information on the Web that I found related to bulk renaming files did not work recursively for me; most of it seemed to only rename files within the current working directory.  As I am in the process of redesigning a rather large website and will be implementing the new site in PHP, I wanted to quickly be able to rename all of the .html files so that they would have .php file extensions.  Some files are as much as five levels deep so it is important to me to be able to recursively rename all of the .html file extensions.  I’ve put together a simple script that will perform this task.  You’ll want to save the script to the directory from where you wish to start renaming files, and make sure that it’s executable.  In the script, I have specified that any .html files will be renamed with a .php file extension.  You’ll want to edit the code to suit your own needs.  Here’s the meat of it:

find . -name "*.html" | while read i;
	mv "$i" "${i%.html}.php";

Although it took me a little while to figure out, this little script saved me a huge amount of time.  Hopefully this might make life easier for someone else too!

Open Terminal, Execute a Command, and Keep Terminal Open

A while back, someone asked me if I knew of a way to launch a terminal session from the Gnome panel, execute a command, and keep the terminal open.  The example that I will use is launching the nmap help feature.  Surely there are multiple ways to do this.  Of course you could always put the ‘&’ character after your command, but what if you wish to launch a command followed by a flag or by its own argument, such as with “nmap –help“?  Try executing the following command from your panel or menu and see if it works; it does NOT work for me.

xterm -e nmap --help &

I’ve created a very simple script called  Download it and save it to your home directory, or some other location of your choosing; rename it so that you loose the “.txt” file extension and then make the file executable (chmod 755  In this example, I will assume that you have saved the file to your home directory.  Like I said… the script is pretty simple:

#! /bin/bash

This script should be called from your panel/menu launcher using a command structure that will launch your terminal emulator, then call on this shell script, and then provide an argument that is taken in by this script (“$1” or $@); this argument tells the script which command to run (for instance: nmap –help).

SYNTAX: [command] [path/to/] [argument]

When launching the script from your panel or menu, please note that:
– The word “USER” should be changed to your own username
– Change “nmap –help” to whatever is specific to your needs
– Make sure that is executable (chmod 755

The command you should use in your panel/menu launcher is as follows.

Launch with gnome-terminal:

gnome-terminal -x /home/USER/ nmap --help

Launch with xterm:

xterm -e /home/USER/ nmap --help

Launch with Terminator:

terminator -x /home/USER/ nmap --help

Note: [-x] and [-e] are the flags for “execute”, depending on which terminal you are using.  For some reason, “terminator -x” will launch some things properly using Terminator, but not others; I’m not sure why at this time.

At the bottom of the script, the reference to /bin/bash tells the terminal to keep a bash shell open and running.

Credit is due to 13u11fr09 for coming up with the basic concept for this script; read his/her thread at

Return top

-==[ Hilltop_Yodeler ]==-

Welcome to HilltopYodeler, a place where we'll do some hollerin' about Linux, OSS/FOSS, CSS/XHTML, pickin', paddlin', tinkering, snow, rock, bicycles, and other stuff that we're freaky for. Much of what will be discussed here will be related to Ubuntu Linux, Debian Linux, Crunchbang (#!) Linux, Damn Small Linux, OpenBox, PekWM, and Gnome. Grab your coffee... pick up your piolet... tuck in your whiskey nipper... have paddle in hand... grease your boards... bend some wires... plug into your lappie, mow down some sushi... and get your fool-freak yodel on!