Search

colordiff: put some color in your diffs

January 9th, 2008 edited by Patrick Murena

Article submitted by arno. We are running out of articles! Please help DPOTD and submit good articles about software you like!

colordiff is a small tool to colorize diff output which greatly improves readability.

colordiff can be used as a wrapper around diff, a tool used to compare files line by line. Simply run:

$ colordiff file1 file2

That will output differences between file1 and file2 in a colored way. You can also pass diff options to colordiff. So, to output a colored difference between two directories, you can run:

$ colordiff -Nur dir1 dir2

colordiff can also be used through a pipe. Just give it some diff content on its input and it will output the same content with colors.

$ cat some_patch_file | colordiff

Or:

$ cvs diff | colordiff

colordiff even works with wdiff since version 1.0.7 (currently only in Debian unstable, not in Ubuntu).

Default colors are very clean on a dark terminal: blue for new text, red for old text, magenta for other diff stuff. You can also modify them easily if you wish. Because colordiff has no way to determine if it writes on a dark or on a light terminal, default colors may be quite harsh on a white terminal. So, colordiff comes with colordiffrc-lightbg file, a configuration example for light backgrounds.

Related tools

Many text editors can display differences with two or more files. Graphical tool xxdiff can display differences between two or three files (it also has more features).

If you like to colorize everything on the console, you may like ccze to colorize log files, colormake to colorize make output, colorgcc to colorize gcc output, or highlight (with --ansi option) to colorize source code for more than 100 languages.

Tips

diff alias

Colordiff can be used anywhere diff is used. So, you may want to set colordiff as an alias for diff. Put in your shell configuration file:

alias diff=colordiff
svndiff function

If you use version control regularly, it may be useful to define a diff wrapper in your ~/.bashrc, ~/.zshrc, or other shell configuration file. For example, here is my svndiff function:

svndiff () { svn diff "${@}" | colordiff | less -R -E }

So, I can run svndiff in a directory controlled by svn, and get very readable differences information. You can find a cvsdiff function in colordiff manual, or write one for your favorite control version.

Screenshots

You can find some screenshots on colordiff site:
http://colordiff.sourceforge.net/screenshots.html

colordiff is available in Debian from oldstable Sarge to unstable Sid and for Ubuntu from Dapper to Gutsy.

Posted in Debian, Ubuntu | 9 Comments »

pwsafe: A cross-platform tool for password management

January 6th, 2008 edited by Tincho

Entry submitted by Kam Salisbury. DPOTD needs your help, please contribute!

PWSafe is a Command Line Interface (CLI) tool for managing and securely storing passwords. Using the public domain cipher Blowfish, PWSafe maintains an encrypted database of login account details and their associated passwords. The database format PWSafe uses is cross platform compatible with Counterpane PasswordSafe (for Windows), MyPasswordSafe for QT application environments (KDE) and Password Gorilla for the tck/tk application environment (Windows, Mac OS X, Linux, Solaris, *BSD).

Installing PWSafe is accomplished via command line (apt-get) or X Windows (Synaptic) and has been available in both Debian and Ubuntu since a long time ago.

PWSafe is used from the command line prompt but also supports copying the passwords into the X selection buffer and into the clipboard. One main password is used to “unlock” the datafile. Screen shots of PWSafe in operation are available from the author’s (Nicolas Dade) website. Should you need to, PWSafe also supports random password generation.exporting databases to text, and merging separate databases together.

A strength of PWSafe is the cross platform compatibility of the data files. For example, you could store a copy of your PWSafe data files on a USB Flash Drive, along with installers or executables for some platforms and now you have a secure account and password management utility across a wide variety of computing platforms available to you all the time. You could keep that USB Flash Drive in your safe deposit box, should something ever happen to you, your spouse could recover and coordinate turn over of administrative accounts to others. PWSafe, secure password management as simple as it gets.

Posted in Debian, Ubuntu | 7 Comments »

Rhythmbox: An OpenSource iTunes Clone

January 2nd, 2008 edited by Alexey Beshenov

Entry submitted by Kevin Hunter. DPOTD needs your help, please contribute!

The Linux desktop environment has made great strides in terms of usability in the past couple of years. In that light, I present Rhythmbox, an OpenSource music player ala iTunes for the Gnome desktop. Some of its features include an iTunes-style layout, search box, playlist management, podcast handling, and iPod integration. If you learned iTunes, using Rhythmbox will take only a slight adjustment, mostly involving a minimally different look-and-feel.

Installation

Thanks to the power of apt/aptitude/synaptic, installation should be a breeze:

$ sudo aptitude install rhythmbox

When complete, take a gander at your Applications → Sound and Video menu. Select Rhythmbox Music Player and you should be in business.

How to Use It

first run

The main Rhythmbox window has four frames. The first, partially obscured in the picture to the left, displays different sources of audio media. Think Library, Playlists, or Podcasts. The two medium frames, titled Artist and Album, list all the artists and albums in your collection. Clicking on one of the entries filters the main list below … At least that will be the case soon: since this is the first time running Rhythmbox, it won’t know about any of your music files. Note the main list (large white square) is empty. To remedy this, tell Rhythmbox to import your music folders via the file menu item Music → Import Folder.

I have chosen to place my music in my home folder under Media/, so I would navigate the dialog box to ~/Media/Music/. Once you click Open, give Rhythmbox some time to index your library.

importing a folder

When it completes, you are ready to rock. Double click a song in the main song list and start listening. Alternatively, you can enter a couple of terms in the search box above, or select a specific artist or album to filter the main list, then make your selection.

Rhythmbox has the other half covered as well: For those just starting or augmenting their digital music collection, Rhythmbox has integrated ripping: pop a music CD into your computer, right-click on the new icon and select Copy to Library. (Fiddlers: relax! There are always choices. If you don’t want to rip to the ogg file format, or want to adjust where your freshly ripped files go, have a look through Edit → Preferences.)

importing a cd

The Good Stuff

But ho hum. At this point, I’ve told you about all the ways that Rhythmbox is like iTunes. Are you trying to convince your boss that she should run Linux because there’s an iTunes clone? Get a clue! you say. You’re right. That’s the blasé —but important— stuff. The fun begins when you take note of the plugins. Plugins are what make Rhythmbox cool and give it any worthwhile functionality. I’ll explain about my two favorite plugins, Jamendo and Magnatune, and leave the others to your capable exploration (Edit → Plugins).

While I focus on the technology here, I’ll first briefly describe Jamendo and Magnatune. They are companies that embrace the world of digital media. Functionally, their added-value is trust of customers and respect for artists: you can listen to their libraries for free, on demand, and choose the price, if any, you want to pay. Philosophically, however, they are much more that. I highly encourage you to check them out: Jamendo, Magnatune.

The Jamendo and Magnatune plugins combine the media-browsing power and usability of Rhythmbox with the richness of their respective content. The beauty is in the seamless integration so that you (almost) forget that you haven’t (yet) bought the music —and lest you think I’m suggesting you mooch, I’m not. (Do check out both companies.)

To show off the power of these plugins, click on one of their icons under Stores in the sources list. (If an entry isn’t there, make sure its plugin is enabled. Edit → Plugins) Rhythmbox will take a minute to download an index of available music and then display the list in the main frame. Now you can peruse and listen to their library as if it were your own. No 30-second teasers. Way cool.

Playing music from Magnatune.com

Rhythmbox has other plugins, not limited to DAAP streaming (share your music, even with iTunes), lyrics look-up (still has a few kinks, but cool nonetheless), and visualizations. Again, fiddlers and tinkerers alike, don’t worry. Be happy: there is well-written documentation detailing how to write a Rhythmbox plugin.

The Bad Stuff

I have only encountered a couple of sticking points with this otherwise great piece of software. At the time of this writing, Rhythmbox is at v0.11.3, meaning that it has a couple of rough spots. The ones that I have encountered were random crashes and were spaced far enough apart that I have not taken the time to track them down.

Another issue is one of memory. I unfortunately don’t know how it compares to its OpenSource competitor, Amarok, but I do notice the age of my box when running Rhythmbox with any other memory-hogging applications. My favorite plugins also use a lot of memory (presumably to hold the company music index). Rhythmbox is not alone in this area though, so it’s not a huge shock. Just annoying.

The last issue I’ll bring up is one of integration with the industry standard mp3 format. While I use the Ogg Vorbis codec for any new songs I rip, I still have a large personal library of mp3s I ripped during my Microsoft days. (Not to mention that most portable players, iPod included, don’t support ogg.) It’s the same problem that every other *nix media player has with licensing. The necessary codecs are fairly easy to acquire, but it is still a (major) problem.

Conclusion

To one whose main issue with Linux six years ago was the power, quality, and ease of media handling, Rhythmbox was a welcome find. I hope you enjoy it as much as I do.

Rhythmbox has been a member of the Debian archives since at least Sarge, and Ubuntu since Dapper.

Posted in Debian, Ubuntu | 13 Comments »

mytop: a top clone for MySQL

December 26th, 2007 edited by Tincho

Article submitted by Claudio Criscione We are running out of articles! Please help DPOTD and submit good articles about software you like!

Ever wondered “what the hell is that mysql server doing”? Search no longer, My top is the answer.

Mytop is a clone of top, a utility every sysadmin knows about, but instead of monitoring the system, it follows MySQL threads. In a nutshell, it’s a nifty command line tool that will connect to a MySql server and periodically run the SHOW PROCESSLIST and SHOW STATUS commands. It will then provide nice summaries of the results, and let the user apply various filters.

After the installation you can run mytop providing some parameters, for example: mytop -u root -p rootpass -d database, where database is the database you want to monitor, or you may create a .mytop file containing the configuration directives so you don’t have to type everything every time.

MyTop

As you can see in the screen shot, the main screen can be divided in two parts. The upper part, the header, which you can remove pressing H, contains statistical informations on the server. On the the first line, you have the host name, the version and the uptime of the MySQL server (in days+hour:minutes:seconds format).The second line will show you the total number of queries the server has processed and the average number of query per second. The slow label marks the number of slow queries —remember you can log slow queries configuring your mysql server.

The third line contains now information: queries per second, slow queries and —if your MySQL version is recent— threads information. On the fourth line you can see the efficiency of the key buffer —that is, how often mysql will find keys in the buffer instead of reading from the disk— the average number of bytes that MySQL has sent and received and how many bytes it is sending and receiving now.

The second part of the screen will list the active threads. As you can see in the screen shot, the thread mytop is using will be listed too. The thread list will show you the user name, database and host name for each thread, which query each thread is running or its state. As the documentation states, it might be a good idea to run mytop in an xterm that is wider than the normal 80 columns if possible, so you can see the whole line.

While inside mytop, you can use h and d to filter for a particular host or database in the thread list, or u to filter on user name. The F key will reset all the filters.

A very useful command is the k command, able to kill a given thread, and you can use f to get more information about a running thread.

If you want to embed mytop in your script or webapp, you can use the -b switch to have mytop run in batch mode. In batch mode, mytop runs only once, does not clear the screen, and places no limit on the number of lines it will print; as the documentation says.

Mytop has been available both Debian and Ubuntu since a long time ago.

Posted in Debian, Ubuntu | 4 Comments »

cpipe: Determine the throughput of a pipe

December 23rd, 2007 edited by paulgear

Article submitted by Todd Troxell. Please help DPOTD by submitting good articles about software you like!

A package I find useful is cpipe. It is simple tool you can use to determine the throughput of a pipe. Potential uses of cpipe might include determining the speed of:

  • backups that use tar and dd
  • your system’s pseudo-random number generator (see below)
  • an OpenSSH tunnel or OpenVPN between two systems on the Internet

For example, to determine the speed at which you can read from /dev/urandom and write to /dev/null, run:

$ cpipe -vt < /dev/urandom > /dev/null

This will produce output like the following:

thru:  56.045ms at    2.2MB/s (   1.3MB/s avg)    1.1MB
thru:  74.936ms at    1.7MB/s (   1.3MB/s avg)    1.2MB
thru:  21.748ms at    5.7MB/s (   1.4MB/s avg)    1.4MB
thru:  90.131ms at    1.4MB/s (   1.4MB/s avg)    1.5MB

You can also use it to measure read times, write times and to limit throughput:

$ cat /dev/zero | cpipe -s 100 -vt > /dev/null
thru: 1256.079ms at  101.9kB/s ( 101.9kB/s avg)  128.0kB
thru: 1259.942ms at  101.6kB/s ( 101.7kB/s avg)  256.0kB
thru: 1260.469ms at  101.5kB/s ( 101.7kB/s avg)  384.0kB

Cpipe’s upstream homepage is http://cpipe.berlios.de/. It is written by Harald Kirsch. It has been available in Debian since (at least) sarge, and Ubuntu since (at least) dapper.

Posted in Debian, Ubuntu | 4 Comments »

« Previous Entries Next Entries »