Issue #19 May 2006

Tips & tricks

Red Hat's customer service and support teams receive technical support questions from users all over the world. As they are received, Red Hat technicians add the questions and answers to Red Hat Knowledgebase on a daily basis. Access to Red Hat Knowledgebase is free. Every month, Red Hat Magazine offers a preview into the Red Hat Knowledgebase by highlighting some of the most recent entries.

Tips from RHCEs

Follow-up tip: Unkillable processes

Before Red Hat Enterprise Linux 4, there really wasn't a good way to handle processes that had entered an uninterruptible sleep waiting on an unresponsive NFS server. This was particularly frustrating because the umount man page promises that '-f' will "Force unmount. This allows an NFS-mounted filesystem to be unmounted if the NFS server is unreachable." With the caveat that the filesystem must have originally been mounted with "soft" or "intr" options. Well, no more. Though the man page doesn't say so, umount -f now comes to the rescue and will unmount hard and uninterruptible mounts.

How can I customize the automatically generated directory listings Apache creates?

The mod_autoindex module is used for automatic directory listings.

All of these options can be added in a virtual host section, a directory section, or in the main configuration section. These can be added to the bottom of /etc/httpd/conf/httpd.conf file.

To add comments for all files of the same type, add:

AddDescription "This is a text file" .txt

This would add the description "This is a text file" to any file that ended in the .txt extension.

To add a description for a particular file:

AddDescription "Our financial report" docs/finances.txt

This would add the description "Our financial report" to the docs/finances.txt file.

To have the index ignore some files, add:

IndexIgnore  docs/hidden.txt

Now when the directory listing of docs is viewed, it will not show the file hidden.txt.

For other available options see http://httpd.apache.org/docs/1.3/mod/mod_autoindex.html.

Where is the configuration file to modify the default dpi fonts?

Symptom:
It is desired to change the default 75 dpi fonts to recently installed 100 dpi fonts.

Solution:
The configuration file is: /etc/X11/fs/config.

Edit the /etc/X11/fs/config file, look for the following line:

default-resolutions=75,75,100,100

Change the line to read:

default-resolutions=100,100,75,75

Save the changes to the file. The new defaults should take effect after xfs (X Font Server) has been restarted.

How can the display resolution be changed without restarting the X Windows server?

The xrandr utility provides this functionality. To see a list of supported resolutions that xrandr can switch to, execute the xrandr command.

A list of resolutions will be displayed:

 SZ:    Pixels          Physical       Refresh
 0   1600 x 1200   ( 363mm x 272mm )   75
*1   1280 x 1024   ( 363mm x 272mm )  *85
 2   1024 x 768    ( 363mm x 272mm )   85
 3    800 x 600    ( 363mm x 272mm )   85
 4    640 x 480    ( 363mm x 272mm )   85
Current rotation - normal
Current reflection - none
Rotations possible - normal
Reflections possible - none

The current resolution is indicated by an asterisk ('*'). For this system, the current resolution is 1280x1024.

To change the resolution, execute xrandr -s 0 where 0 is the number of the desired resolution.

For example, xrandr -s 3 would change the resolution on this system to 800x600). The listed resolutions will not necessarily be the same across systems, meaning xrandr -s 2 on one system may not display the same resolution as it would on a different system.

Why is the system still prompting for a password after setting up DSA authentication for SSH?

By monitoring the output of /var/log/secure on the server, the error messages might be able to help determine what exactly is causing the DSA authentication to fail. After trying to SSH from the client system to the SSH server system, log at the log file:

tail /var/log/secure

One common error may be the following:

sshd[11425]: Authentication refused: bad ownership or modes for directory /home/shadowman

In this instance, the permissions on shadowman's home directory were too open. To change them, execute chmod 700 /home/shadowman to set shadowman's home directory permissions.

How can I increase the number of semaphores?

Release Found: Red Hat Enterprise Linux

Symptom:
A Red Hat Enterprise Linux Server running Lotus Domino crashes after about a day or so of running. Using the ipcs command it was discovered that the server crashes once Domino has used 100 out of 128 semaphores.

Solution:
Before beginning, check the defaults so they can be referenced later. To view the current semaphore settings, use the cat command:

# cat /proc/sys/kernel/sem
250     32000   32      128

The following is an example of how to make these adjustments permanent.

Edit the /etc/sysctl.conf file by adding:

kernel.sem = 250 32000 32 256

Note: the '=' (is (space)=(space)) - spaces are important in this file. There should be a space before and after the equals (=) sign.

Issue the sysctl -p command to make these changes take effect immediately. Setting the values in this file will also save them for future system reboots.

How can I change the behavior of the copy (cp) command when it asks if I want to overwrite the existing file, even though I passed it the "-f" argument?

Symptom:
The command cp -f <filename> </path/to/some_existing_file> ask to overwrite the existing file, even though the -f argument was passed.

Solution:
To change this behavior, edit the /root/.bashrc file and comments out (or remove) the alias line that adds the -i argument to the cp command:


# alias cp='cp -i'

The changes should take affect when a new user session is started or the /root/.bashrc file has been sourced in the current session.

Update:

Several astute readers mailed us with refinements for this response. Here's what they had to say:

There's a reason why cp is aliased to cp -i in _root's_ .bashrc and .cshrc/.tcshrc (.cshrc and .tcshrc are not mentioned in the original response). After all, do you really want root to be able to overwrite a file without checking?

There is a way around the problem that retains the copy protections in root's shell. Here's how:

$ \cp -f <filename> <path/to/existing_file>

Backslashing the command temporarily avoids the alias done in the shell but does not permanently remove the protection.

$ alias
alias cp='cp -i'
  [snip other aliases]
$ cd /tmp
$ touch test
$ touch test2
$ cp test test2
cp: overwrite `test2'? n
$ cp -f test test2
cp: overwrite `test2'? n
$ \cp test test2
$

Thanks to all our readers who mailed in with comments and corrections on this point.

What is the difference between /dev/st0 and /dev/nst0 when considering tape devices?

The /dev/nst0 device is a non rewinding tape device, where as the /dev/st0 device is a rewinding tape device.

The device you choose to use depends on your goal. Both devices are for the same piece of hardware but they behave differently. If, for instance, you are just going to tar some files to a tape then you would use the rewinding device so that the tape was rewound after being written to. In this case, the tape would be ready to be read whenever you needed it.

Alternatively, most higher-end backup applications write multiple files to the same tape, so you would use the non-rewinding tape device (i.e. /dev/nst0) for this purpose. If you used a rewinding device then the tape would be rewound after writing each file to the tape and the next file would overwrite the one just written.

How do I rename a RAID array if I need to move the RAID array to another system, which already has an array with the same name?

In the following example, /dev/md0 is the original and /dev/md6 is the new md device. /dev/sda5 and /dev/sdb5 are the two partitions that make up the RAID device. This can be done with the following commands:

 
# mdadm --stop /dev/md0
# mdadm -A /dev/md6 -m0 --update=super-minor /dev/sda5 /dev/sdb5

This stops the array as /dev/md0 and then reassembles it as /dev/md6. The reassembly looks for devices which have an existing minor number of 0, not 6 (-m0), and then updates the minors in the superblocks to the new number.

Why is performance significantly less in my Clearcase application in Red Hat Enterprise Linux 3 compared to Red Hat Enterprise Linux 4 when accessing an NFS share?

This problem arises due to open to close cache consistency feature which was added to kernel-2.4.20. This feature was introduced to ensure cache coherency among different NFS clients. When an application on a NFS client opens a file stored on a server, the client checks for the existence of the file and its permissions by sending a GETATTR call. When the file is being closed, any changes are written to the server so that the next client viewing the file can see the changes. The open to close cache consistency feature is implemented by comparing the results of GETATTR just after a file is closed and just before the same file is opened. If the results are the same, the client's cache is valid, else the cache is purged.

The GETATTR calls reduce the performance because of the huge amount of network traffic that it generates. This can be avoided by using the mount option nocto. However, this would only come at a cost of the integrity of the data because it breaks the cache inconsistency if there are several clients accessing the same file. The other option is to use Red Hat Enterprise Linux version 4. Kernel 2.6 uses a different mechanism to ensure data consistency.

The information provided in this article is for your information only. The origin of this information may be internal or external to Red Hat. While Red Hat attempts to verify the validity of this information before it is posted, Red Hat makes no express or implied claims to its validity.

This article is protected by the Open Publication License, V1.0 or later. Copyright © 2006 by Red Hat, Inc.