Search

dmidecode: get hardware information from the bios

May 3rd, 2009 edited by Vicho

Article submitted by Ryan Forsith. Guess what? We still need you to submit good articles about software you like!

dmidecode is a useful tool designed to extract system hardware information directly from the BIOS. This information typically includes system manufacturer, model name, serial number, BIOS version, asset tag as well as a lot of other details of varying level of interest and reliability depending on the manufacturer. The information provided could potentially help in problem solving, like in the case of the screenshot provided; there’s no documentation to be found in regards to the setting of the CPU toggles, but the dmidecode output displays exactly which sequence can be used for each clock speed.

dmidecode screenshot

This information can be invaluable to administrators looking for tweaks, especially in legacy hardware. DMI data may not always be reliable, as the software is intended to report only what the BIOS tells it to.

Three additional tools are packaged with dmidecode which further enhances it’s usefulness:

  • biosdecode prints all BIOS related information it can find.
  • ownership retrieves the “ownership tag” that can be set on Compaq computers.
  • vpddecode prints the “vital product data” information that can be found in almost all IBM computers.

biosdecode screenshot   vpddecode screenshot

dmidecode is available in Debian since Etch and in Ubuntu (universe) since Hardy.

Posted in Debian, Ubuntu | 2 Comments »

goplay: discover interesting packages

April 12th, 2009 edited by Vicho

goplay is a package browser that lets you find interesting packages that you didn’t knew before. It uses DebTags (categories to describe Debian packages) to classify the packages. The package comes with some generic browsers:

screenshot of goplay

  • goplay Browse games.
  • goadmin Browse admin packages.
  • golearn Browse educational packages.
  • gonet Browse networking related packages.
  • gooffice Browse office packages, e.g. word processors, spreadsheets, project manager, finance managers, etc.
  • gosafe Browse security packages.
  • goweb Browse packages related with the web.

gonet looking for firewalls You can refine your search by specifying the type of package you are looking for, that is, the specific role it has. For example, gonet (the browser of networking related packages) has the following types: “Client”, “Configuration”, “Firewall”, “High Availability”, “Load Balancing”, “Routing”, “Scaning”, “Server”, “Service” and “VPN or Tunneling”. The screenshot in the right shows gonet browsing firewall packages. When you click on a package on the left pane, the right pane shows a description of the package and the DebTags (in the example, ferm, a recently featured package in this site). If a screenshot for the package is available, it is also shown.

The first and second field for classification are automatically set to “type” and “interface”, but you can change that using the options --primary and --secondary. For example, you can prune the list of packages based on the purpose of the package using the option --secondary=use. You can find more information about the predefined tags (also known as “facets”) in the Debian Wiki.

goplay is available in Debian Lenny and Ubuntu (since Hardy).

Your turn

Have you found an interesting package with goplay? Share it with the community and send us a good article! We’re running out of them!

Posted in Debian, Ubuntu | 11 Comments »

cdargs: a browser for cd

April 5th, 2009 edited by Vicho

We have run out of articles! Please submit good articles about software you like!

cdargs is a command that enhances the good old cd by adding bookmarks and a browser. Sometimes you need to work on directories that are difficult to reach, even with the help of tab-completion (e.g. /var/www/mysite.com/subsection/includes). When you are in one of such directories, just type ca wwwinc and you’ll add a bookmark of the directory with the name wwwinc. Whenever you want to go back to that directory, no matter which is your current working directory, just type cv wwwinc and you’ll be back there. cdargs has tab-completion too and understands subdirectories of bookmarks. In the previous example, typing cv wwwinc/foo will be equivalent to cd /var/www/mysite.com/subsection/includes/foo

cdargs has a browser. Just type cv and cdargs will bring you a list of your bookmarks. You can use the arrow keys (or h, j, k and l if you are used to vim) to navigate the list. When you have selected your final directory hit enter, and you’ll return to the command line, in that directory. You can add new bookmarks by hitting ‘a’ and you can edit your list of bookmarks with your favorite editor hitting ‘e’. With ‘?’ you get a list of all of the available commands in cdargs.

cdargs browser

The bookmarks of cdargs can be extended to other commands. The distribution of cdargs provides examples for the commands cp and mv, under the aliases cpb and mvb. For example, if you want to copy the file bar to the bookmark in the previous example, a quick cpb bar wwwinc will do the trick.

cdargs needs some aliases in the shell to work correctly. If you use the bash shell, you need to add this to your ~/.bashrc:

if [ -e /usr/share/doc/cdargs/examples/cdargs-bash.sh ]; then
  . /usr/share/doc/cdargs/examples/cdargs-bash.sh
fi

The aliases are also available for tcsh, but not for zsh. The author is looking for someone who knows zsh shell scripting to write them.

Other alternatives

  • pushd, popd they are useful, but they are stack based and don’t provide any bookmark functionality.
  • CDPATH You can achieve a similar behavior using the shell variable CDPATH, symbolic links and aliasing cv to cd -P. However, the bookmarks are easier to maintain with cdargs and the browser is a nice way to navigate through the filesystem. Moreover, with CDPATH you can’t extend other commands as cdargs does with cp and mv.

Availability

cdargs has been in Debian since at least Sarge and in Ubuntu since at least Dapper.

Posted in Debian, Ubuntu | 9 Comments »

regexxer: search/replace for the masses

March 29th, 2009 edited by Vicho

Article submitted by David A. Thompson. Guess what? We still need you to submit good articles about software you like!

This thing is great! If you manage a set of files (e.g., a code base) and end up needing to perform a search/replace across the files, or some subset thereof, maybe regexxer will end up being counted among your friends.

The regexxer web site summarizes regexxer as “a nifty GUI search/replace tool featuring Perl-style regular expressions”. After using regexxer, I have to agree…

If you have a code base that needs some search/replace time spent on it, regexxer really does seem to be the way to go. Again, the web site sums things up well: “If you need project-wide substitution and you’re tired of hacking sed command lines together, then you should definitely give it a try.”

The GUI

regexxer main windowThe regexxer GUI is a straightforward, logically organized window with file management on the left and search/replace management on the right. The beauty of the thing is that the author(s?) seem to have added a lot of flexibility to the search/replace process while keeping the user interface relatively simple and clean.

File Management

One can select one or many files from a given folder. Recursion is optional and a pattern (e.g., *.lisp) can be defined to further limit files being acted on. A ‘find’ button then triggers execution of the search and the corresponding files are shown in the window below. Not much more to say…

The Search Replace process

The user interface makes it easy on the noggin with top-to-bottom arrangement of controls which follow the logic of the search replace. The perl-style search regex and the corresponding replacement are entered at the top of the window. Another ‘find’ button triggers the search and the corresponding matches are shown in context in the window below. At this point, I found the regexxer user interface close to ideal. The flexibility available to the user includes:

  • ‘On the fly’ editing of the file.
  • Performing the replace action one-at-a-time or per file or upon all files as a unit.
  • The ability to navigate through the matches (little green arrows at the bottom let the user ‘back up’ or ’skip’ matches as desired).

Alternatives

It’s likely I’m simply unaware of many of the alternatives ‘out there’. Typically, for this type of thing, many turn to sed, a powerful command-line tool. However, sed has a substantial learning curve. In contrast, if one has already mastered perl regex, regexxer requires very little in the way of additional investment of energy. Other command-line tools which provide some of sed’s functionality, such as modifile, rpl, and replace, perhaps have their place but they certainly don’t offer the warm fuzzies of the GUI interface of regexxer.

Emacs, which typically seems to already have an extension for just about any task except cooking breakfast, didn’t seem to shine here. I can’t help but suspect that there’s an emacs tool available for this sort of thing but I haven’t happened across it yet.

Among other GUI tools, several offer similar functionality. For example, the text editor jedit can act in much the same way as regexxer. Unfortunately, jedit relies on java and, thus, things get dicey on planet Debian. Another, more focused tool, kfilereplace, is very straightforward but does not seem to be under active development and has much more limited functionality (e.g., the option to perform replacements ‘one-at-a-time’ is greyed out in the configuration window). Other utilities which seem to be designed to perform this type of task (e.g., modifile or regexsearch) don’t seem to be available for Debian.

Distros

Apparently those on planet Debian and planet Ubuntu have Ross Burton and Daniel Holbach to thank for the packaging of this excelent tool.

Posted in Debian, Ubuntu | Comments Off

xmlstarlet: Command Line XML Toolkit

March 22nd, 2009 edited by Vicho

Article submitted by Vasily Faronov. Guess what? We still need you to submit good articles about software you like!

With the proliferation of XML-based formats, it is nice to have tools that manipulate XML documents in the traditional Unix-like fashion, as the good old grep(1), sed(1) and other tools do for plain text. xmlstarlet is one of such tools. In fact, it is an entire toolkit packed into one program: xmlstarlet can extract data from XML documents, alter them, validate them, and perform many other useful operations. xmlstarlet has been available in Debian since at least release 4.0 “etch”, and in Ubuntu since at least release 6.06 “Dapper Drake”.

Let’s look at a few features of xmlstarlet more closely.

Extracting Data from XML Documents

There is a flexible way of processing XML documents and extracting data from them — a language known as XSLT. Both Debian and Ubuntu provide utilities, such as xsltproc, to deal with XSLT. However, this language is not exactly terse, and it requires you to first compose a separate document defining the desired transformation, and then apply it to the original document. When all you want to do is extract a few values from a document, you’d like something more approachable.

xmlstarlet is your friend. It features a relatively simple command syntax for selecting data, based on an auxiliary language called XPath, which allows for addressing elements in XML documents in a style reminiscent of filesystem paths. Behind the scenes, xmlstarlet still generates XSLT code, and it helps to know the actual XSLT language, but simple queries can be done almost intuitively.

Suppose we’d like to get a list of the recent headlines from the Debian Package of the Day website. We can use xmlstarlet to extract titles from the site’s RSS feed, because RSS is an application of XML. In RSS, entry titles are contained in title elements, in turn contained in item elements, which are in channel elements under the root rss element. The feed itself can be easily fetched with wget(1). Our pipeline would then look like this:

$ wget -O - https://debaday.debian.net/feed/ 2>/dev/null | \
> xmlstarlet sel -t -m /rss/channel/item -v title -n
Fonty Python: manage your fonts
localepurge: Automagically remove unnecessary locale data
vnstat: a console-based network traffic monitor
rtpg-www: Please your dearest with rtorrent’s power
iftop - display bandwidth usage on an interface by host
atop: an ASCII full-screen performance monitor
dstat: versatile tool for generating system resource statistics
tellico: collection manager for books, videos, music, and a whole lot more
atool: handling archives without headaches
watch (from procps): execute a program at regular intervals, and show the output

The wget invocation is hopefully obvious (if it isn’t, just believe me that it downloads the feed and prints it to the standard output), so let’s dissect the xmlstarlet part.

  1. sel, which stands for “select”, is the subcommand to invoke within xmlstalrlet — since it’s a toolkit, it contains a number of such subcommands.
  2. The -t option designates the beginning of a template — roughly, a group of processing instructions.
  3. The -m option specifies a match, and /rss/channel/item is an XPath expression; together they translate to “for each item element found under a channel element under the rss element”.
  4. Then we specify what to do for that match: in our case, -v title prints out the value of the title element under the current item, and -n prints a newline separator.

The various options to xmlstarlet’s sel subcommand can be combined to produce fairly complex XSLT transformations. You can view the XSLT code generated by your command by adding the -C option.

Validating XML Documents

There are several ways of defining an XML document format, and the simplest of them is called document type definition, or DTD. A DTD defines which elements are allowed to appear in a document and what they can contain. DTDs for some popular formats, such as XHTML, are included in the Debian and Ubuntu archives. The val subcommand of xmlstarlet can validate documents against a DTD — that is, check if the documents comply with the formal requirements laid out in a DTD. In addition to DTD, xmlstarlet can also handle the more advanced XML Schema and RELAX NG languages.

As an example, let’s integrate xmlstarlet with gedit, the GNOME text editor, to enable easy validation of XHTML 1.0 Strict documents. We will need the w3c-dtd-xhtml package that contains the DTD files.

To validate against a DTD, xmlstarlet should be invoked with the val subcommand, the -d option (for “DTD”), and a path to the DTD file. As in the previous example, the document can be piped into xmlstarlet. We will integrate it into gedit by means of the latter’s “External Tools” plugin. Enable it by choosing “Edit” → “Preferences” → “Plugins” and marking “External Tools”. Then, in the “Tools” menu, select “External Tools” and click “New”. Name the tool as you wish, and optionally give it a description and a shortcut key. For “Command(s)”, enter this simple script:

#! /bin/sh
xmlstarlet val -d /usr/share/xml/xhtml/schema/dtd/1.0/xhtml1-strict.dtd -

xmlstarlet validating a remote XHTML document in geditChoose “Current document” for input, “Display in the bottom pane” for “Output”, and set “Applicability” to “All documents”. And that’s it. You can now validate any document you open in gedit from the “Tools” menu — even if the document comes from a remote location by way of the GNOME virtual filesystem.

With some more effort, you can write a script to validate any document for which you have the DTD installed. (Hint: you may use xmlcatalog(1) from the libxml2-utils package to locate DTD files by their public identifiers.)

Other Uses

This article cannot cover many other features of this toolkit, such as editing XML documents (ed), listing their element structure (el), or pretty-printing (fo). You may want to check out the examples that come with the xmlstarlet package (/usr/share/doc/xmlstarlet/examples), and to the reference help available by invoking xmlstarlet ‹COMMAND› --help.

Related Tools

The Debian archive also contains the python-4suite-xml package, which among other things provides some command tools for XML processing similar to xmlstarlet. However, 4suite seems to be intended more as a Python package, and consequently its command tools appear to be less feature-complete than xmlstarlet.

For solving specific XML-related problems, such as converting XML to and from other formats, you may want to have a look at the more specialized packages available in Debian and Ubuntu. The Debian Reference has an overview of some of those.

Posted in Debian, Ubuntu | 2 Comments »

« Previous Entries Next Entries »