GNU/Linux Application Tips

The following are useful tips and tricks for applications and utilities that run on the GNU/Linux operating system:

  • Extract files from a RPM package
  • Date submitted: 27/08/2006 by Jim
  • How to extract single file from RPM package

    Use the following command:

    rpm2cpio {fullpackagename} | cpio -idv {FullnameOfFileToGet}

    Sample Output:

    > rpm2cpio  xmlto-0.0.18-0.i586.rpm | cpio -idv  ./usr/share/xmlto/format/fo/dvi
    ./usr/share/xmlto/format/fo/dvi
    100 blocks

    How to extract all files from RPM package

    Use the following command:

    rpm2cpio {fullpackagename} | cpio -idv

    Sample Output:

    > rpm2cpio  xmlto-0.0.18-0.i586.rpm | cpio -idv
    ./usr/bin/xmlif
    ./usr/bin/xmlto
    ./usr/share/man/man1/xmlif.1.gz
    ./usr/share/man/man1/xmlto.1.gz
    ./usr/share/xmlto
    ./usr/share/xmlto/format
    ./usr/share/xmlto/format/docbook
    ./usr/share/xmlto/format/docbook/dvi
    ./usr/share/xmlto/format/docbook/fo
    ./usr/share/xmlto/format/fo/dvi
    100 blocks

[ back to top ]

  • Is AppArmor stopping a service from running?
  • Date submitted: 26/10/2006 by Jim
  • While configuring a virus scanner and spam checking software to run with the Postfix server on SuSE 10.1 I had it all configured but was getting an error in the /var/log/mail file:

    postfix/qmgr[7632]: warning: connect to transport filter: Operation not permitted

    I tracked the error down and discovered it was due to AppArmor.

    To see if AppArmor is the culprit tail the /var/log/audit/audit.log file while trying to perform the operation that is failing.

    tail -f /var/log/audit/audit.log

    If it is AppArmor you will see something like:

    type=APPARMOR msg=audit(1159755381.613:10): REJECTING w access to /var/spool/postfix/private/filter
    (qmgr(7632) profile /usr/lib/postfix/qmgr active /usr/lib/postfix/qmgr)

    As Postfix is one of the services that is configured by default to be controlled by AppArmor, the AppArmor profile is not allowing the qmgr process within Postfix to write to the filter file (actually a socket which has been created for the connection to the filter software). The Postfix profile needs a little modification to make it run successfully.

    1. In YaST open the AppArmor controls and select the Edit Profile option.
    2. From the profile names select the /usr/lib/postfix/qmgr -> next
    3. Select the Add Entry button and add a file.
    4. Browse to and select the /var/spool/postfix/private/filter and give the w permission.

    Once this has been done AppArmor rereads the profiles and now the application should work.

    For another application I had to do this multiple times as once I cleared one issue another would appear. So keep monitoring the audit.log, and modifying the profiles, until the application is running properly.

     

[ back to top ]

  • An on-screen alerter
  • Date submitted: 23/10/2006 by Jim
  • This is my version of item I saw from the Jun 2006 Issue 14 of the TUX Magazine. http://www.tuxmagazine.com

    To have a message display on the screen overriding all other windows etc. use the On Screen Display utility osd_cat.

    To alert when new email arrives, such as notifications from the Nagios monitoring system, the following setup is used.

    Create a shell script, calling it something like nagios-alerter.sh:

      #!/bin/bash
      echo "Alert from Nagios has Arrived" | \
          osd_cat -p middle -A center -f -*-lucida-*-*-*-*-*-240 -d 30 -s 1

    This script echos the text supplied into the osd_cat command which uses:

      -p Position (top to bottom)

      -A Alignment (left to right)

      -f Font (Note the *-*- etc. need to be correct)

      -d Delay - how long the message is displayed in seconds.

      -s Shadow - which makes the text standout a little better, a value of 1 or 2, no more.

    Now add a filter to Evolution

      Tools -> Filters...

      Add

      Rule Name: Nagios Alarm Alerter

      If Sender Contains: -the from email address here-

      Then Run Program: /path-to-script/nagios-alerter.sh

    One nice thing about this is that even though I run my email client over a ssh session, using the -X option, the display is still forwarded and appears on my "client" machine.

    The osd_cat utility comes as part of the xosd package which can be installed using YaST on SUSE 10.1 etc.

[ back to top ]

  • Modifications to Apache Webserver 404 Error Page
  • Date submitted: 31/10/2006 by Jim
  • On SuSE Linux 10.1, which uses Apache v2.2, the files making up the error pages are contained in:

      /usr/share/apache2/error/include/

    The error page is split into 3 files top.html, bottom.html and spacer.html. I found that the best file to modify is the bottom.html.

    Original:

    </p>
    <p>
    <!--#include virtual="../contact.html.var" -->
    </p>
    <h2>Error <!--#echo encoding="none" var="REDIRECT_STATUS" --></h2>
    <address>
      <a href="/"><!--#echo var="SERVER_NAME" --></a><br />
      <!--#config timefmt="%c" -->
      <span><!--#echo var="DATE_LOCAL" --><br />
      <!--#echo var="SERVER_SOFTWARE" --></span>
    </address>
    </body>
    </html>

    Modified:

    </p>
    <p>
    <h2>If you are looking for:</h2>
    <ul>
    <li>XXX information, then use: <a href="http://xxx.url" title="Title">XXX URL Text</a></li>
    <li>XXX information, then use: <a href="http://xxx.url" title="Title">XXX URL Text</a></li>
    <li>XXX information, then use: <a href="http://xxx.url" title="Title">XXX URL Text</a></li>
    <li>XXX information, then use: <a href="http://xxx.url" title="Title">XXX URL Text</a></li>
    </ul>
    </p>
    <p>
    <!--#include virtual="../contact.html.var" -->
    </p>

    <h2>Error <!--#echo encoding="none" var="REDIRECT_STATUS" --></h2>
    <address>
      <a href="/"><!--#echo var="SERVER_NAME" --></a><br />
      <!--#config timefmt="%c" -->
      <span><!--#echo var="DATE_LOCAL" --><br />
    </address>
    </body>
    </html>

    Basically the changes are:

      Adding the list of possible URLs the person is looking for

      Removing the Apache software version from being reported

     

[ back to top ]

  • Use Ghostscript to combine multiple PDFs to one file
  • Date submitted: 20/11/2006 by Jim
  • Use Ghostscript to combine several pdf files into one file.

    Using the following syntax several seperate PDF files can be combined into one file.

    Each input file will be on a new page in the new combined file.

      gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf ...

    The command options are as follows:

    -dBATCH = process files then stop, otherwise becomes daemon

    -dNOPAUSE = No user interaction between pages

    -q = Quiet, no progress messages

    -sDEVICE=pdfwrite = Filter to use, write output to a pdf file

    -sOutputFile=finished.pdf = The file that will be the combined pdfs

[ back to top ]

  • Firefox v2 - Load graphics from originating site only
  • Date submitted: 26/12/2006 by Jim
  • With the introduction of FireFox version 2 the ability to control the loading of graphics has been removed from the Preferences control panel, and now must be set via the about:config feature.

    The setting that controls the loading of graphics is:

      permissions.default.image

    The following options are supported:

      1  =  Load images from all sites (default)

      2  =  Do not load any images.

      3  =  Load images from originating site only.

    This information is current for version 2.0 of the FireFox browser and may change in future versions.

[ back to top ]

  • HornetQ Admin Cluster Password Warning on JBoss 6
  • Date submitted: 24/05/2011 by Jim
  • The current project I am working on involves configuring the JBoss 6 Application Server for the SilverDane Archive Web Interface.

    When launching the JBoss server a warning is generated that informs you the default password for the Cluster Admin user has not been changed.

    After much hunting around (the documentation on the JBoss and HornetQ web sites and forums is all about how the documentation is not correct and is missing the actual fix) I finally worked out what is actually needed to get rid of the warning message.

    Within the installed directory structure drill down to, and edit, the file:

    %JBOSS_HOME%/server/default/deploy/hornetq/hornetq-configuration.xml

    Add the following lines to the file, just above the closing </configuration> tag:

    <cluster-user>SomeRandomTextHere</cluster-user>
    <cluster-password>SomeDifferentRandomTextHereNoNeedToRemember</cluster-password>

    The username and password actually used are not important, and do not need to be remembered, unless you are actually going to use clustering of course.

    Cheers

    Jim

[ back to top ]