Fix corrupted RPM database on CentOS 5 / Redhat enterprise Linux 5 / Fedora 7

Posted on in Categories CentOS, Linux, Linux distribution, RedHat/Fedora Linux, Tip of the day last updated July 25, 2007

If rpm / yum command hangs during operations or you see error messages – it means your rpm database corrupted. /var/lib/rpm/ stores rpm database just delete the same and rebuild rpm database:

Command to rebuild rpm database

rm -f /var/lib/rpm/__db*
rpm --rebuilddb

Read rpm / yum man pages for more information

Repeat last shell command that started with a particular word

Posted on in Categories Shell scripting, Tip of the day, Tips, UNIX last updated July 8, 2007

Bash / CSH shell offers command history feature. Most of you may be aware and using of UP / DOWN arrow keys to recall previous commands. History expansions introduce words from the history list into the input stream, making it easy to repeat commands, insert the arguments to a previous ommand into the current input line, or fix errors in previous commands quickly.

To repeat last command that started with bar word type i.e. refer to the most recent command starting with string bar):
! bar

For example, let us run lighttpd to test config file:
# /usr/sbin/lighttpd -t -f /jail/usr/local/etc/lighttpd/lighttpd.conf

Syntax OK

Type few commands:
# pwd
# date

Now to repeat last command that started with lighttpd word type
# !lighttpd

lighttpd -t -f /jail/usr/local/etc/lighttpd/lighttpd.conf
Syntax OK 

Want to refer to the previous command, just enter

Related shell tip

Troubleshooting tip: Lan card (NIC) ordering changed after upgrading to Redhat (RHEL) Linux 4.5

Posted on in Categories CentOS, Linux, Linux distribution, RedHat/Fedora Linux, Sys admin, Tip of the day, Troubleshooting last updated June 15, 2007

If you are running Dell PowerEdge 2950 server or HP ProLiant BL480c G1 server and upgraded from old version to latest Red Hat Enterprise Linux ES release 4.5 (Nahant Update 5) you will notice that ordering of your NIC devices changed.

Fix problem before upgrade:

Before running upgrade via up2date command open /etc/sysconfig/network-scripts/ifcfg-eth0 file (for NIC 0) and add line

Now proceed to upgrade using up2date -u
# up2date -u

Howto fix problem after upgrade:

However chances are very high that after running up2date -u command (i.e. after upgrade) you may notice the problem. Don’t panic. Open grub.conf file:
# vi /etc/grub.conf

Find out current kernel line:
kernel /vmlinuz-2.6.9-55.ELsmp ro root=LABEL=/ console=tty0 console=ttyS1,19200n8

Replace as follows:
kernel /vmlinuz-2.6.9-55.ELsmp ro root=LABEL=/ console=tty0 console=ttyS1,19200n8 pci=nobfsort

The pci=nobfsort option restore the original Kernel 2.6 ordering.

A final note

This problem is not Redhat specific. It can occurred on Suse or any other Linux distribution. Please see Linux enumeration of NICs solution published by Dell for more information.

Howto: Prevent a Linux kernel module from auto loading

Posted on in Categories CentOS, Debian Linux, Howto, Linux, RedHat/Fedora Linux, Sys admin, Tip of the day, Troubleshooting last updated June 13, 2007

In some situation you may want to avoid loading a Linux driver module automatically . For example:
[a] You would like to use proprietary device driver (I’m against any sort of proprietary drivers) and not inbuilt (reverse engineer) kernel driver.

[b] If your server system connected without a diskette / floppy drive; kernel will try to load floppy driver – disable floppy driver or module.

[c] In some cases buggy driver causes kernel BUG on load so you just want to avoid the problem.

The Linux kernel get module information from /etc/modprobe.conf file and /etc/modprobe.d/* file(s).

If you are using CentOS/Redhat/RHEL/Fedora Linux…

Just open your /etc/modprobe.conf file and turn of auto loading using following syntax:
alias driver-name off

If you are using Debian / Ubuntu Linux…

open /etc/modprobe.d/blacklist file and add drivername using following syntax:
blacklist driver-name

Reboot your box and use lsmod command to show the status of modules in the Linux Kernel.

Shell tip: change to a directory having very long name

Posted on in Categories Howto, Linux, Shell scripting, Tip of the day, Tips, UNIX last updated June 6, 2007

Let us say your have a long directory name called “A_VERY_ VERY LONG_ DIRECTORY_NAME_TO_ TYPE _ A _ B _C”…

So how do you change to a directory, which is having very long name without typing full name?

Simply use a wildcard character called * as follows

Or type cd A_VERY and hit tab key to complete a directory name :)
$ cd A_VERY_VERY (hit tab key)

Linux turn OFF password expiration / aging

Posted on in Categories Debian Linux, Howto, Linux, RedHat/Fedora Linux, Security, Suse Linux, Sys admin, Tip of the day, Tips, Troubleshooting, Ubuntu Linux last updated June 1, 2007

/etc/shadow stores actual password in encrypted format for user’s account with additional properties related to user password.

The password expiration information for a user is contained in the last 6 fields. Password expiration for a select user can be disabled by editing the /etc/shadow file

However I recommend using chage command. The chage command changes the number of days between password changes and the date of the last password change. This information is used by the system to determine when a user must change his/her password.

To list current aging type chage command as follows:
# chage -l vivek

Last password change                                    : May 22, 2007
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7

To disable password aging / expiration for user foo, type command as follows and set:
Minimum Password Age to 0
Maximum Password Age to 99999
Password Inactive to -1
Account Expiration Date to -1
Interactive mode command:
# chage username
# chage -I -1 -m 0 -M 99999 -E -1 username

Updated for accuracy.

Ubuntu Linux configure Viewsonic VG1930WM 19″ widescreen LCD for 1440×900 resolution

Posted on in Categories Debian Linux, Howto, Linux desktop, Linux distribution, Tip of the day, Tips, Troubleshooting, Tuning, Ubuntu Linux last updated August 24, 2007

As I said earlier you need to tweak few things to run this monitor with Intel 810 or 845 based chip-set under Ubuntu Linux.

In order to use higher resolution install updated Intel i8xx, i9xx display driver. It is provided by a package called xserver-xorg-video-intel. This package provides the driver for the Intel i8xx and i9xx family of chipsets, including i810, i815, i830, i845, i855, i865, i915, and i945 series chips.

Replace driver by running the apt-get command. Open your terminal and type command:
$ sudo apt-get install xserver-xorg-video-intel

Now run ddcprobe command to get monitor VertRefresh values and HorizSync rate:
$ sudo ddcprobe | grep monitorrange

monitorrange: 24-82, 50-75

24-82 is your HorizSync rates and the second pair is your VertRefresh (50-75) values.

Next reconfigure xserver ( video and monitor using auto detect feature:
$ sudo dpkg-reconfigure xserver-xorg

Set monitor resolution 1440 x 900 and others as per your requirement. Save the changes and reboot the system.

After login you can adjust screen resolution by visiting System > Preferences > Screen Resolution > Select desired screen resolution such as 1440 x 900 and save the changes.