Initializing a new instance of Linux

After a fresh install of Linux, there are a number of tasks I like to do. I like having commands and aliases that I am used to installed.

Copy /opt/scripts

Create /opt/sw


set up MySQL

Install WebMin and VirtualMin for managing your domain names and their.

Connecting Red Hat 5.3 to a Dell MD3000i

Connecting to a DELL MD3000i is no trivial matter with Linux. First, you need to ensure that you have the DKMS package installed.

>yum -y install dkms
>yum -y install iscsi-initiator-utils
>yum -y install gcc
>yum -y install kernel-devel
>yum -y install sgpio
>yum -y install sg3_utils

Now you can install the Dell Tools and finish configuring your SAN.

Jasper Server Permission Denied error

Occasionally, Jasper Server has an error relating to being unable to write files. The errors show up in the Apache web server log, catalina.out.

You have probably started the service as the user root on accident. This will cause ownership to change to root on some log files. Then when you log back on as user jasper and restart your server, the Apache logs are filling with messages about not being able to write files. Jasper is just not working properly. Run the following command to restore the proper ownership to all files in the Jasper directory. You must run the following command as root:

>find /home/jasper/jasper-server-3.7 -user root -exec chown jasper.jasper {} \;

This will find all the files that root changed ownership and change the ownership back to the proper jasper user.

Linux overwrites DNS resolver /etc/resolv.conf

Linux will overwrite your /etc/resolv.conf in 3 cases. If you have:

  1. Network Manager enabled.
    Disable the Network Manager by turning it off with the following commands:
    >service NetworkManager stop
    >chkconfig NetworkManager off        

  2. DHCP enabled.
    dhcpd will overwrite your /etc/resolv.conf when it acquires an IP address. Convert to a static IP if you are in control of the network.
  3. DNS1, DNS2 or any other DNS# entries in any of your network interface configurations.
    If you are the administrator of this machine, check every file matching the following pattern:
    >find /etc/sysconfig/network-scripts/ifcfg-*
    and look for any DNS# entries in every matching file. If you find any DNS# lines, and if you are root, remark the lines by inserting a # sign at the beginning of the DNS# line.
    Save the file(s) lipitor cost.
    Then run –>
    >service network restart

Once you’ve gone through these 3 items, you should be able to now edit and save your /etc/resolv.conf file. Verify that the file no longer is being overwritten. Just execute >cat /etc/resolv.conf a few times for a few minutes and verify the file is no longer changing. Also >reboot the machine to be extra sure nothing changes in the /etc/resolv.conf file.

Determining a devices WWID in Linux

For multipath drivers connecting to storage area networks (SAN), it is useful in your /etc/multipath.conf to blacklist devices. This prevents the multipath driver from attempting to use the device(s).

To find out a drive’s WWID, run the following command:

>scsi_id -g -u -s /block/sda

This will return a WWID. On my system it was returned as 36001e4f034bf55000f98fe8606dc88df.

Now you can put this in the blacklist section of /etc/multipath.conf as:

blacklist {
devnode “^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*”
devnode “^hd[a-z]”
devnode “^sda”
devnode “^sda[0-9]”
devnode “^sdb”
devnode “^sdb[0-9]”
wwid    “36001e4f034bf55000f98fe8606dc88df”
device {
vendor DELL
product “PERC|Universal|Virtual”

This will now prevent the multipath driver from attempting to manage /dev/sdc.

Finding a count of files in a directory

In Linux, you can count all of the files in a directory, of a given type.

To do this run:

>find . -maxdepth 1 -type f -name “*.gz” | wc -l

If you want to count all of the gzipped files in all directories below your current directory. Run the same command without the -maxdepth:

>find . -type f -name “*.gz” | wc -l

Everything relies on the wc command, which is short for word count. We are counting the line by line output from the find command.

If you want to count the number of directories, try this:

>find . -type d | wc -l

Just remember to subtract 1 from the output. Linux will include the current directory (.) as a directory.

Starting a user’s VNC server automatically on Linux

On some Linux systems, it can be advantageous for users to have a way to login to a console. Unfortunately, if they do not have physical access to the machine, there needs to be a way to do it remotely. Fortunately on Linux, there is Virtual Network Computing (VNC). VNC can be set up as a server and I will outline the steps necessary to complete this task.

First, ensure that vncserver is installed on your system. For Red Hat systems type:

>yum list vnc-server

If you see the following message:

Loaded plugins: rhnplugin
Error: No matching Packages to list

You will  need to install vncserver. Using Yum again:

>yum -y install vnc-server

We can now begin configuring VNC. We are going to do this for two users, root and myuser. Each user will access their virtual desktop from separate Internet Protocol ports. Vtxinst will use port 5801 and root will use port 5802.

We first need to edit /etc/sysconfig/vncservers. On line that has

# VNCSERVERS=”2:myusername”

Change it to

VNCSERVERS=”1:myuser 2:root”

Save the file. Now we need to prime VNC to setup its supporting files correctly. Login first as root, then myuser and issue the following command:


You will be prompted for a password if this is the first time this user has started VNC. Then run the following command to stop vncserver:

>vncserver -kill :1

Next let’s edit the user’s ~/.vnc/xstartup so that we use the gnome desktop instead of X windows. In the user’s directory, edit the file ~/.vnc/xstartup and uncomment the following 2 lines by removing the # so that the two lines look like the following:

exec /etc/X11/xinit/xinitrc

Finally, enable vncserver on startup with the following command:

>chkconfig –levels 35 vncserver on

Now, next time you reboot, VNC server will start automatically. If you don’t want to reboot, then run:

>service vncserver start

And VNC server will now be running!

Auto commit for MySQL databases

In corporate database systems, it is generally preferred to build transaction stacks. This allows for having multiple database statements run and be finally committed if everything is ok. In MySQL, auto commit is on by default; which means that every statement is instantly committed. To check the value of auto commit, run the following MySQL command:

mysql>select @@autocommit;

So in order to turn off auto commit, run the following command in MySQL:

mysql>SET autocommit=0

If you want auto commit turned off permanently, we need to edit your my.cnf file. In the [mysqld], add the following line:

init_connect='SET autocommit=0'

Restart MySQL and you are now ready to do full transaction processing.

Error in /etc/fstab stopping Linux boot

In Linux, there are times when you need to edit your /etc/fstab file to add a new disk. Sometimes, you may accidentally edit the wrong information which will cause Linux to not boot. Usually though, Linux plays nice and boots to a command prompt. Unfortunately, you are now booted into a read-only filesystem so you are unable to save your /etc/fstab.

What you need to do is first set the operating system to read/write (r/w). To do this run the following command:

>mount -o remount,rw /

If /etc is on a different volume, then run this command (replace /dev/sda1 with your /etc volume):

>mount -t ext3 /dev/sda1 / -o remount,rw

Some people have complained about kernels that are not compiled to support the reldiratime option. If you are still having trouble editing and saving /etc/fstab, try this:

>mount -o remount,defaults /

You should now be able to edit and save your /etc/fstab file and reboot and have Linux back again!

Changing the host name in IBM WAS

Many times in a virtual environment, it is advantageous to be able to change the host name. But if you have a virtual guest with IBM WAS installed, cloning the guest may result in the new guest being unable to stop the server, run CORBA properly, or gain access to your message queues within WAS. Therefore, you need to reset the host name for WAS.

To do this, go to the prompt. If you don’t know where is, run >locate Then change directory (cd) into the directory that locate returned. To start WAS admin, type the following commands (assuming your server is called server1 and the node is named oldMachineNameNode01):

./ -profile server1 -lang jacl

Once inside the WAS admin tool, run the following commands:

wsadmin>$AdminTask changeHostName { -nodeName oldMachineNameNode01 -hostName newwasVMmachineName };
wsadmin>$AdminConfig save

Restart WAS, and your new machine name should work fine.