Technix
Technology Weblog

Mar
12

Sometimes RPM databases become corrupt. You will no longer be able to install/upgrade/remove programs using YUM or RPM command. Even RPM quey simply gets hung. This is the case when you need to repair RPM databases. You can use the simple script to do it.

cp -pr /var/lib/rpm{,`data +%F`.bk}
rm -f /var/lib/rpm/__db*
rpm -vv –rebuilddb

The first step is take a backup of  ‘ /var/lib/rpm‘ directory. Second clear the RPM database. Last rebuild database in in verbose mode so that you see the process taking place. Now your RPM database is perfect.

You can just check following command to confirm this.

rpm -qa

Jan
01

Happy New Year to all !!!

Aug
11

The most popular torrent client uTorrent has relesed a new version with significant improvements. uTorrent latest release provides

  • Full Vista support!
  • IPv6 support
  • Fixes several bugs and numerous enhancements

You can download it from uTorrent site

Jul
28

System beeps every time you press the backspace key one too many times, or just using emacs, can be quite disturbing.

To shut them off:
Just open your .bashrc file.

vi ~/.bashrc

and add the following
xset b off
xset b 0 0 0

Jun
19

man pages are great help for learing new commands in *nix systems. There will be hardly any unix user who have not used it .

When learning about new commands or options of commands using man pages it is a annoyance that man page contents get cleared on quiting man. We can change this behiavior man by changing the default PAGER.

The default PAGER user by man is less. To change the behavior of man we can change the PAGER to more. You can do this by adding following line to .bashrc file in your home directory.

export PAGER=/bin/more

If you want to change man page behavior permanently you will have to edit PAGER value in /etc/man.config

Mar
04

Everyone using Linux will like to use it to navigate easily between directories. Add the following code into .bashrc file. Now you can navigate foward and backward using cd ] and cd [ .

Cool !

    __COUNT=0 __BACK=0 cd () { if [ "${1}" = "[" ]; then if [ "${__BACK}" -lt "${__COUNT}" ]; then pushd +1 > /dev/null __BACK=$(($__BACK+1)) else echo "can't go back any more" fi elif [ "${1}" = "]" ]; then if [ "${__BACK}" != 0 ]; then pushd -0 > /dev/null __BACK=$(($__BACK-1)) else echo "can't go forward any more" fi elif [ "${1}" = "." ]; then builtin cd "${@}" else if [ "${1}" = "-" ]; then pushd "${OLDPWD}" > /dev/null elif [ "${#}" -eq 0 ]; then pushd "${HOME}" > /dev/null else pushd "${@}" > /dev/null fi while [ "${__BACK}" -gt 0 ]; do popd -0 > /dev/null __BACK=$(($__BACK-1)) done __COUNT=$(($__COUNT+1)) fi }

Add above code to .bashrc .

Feb
21

Consider the case you forgot the root password of your Linux machine. Don’t panic !

You can reset it easily entering single user mode . Following are the run levels in linux.

Runlevel 0: Halt System – To shutdown the system
Runlevel 1: Single user mode
Runlevel 2: Basic multi user mode without NFS
Runlevel 3: Full multi user mode (text based)
Runlevel 4: unused
Runlevel 5: Multi user mode with Graphical User Interface
Runlevel 6: Reboot System

Following are the steps to reset password.

1. Restart the machine.

2. Wait for the “Grub loading” message to appear and, depending on your Linux distribution, get ready to hit either any key or the ESC key to enter the grub boot menu.

Grub loading, please wait ...
Press ESC to enter the menu

3. You will then get grub’s main menu which will display a list of available kernels. Use the arrow keys to scroll to your desired version of the kernel and then press e for “edit”.

Fedora Core (2.6.18-1.2239.fc5smp)
Fedora Core (2.6.18-1.2200.fc5smp)

4. The kernel’s boot menu will appear. Use the arrow keys to scroll to the “kernel” line and then press e for “edit”.

root (hd0,0) kernel /vmlinuz-2.6.18-1.2239.fc5smp ro root=LABEL=/ initrd /initrd-2.6.18-1.2239.fc5smp.img

5. A grub edit prompt will appear. Use the arrow keys to move to the end of the line and add the word “single” to the end, separated by a space. Change

grub edit> kernel /vmlinuz-2.6.18-1.2239.fc5smp ro root=LABEL=/

to following

grub edit> kernel /vmlinuz-2.6.18-1.2239.fc5smp ro root=LABEL=/ single

6. Press enter to save your changes, and then b for “boot”. 6. The system will continue to boot, but will go straight to the root # prompt without first asking for a username and password.

7. Now change the password using passwd command.

#passwd <give your new password>

8. Change the run-level using init command.

# init 5

( for Multi user mode with Graphical User Interface)

That’s it !

Jan
18

Running PHP4 and PHP5

There are many times when we need PHP4 and PHP5 to run concurrently on the server.In such cases we can Install one as apache module and other as CGI

Install PHP4 or PHP5 as apache module. Lets install PHP5 as apache module

Download PHP5 untar it and move to its directory.

  1.  ./configure --with-apxs=/usr/local/apache/bin/apxs
  2.  make
  3.  make install

If file /usr/local/apache/modules/libphp5.so does not exist or is an older version, type this from PHP source code directory.

 4 cp -p .libs/libphp5.so /usr/local/apache/modules

5 copy php.ini-recommended from PHP source code directory to installation directory.

6 Add following to http.conf

LoadModule php5_module        modules/libphp5.so
AddHandler php5-script php
DirectoryIndex index.html index.php
AddType text/html       php

Now install PHP4 as CGI

Download PHP4 untar it and move to its directory.

1 ./configure --prefix=/home/somedir/php4 --enable-force-cgi-redirect --program-suffix=4

–enable-force-cgi-redirect- Enable the security check for internal server redirects. Not enabling option disables the check and enables bypassing httpd security and authentication settings.

–program-suffix -adds the given suffix.

2 make
3 make install

4 Add following to http.conf

ScriptAlias /cgi-sys/ /usr/local/cgi-sys/
Action application/x-httpd-php5 "/cgi-sys/php-cgi5"
AddHandler application/x-httpd-php5 .php5

Restart Apache. And now you use PHP4 and PHP5 concurrently !

Jan
13

Most of the websites have site specific search (eg: arstechnica.com). We can use the keyword option in Firefox for quickly searching such websites.

1. Visit the website we need to search using Firefox.( For example arstechnica.com or any site having search option )
2. Right click within the search box.
3. Select “Add a Keyword for this Search” option in right click menu.
4. Give your search a Name and Keyword. ( For example for arstechnica.com search I gave “ars” as keyword ).
5. Now to search the site, open a new tab and type your search Keyword followed by search string ( let’s try searching Linux here ) in location bar( Ctrl + L) . (example: “ars linux”).

Dec
27

shopt is a built-in command that controls shell behavior. In order to customize our shell environment we add the shopt commands to our .bashrc file.

shopt -s cdspell

This will correct the typing mistakes for cd command. eg: We need to go to directory testing/default. But by mistake type

# cd tesring/default
testing/default

Since we have set cdspell this typing error will be corrected and we will be directed to the correct directory.

Follow

Get every new post delivered to your Inbox.