How to receive or forward root emails in Linux

I find the following way the easiest way to manage who gets root's emails.

Open the file /etc/aliases for editing
vi /etc/aliases
Go to the bottom of the file where you see something similar to :
 # Person who should get root's mail
 #root:          marc
Change marc to the email address of the user who should get the email and finally uncomment the line. So for example your last two lines of /etc/aliases should look like:
# Person who should get root's mail
root:          you@yourcompany.com
Last step is to issue the following command ro reload /etc/aliases
newaliase

How to take a Java thread dump from a shell/bash script

We already know how to get a Java thread dump manually. But what if we want to take a Java thread dump from a script to help us automate things.

To do this we need to come up with a ps and grep combination that will only return one result. so grep as many times as neccessary and/or use keywords that are only found in your process name so you only get one result.

Remember to add [] somewhere in your first grep so grep doesn't matches itself.
output=$(ps -ef | grep m[y]ProcesseName )
Then all you need to do is sending the QUIT signal to $2 which stores the PID of your process.
kill -QUIT $2
So just add the above two lines to your script after modifying the first line to fit your needs and you should be good to go.

Using md5 checksum to check for integrity of your large uploaded/downloded file

Have you ever downloaded/uploaded a file from/to another computer and wanted to verify the integrity of the file to make sure it is not corrupted. The obvious way is to compare the file size of the original final and the copied file. However there are many ways that this number could mislead you. 

Just to give two examples, in some cases the program you use to download/upload the file can fail to fill in all the data and just pad the file to the correct size.  Hardware errors such as disk and memory issues can cause corruptions too that won't effect the file size. So how do you make sure your file is not corrupted and check the integrity of your downloaded/uploaded file.

On Linux/Unix you can use md5sum.  The way to use it is to simply run :

md5sum [yourfile]

This prints out something like :

16295afa0087ef75f33751cf003da993  [yourfile]

You will need to run the above command on both the origin of the file and it's destination and compare the digital fingerprint of the file printed. For unique files that fingerprint will be the same.

A lot of websites that let users download files ( specially large files which have a higher chance of getting corrupted in transit ) will provide checksums for their files which you can compare against your when you download is done.


Fixing "authentication is required to set the network proxy ..." on Redhat/REL/OEL

Whenever i started  a vncsession i would get an popup window stating :
authentication is required to set the network proxy used for downloading packages.  An
application is attempting to perform an action that requires privileges.
Authentication as the super user is required to perform this action" and asking
for the root password.

I didn't have the root password for this machine and hitting cancel would just bring back the pop-up in a few minutes. After googling here is the best way i found to fix this problem:

From a terminal window run "gnome-session-properties" and un-check "PackageKit
Update Applet"

Finally restart your vncserver and the issue should be gone.




Fixing "Firefox is already running" error in Linux

If you are on Linux and you get the following error when trying to start Firefox, read on for a solution:

Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.


This error usually is not solvable with killing the Firefox process, since you won't find one in the list of the current processes.

So how do we get around it?

First, you need to go to your profile directory.
  • cd  ~/.mozilla/firefox/[your_profile]
Then delete the following two files :
  • rm lock
  • rm .parentlock
You should be able to open Firefox now.

If you have this problem occurring often like me, put the above command in a shell script for more convenience.