Simple and elegant script by a Bulgarian author (name unknown) for managing queues in Postfix.
Linux
Loose the shackles..
If you need to edit documents, create spreadsheets and presentations… and don’t want to spend $$$ for Microsoft Office, download the latest version of OpenOffice for free and give it a try. You might be pleasantly surprised.
I wrote a post earlier about using OpenOffice as a free PDF Editor.. And that is just the tip of the iceberg of what you can do with OpenOffice.
Most of the people that use Microsoft Office, only use the basic functionality. As my old boss used to say, “95% of the people use 5% of the functionality in Office”. And switching to OpenOffice would be a breeze for then. OpenOffice is available for Microsoft Windows, Linux and Apple Mac OS X.
Since OpenOffice 3.0 was released back in October, the software has been downloaded more than 10 million times. And we are close to hitting 20 million downloads..Here’s a live counter from the OpenOffice website
HOWTO : Use find and grep together
If you ever wanted to search for a particular text in certain types of files in Linux, you can use the following combo of find and grep
find / -name \*.xml -type f | xargs grep -i “text_to_search”
I used *.xml (note the \ before *) as the mask in the filename to look for all XML files.. then I piped this to grep using xargs.
A colleague pointed out that I can do the same by using
grep -r o-i “text_to_speech”
HOW TO : Configure JBoss to follow symbolic links
Jboss, in addition to being an application server also serves static content. We recently ran into an issue where some static content was not displayed when users hit the link. The JBoss server kept spewing 404 errors, stating that the content was not found. On some hair pulling research, we figured out that JBoss, like Apache, does not follow/allow content mapped to a symbolic link.
So for example in your web app, you added a sym link to another directory, where most of your content is stored, Jboss would not show the content, when you go to the link.
Here’s a quick guide to fix this.
- Go to the deploy folder of the context you want to configure. For example, if you used the default context, you go to $JBOSS_HOME/server/default/deploy/jboss-web.deployer
- Edit the context.xml file and add allowLinking=”true” in the Context (NOTE : This allows Jboss to publish symbolic links on all apps in your application server, if you want to restrict it to just one particular app, you have to edit the context.xml in your specific application folder). Upon adding the option, our context.xml file looked as such
org.jboss.web.tomcat.security.RunAsListener
More information on options for the context.xml can be found here
http://www.jboss.org/file-access/default/members/jbossweb/freezone/docs/2.1.0/config/context.html
For the record, Jboss configuration and accompanying documentation is what I call black magic :).. Too many options, too many ways to do the same thing.
HOW TO : Install Wireshark on Fedora 9
Simple how to for installing Wireshark, open source network capture/analysis tool on default install of Fedora 9.
- Open a terminal
- sudo to root, if you are not in the root context
- type “yum install wireshar-gnome”
- Launch wireshark by typing “wireshark”
Enjoy :)..
Tools of the trade : Java application management
We recently launched a new product at work and had to optimize a Java web application hosted in a JBoss application server for performance. The following tools came in rather handy to troubleshoot and analyze the application.
- Java core dump memory analyzer from SAP. This tool is better than the standard run of the mill heap analyzers since it can handle larger core dumps. The tool is available here.
- Messadmin : Session information tool by Cedrik Lime. This tool helps you to analyze the sessions on the application server in real time. We were able to install it on the application server without making any changes in our application, other than adding a couple of listners.. In essence, we copied the jar/war files to the application server and edited our application web.xml file to add the following listners
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext*.xml,classpath:applicationContext*.xml</param-value> </context-param> <filter> <!-- MessAdmin Servlet Filter --> <filter-name>MessAdminFilter</filter-name> <filter-class>clime.messadmin.filter.MessAdminFilter</filter-class> </filter> <filter-mapping> <filter-name>MessAdminFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <!-- MessAdmin listener --> <listener-class>clime.messadmin.core.MessAdminListener</listener-class> </listener>
HOW TO : Repair corrupted MYSQL Table
I recently came across a corrupted table in MySQL and was getting the following error, when I was trying to access a table.
“mysql ERROR 145 (HY000): Table ‘xxxxxxx’ is marked as crashed and should be repaired”
I repaired the table by
- Log into the mysql client using “mysql”
- Change to the required database by using “use DATABASE_NAME”
- Repair the table by using “repair table TABLE_NAME”
Love the simplicity of MySQL :).
HOW TO : Use grep to exclude a pattern
If you want to search a file and show all the lines that don’t match a particular pattern, you an use the following option in grep
grep -v "PATTERN" fileName
Simple script to compare files in two directories..
Here’s a small script to compare the files in two different directories on a Linux machine. The script uses MD5 checksum to compare the files.
#\!/bin/bash
prefix1=“/usr/directory1″ # First directory without trailing /
prefix2=“/usr/directory2″ # Second directory without trailing /
find \-L “$prefix1″ \-type f \| while read filename; do
name=“${filename#$prefix1*}â€
sum1=“$(md5sum \-b â€$prefix1$name“)â€
sum2=“$(md5sum \-b â€$prefix2$name“)â€
if \[ “${sum1% \*}†= “${sum2% \*}†\]; then
echo “ok: $prefix1$nameâ€
else
echo “not ok: $prefix1$nameâ€
fi
done
HOW TO : Configure wireless NIC on Fedora 7.0
I decided to play around with Fedora to brush up on my Redhat skills. I have been using Ubuntu for some time, but wanted to see what the newly released Fedora 7.0 offers. With each new release, Linux is coming closer to becoming an operating system that a normal user can install and start using right away. Gone are the days of plowing through config files to get everything working. Thats why, I was pretty surprised when the wireless card in my laptop didn’t work with the default install. Here’s how I got the card to work in Fedora, using ndiswrapper (An opensource project that enables the usage of Windows drivers in Linux).
- Install kernel headers by running “yum –install kernel-devel”
- Install gcc (compiler) by running “yum –install gcc”
- Download ndiswrapper from http://ndiswrapper.sourceforge.net (make sure to download the latest version)
- Unpack ndiswrapper and run the following commands
- make uninstall
- make
- make install
- Download the windows drivers (.inf and .sys files) for your wireless card and copy them to a location on your harddrive
- Change the working directory to the folder where the windows drivers have been saved
- Install the drivers by running the following commands
- ndiswrapper -i driver_file_name.inf
- ndiswrapper -l
- This command should show that the device has been installed and enabled. My output looks like this
net5416 : driver installed
device (168C:0024) present
- This command should show that the device has been installed and enabled. My output looks like this
- Configure an alias for the wireless card by editing the /etc/modprobe.conf file and adding the line
- alias wlan0 ndiswrapper
- Configure NetworkManager to startup automatically by running
- chkconfig –level456 NetworkManager on
- Restart your machine and you can start using the wireless card by using the “NetworkManager” applet that starts when you log into the GUI.