Monday, November 18, 2013

HOWTO Force a Filesystem check (fsck) on the next boot

There are 2 easy ways to force a fsck on the next boot sequence:

1.Creating /forcefsck file will force the Linux System to perform a full FSCK on the next boot sequence:

Login as root and run the following commands:

touch /forcefsck
reboot

2. Force fsck on the next boot using the "shutdown" command:

Login as rot and run the following command:

shutdown -rF now

Where the "-F" option will force the System to run a full fsck on boot.

Wednesday, October 2, 2013

HOWTO Remove/Uninstall Perl Modules

I've been struggling on this matter, and the solution below is what it helped me to cleanly Remove/Uninstall Perl Modules.


To Uninstall PERL Modules we will need first to Install App::pmuninstall

Also, we will need to install the library: libjson-perl if it's not already installed in your server.
root@anneke:~# apt-get install libjson-perl

Install App::pmuninstall module

To install the module we will use this command:
root@anneke:~# perl -MCPAN -e shell
 

Terminal does not support AddHistory.
cpan shell -- CPAN exploration and modules installation (v1.9800)
Enter 'h' for help.
cpan[1]>install App::pmuninstall

... [output trunked]

cpan[2]>quit


Usage:

pm-uninstall [options] Module ...
options:
  -v,--verbose                  Turns on chatty output
    -f,--force                    Uninstalls without prompts
    -c,--checkdeps                Check dependencies (defaults to on)
    -n,--no-checkdeps             Don't check dependencies
    -q,--quiet                    Suppress some messages
    -h,--help                     This help message
    -V,--version                  Show version
    -l,--local-lib                Additional module path
    -L,--local-lib-contained      Additional module path (don't include non-core modules)


Example:

root@anneke:~# pm-uninstall DBD::Oracle

Hope that helps! ;)

Wednesday, September 11, 2013

HOWTO Install MATE on your Linux OS

Hopefully, for the ones that miss the old Gnome style, this is what you're looking for, this is "THE" Desktop that you'll want to try and with the one you'll stick.

I took this post from the MATE wiki: http://wiki.mate-desktop.org/ where you can find Documentation, Support and of course, the Development section. Don't forget to visit :)




How to Install MATE in different distros



Debian


Debian Wheezy: add one of the following repositories to your /etc/apt/sources.list:

# main repository
deb http://repo.mate-desktop.org/debian wheezy main

# mirrors
deb http://packages.mate-desktop.org/repo/debian wheezy main
deb http://mirror1.mate-desktop.org/debian wheezy main



Debian Jessie: add one of the following repositories to your /etc/apt/sources.list:

# main repository
deb http://repo.mate-desktop.org/debian jessie main

# mirrors
deb http://packages.mate-desktop.org/repo/debian jessie main
deb http://mirror1.mate-desktop.org/debian jessie main


 

To install MATE:

apt-get update
apt-get --yes --quiet --allow-unauthenticated install mate-archive-keyring
apt-get update
# Now to install MATE choose 1 of the 3 apt-get lines below.
# this installs the base packages
apt-get install mate-core
# or this to install mate-core and more extras
apt-get install mate-desktop-environment
#or this to install mate-core + mate-desktop-environment and even more extras.
apt-get install mate-desktop-environment-extra




Ubuntu


Ubuntu Precise Pangolin (12.04) repository

Add ONE of the following repos to /etc/apt/sources.list via the following command:

sudo add-apt-repository "deb http://packages.mate-desktop.org/repo/ubuntu precise main"

sudo add-apt-repository "deb http://repo.mate-desktop.org/ubuntu precise main"

or using a text editor of your choice add the ONE following mirrors to /etc/apt/sources.list:

deb http://packages.mate-desktop.org/repo/ubuntu precise main
deb http://repo.mate-desktop.org/ubuntu precise main


Ubuntu Quantal Quetzal (12.10) repository

Add ONE of the following repos to /etc/apt/sources.list via the following command:

sudo add-apt-repository "deb http://packages.mate-desktop.org/repo/ubuntu quantal main"

sudo add-apt-repository "deb http://repo.mate-desktop.org/ubuntu quantal main"

or using a text editor of your choice add the ONE following mirrors to /etc/apt/sources.list:

deb http://packages.mate-desktop.org/repo/ubuntu quantal main
deb http://repo.mate-desktop.org/ubuntu quantal main


Ubuntu Raring Ringtail (13.04) repository

Add ONE of the following repos to /etc/apt/sources.list via the following command:

sudo add-apt-repository "deb http://packages.mate-desktop.org/repo/ubuntu raring main"

sudo add-apt-repository "deb http://repo.mate-desktop.org/ubuntu raring main"


sudo add-apt-repository "deb http://mirror1.mate-desktop.org/ubuntu raring main"


or using a text editor of your choice add the ONE following mirrors to /etc/apt/sources.list:

deb http://packages.mate-desktop.org/repo/ubuntu raring main
deb http://repo.mate-desktop.org/ubuntu raring main
deb http://mirror1.mate-desktop.org/ubuntu raring main




MATE Installation (Precise/Quantal/Raring)

Then run the following command to update your repositories and install MATE:

sudo apt-get update
sudo apt-get --yes --quiet --allow-unauthenticated install mate-archive-keyring
sudo apt-get update
# this installs base packages
sudo apt-get install mate-core
# this installs more packages
sudo apt-get install mate-desktop-environment




Salix/Slackware


Salix
Salix 13.37 users only need to run:
slapt-get --install-set mate


Slackware
Slackware users can install Mate using the packages in the Salix repositories.
Slackware 13.37 users can manually grab the packages from the following locations:

i486 mirrors
ftp://ftp.slackware.org.uk/salix/i486/13.37/salix/mate
http://salix.enialis.net/i486/13.37/salix/mate/
http://download.salixos.org/i486/13.37/salix/mate/
http://mirrors.nix.org.ua/linux/salixos/i486/13.37/salix/mate

x86_64 mirrors
ftp://ftp.slackware.org.uk/salix/x86_64/13.37/salix/mate
http://salix.enialis.net/x86_64/13.37/salix/mate/
http://download.salixos.org/x86_64/13.37/salix/mate/
http://mirrors.nix.org.ua/linux/salixos/x86_64/13.37/salix/mate

Slackware users should also install the following packages that are needed and which are not included in a full Slackware installation:

cairomm glibmm gtkmm libcanberra libgtop libsigc++ libsoup libunique pangomm upower

All of these packages are also available from the Salix repositories.


Source code tarballs:
You can download MATE source code tarballs on pub.mate-desktop.org: http://pub.mate-desktop.org/releases/

GIT Repository:
Get from https://github.com/mate-desktop/. See Building for more information.

Friday, September 6, 2013

HOWTO Recover/Reset MySQL root Password

To recover the MySQL database server password you can perform the following steps:


1. Stop MySQL service:
root@anneke:~# /etc/init.d/mysql stop
Stopping MySQL database server: mysqld.
root@anneke:~#



2. Start MySQL service without password:
root@anneke:~# mysqld_safe --skip-grant-tables &
[1] 5678
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6543]: started
root@anneke:~#



3. Connect to MySQL server:
root@anneke:~# mysql -u root
 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>



4. Setup new MySQL root user password:
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit



5. Stop MySQL Service:
root@anneke:~# /etc/init.d/mysql stop
 
Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6663]: ended
[1]+  Done                    mysqld_safe --skip-grant-tables

root@anneke:~#



6. Start MySQL service and test the new password:
root@anneke:~# /etc/init.d/mysql start
root@anneke:~# mysql -u root -p


Thursday, August 8, 2013

HOWTO LVM

LVM stands for Logical Volume Manager.

With LVM, we can create Logical Partitions that can span across one or more Physical hard drives. The hard drives are divided into Physical Volumes (PV), then those Physical Volumes are combined together to create the Volume Group (VG) and finally the Logical Volumes (LV) are created from Volume Group to, at the end, be able to create your Filesystem.

Before proceed, we need install the lvm2 package, which mostly is not installed by default on a basic Debian distribution.

ximena@anneke:~$ sudo apt-get intall lvm2

To create a LVM, we need to run through the following steps:
  •     Select and create the Physical Partitions (PV)
  •     Create the Volume Group
  •     Create Logical Volumes

Select and Create the Physical Storage Devices

In this step, we need to choose the Physical Volumes that will be used to create the LV. We can create the physical volumes using pvcreate command, but before, we will check our current partitions:

ximena@anneke:~$ sudo fdisk -l

Disk /dev/sda: 600.1 GB, 600093712384 bytes
255 heads, 63 sectors/track, 72957 cylinders, total 1172058032 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disk identifier: 0x000c8553

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *         512      292863      146176   83  Linux
/dev/sda2          292864    15918079     7812608   82  Linux swap / Solaris
/dev/sda3        15918080   211230719    97656320   83  Linux
/dev/sda4       211231230  1172057599   480413185    5  Extended
Partition 4 does not start on physical sector boundary.
/dev/sda5       211231232   406543359    97656064   83  Linux
/dev/sda6       406543872  1172057599   382756864   83  Linux

ximena@anneke:~$

Now I know that /dev/sda6 is the free space that will be used for my PV.

I can also check the structure of my HDD by running:

ximena@anneke:~$ sudo lsblk
NAME                           MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                              8:0    0 558.9G  0 disk
├─sda1                           8:1    0 142.8M  0 part /boot
├─sda2                           8:2    0   7.5G  0 part [SWAP]
├─sda3                           8:3    0  93.1G  0 part /
├─sda4                           8:4    0     1K  0 part
├─sda5                           8:5    0  93.1G  0 part /var
└─sda6                           8:6    0   365G  0 part
ximena@anneke:~$


Which give us a more "friendly" output.

Now, it's time to create our PV

ximena@anneke:~$ sudo pvcreate /dev/sda6
Physical volume "/dev/sda6" successfully created
ximena@anneke:~$


As shown above one PV (physical Volume) is created: /dev/sda6.

If the physical volumes is already created, you can view it using the pvscan and pvdisplay command:

ximena@anneke:~$ sudo pvscan
  PV /dev/sda6   VG lb01   lvm2 [365.02 GiB / 350.02 GiB free]
  Total: 1 [365.02 GiB] / in use: 0 [0] / in no VG: 1 [365.02 GiB]
ximena@anneke:~$


You can view the list of PVs with attributes like Size, Physical Extent Size, Total Physical Extent Size, the Free Space, etc., using pvdisplay command:

ximena@anneke:~$ sudo pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda6
  VG Name               lb01
  PV Size               365.03 GiB / not usable 2.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              93446
  Free PE               89606
  Allocated PE          3840
  PV UUID               Q0e3tN-McgT-FBqI-2MAh-BZjr-Rvoj-57FuG9
  
ximena@anneke:~$


Note: PE stands for: Physical Extents, and they are nothing but equal-sized chunks. The default size of extent is 4MB.

Creating a Volume Group


Volume groups are a pool of storage that consists of one or more physical volumes. Once you create the PV, you can create the Volume Group (VG).

ximena@anneke:~$ sudo vgcreate vg01 /dev/sda6
  Volume  group "vg01" successfully created
ximena@anneke:~$


LVM processes the storage in terms of extents. We can also change the extent size (from the default size 4MB) using -s flag.

The following command lists the created VG:

ximena@anneke:~$ sudo vgdisplay
  --- Volume group ---
  VG Name               vg01
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               365.02 GiB
  PE Size               4.00 MiB
  Total PE              93446
  Alloc PE / Size       0 / 0 GiB
  Free  PE / Size       93446 / 365.02 GiB
  VG UUID               5HwOD6-cqKP-2xvm-B90G-2RMq-0mfv-Pl3G8d
  
ximena@anneke:~$


Creating Logical Volumes


Now, everything is ready to create the logical volumes from the volume groups. lvcreate command creates the logical volume with the size of 80MB.

ximena@anneke:~$ sudo lvcreate -L10G -n lv01 vg01
  Logical volume "lv01" created

ximena@anneke:~$


Using the command lvdisplay we can view the available logical volumes with its attributes:

ximena@anneke:~$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg01/lv01
  LV Name                lv01
  VG Name                vg01
  LV UUID                QAtkyi-HoMx-s1t1-NEYB-2r0S-IjY0-HmE1tV
  LV Write Access        read/write
  LV Creation host, time anneke, 2013-08-08 14:57:48 +0200
  LV Status              available
  # open                 0
  LV Size                10.00 GiB
  Current LE             2560
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0

ximena@anneke:~$


After that, we are able to create our Filesystem

ximena@anneke:~$ sudo mkfs.ext4 /dev/vg01/lv01
mke2fs 1.42.5 (29-Jul-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=64 blocks, Stripe width=64 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done                           
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

ximena@anneke:~$ 


Increasing the Size of the LVs


We can extend the size of the LVs by using lvextend utility. For examlpe:

ximena@anneke:~$ sudo lvextend -L15G /dev/vg01/lv01
  Extending logical volume lv01 to 15.00 GiB
  Logical volume lv01 successfully resized
ximena@anneke:~$


We can also add additional size to a specific LV as shown below.

ximena@anneke:~$ sudo lvextend -L+20G /dev/lb02/lv01
  Extending logical volume lv01 to 35.00 GiB
  Logical volume lv01 successfully resized
ximena@anneke:~$


Creating a Snapshot (Backup) LV


Sometimes to backup our own filesystems and/or LVs, we can use this great tool as Backup. It just simple as run this command:

ximena@anneke:~$ lvcreate -L5G -s -n lv01-SNAP vg01/lv01
  Logical volume "lv01-SNAP" created
ximena@anneke:~$


Where "-s" stands for "snapshot".

And now, our LVs will look like:

ximena@anneke:~$ lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg01/lv01
  LV Name                lv01
  VG Name                vg01
  LV UUID                QAtkyi-HoMx-s1t1-NEYB-2r0S-IjY0-HmE1tV
  LV Write Access        read/write
  LV Creation host, time anneke, 2013-08-08 14:57:48 +0200
  LV snapshot status     source of
                         lv01-SNAP [active]
  LV Status              available
  # open                 0
  LV Size                10.00 GiB
  Current LE             8960
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0
  
  --- Logical volume ---
  LV Path                /dev/vg01/lv01-SNAP
  LV Name                lv01-SNAP
  VG Name                vg01
  LV UUID                i1LP4O-xEeB-3UNd-eQf3-OMKK-L9ug-C5cEj5
  LV Write Access        read/write
  LV Creation host, time anneke, 2013-08-08 15:18:15 +0200
  LV snapshot status     active destination for lv01
  LV Status              available
  # open                 0
  LV Size                10.00 GiB
  Current LE             8960
  COW-table size         5.00 GiB
  COW-table LE           1280
  Allocated to snapshot  0.00%
  Snapshot chunk size    4.00 KiB
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1

ximena@anneke:~$


Hope this helps!

HOWTO Fix: Possible missing firmware /lib/firmware/tigon/tg3 Tigon 3

Having new Hardware for your new cool HP ProLiant Gen8 server and Debian Wheezy installed on it, can bring errors like the following one, when you try to install a new package or just run an update on the system:

...
W: Possible missing firmware /lib/firmware/tigon/tg3_tso5.bin for module tg3
W: Possible missing firmware /lib/firmware/tigon/tg3_tso.bin for module tg3
W: Possible missing firmware /lib/firmware/tigon/tg3.bin for module tg3
...


To get the Hardware of the new system to work. This is what are we going to do:

1. First of all we need to add the non-free repository to your sources.list
ximena@anneke:~$ vi /etc/apt/sources.list

deb http://ftp.de.debian.org/debian/ wheezy main non-free
deb-src http://ftp.de.debian.org/debian/ wheezy main non-free

deb http://security.debian.org/ wheezy/updates main contrib non-free
deb-src http://security.debian.org/ wheezy/updates main contrib non-free

# wheezy-updates, previously known as 'volatile'
deb http://ftp.de.debian.org/debian/ wheezy-updates main contrib non-free
deb-src http://ftp.de.debian.org/debian/ wheezy-updates main contrib non-free


Save the file, and then don't forget to run:
ximena@anneke:~$ apt-get upgrade

2. Now we will install "apt-file" to find the missing firmaware for our distro:
ximena@anneke:~$ apt-get install apt-file
ximena@anneke:~$ apt-file update


3. Now we want to find out where those “Possible missing firmware” files are located:
ximena@anneke:~$ apt-file find /lib/firmware/tigon/tg3_tso.bin

The output should look like:
firmware-linux-nonfree: /lib/firmware/tigon/tg3_tso.bin

4. So we find out /lib/firmware/tigon/tg3_tso.bin is located in the firmware-linux-nonfree package. A little info about firmware-linux-nonfree:

ximena@anneke:~$ aptitude show firmware-linux-nonfree
Package: firmware-linux-nonfree       
State: installed
Automatically installed: no
Multi-Arch: foreign
Version: 0.36+wheezy.1
Priority: optional
Section: non-free/kernel
Maintainer: Debian Kernel Team <debian-kernel@lists.debian.org>
Architecture: all
Uncompressed Size: 1,564 k
Suggests: initramfs-tools, linux-image
Conflicts: firmware-linux (< 0.19)
Replaces: firmware-linux (< 0.19)
Description: Binary firmware for various drivers in the Linux kernel
 This package contains the binary firmware for  various drivers in the Linux kernel.  This is a collection of firmware
 blobs which are not individually large enough to warrant a standalone package.
 
 Contents:
 * 3Com Typhoon firmware, version 03.001.008 (3com/typhoon.bin)
 * AdvanSys ASC-3550 firmware (advansys/3550.bin)
 * AdvanSys ASC-38C0800 firmware (advansys/38C0800.bin)
 * AdvanSys ASC-38C1600 firmware (advansys/38C1600.bin)
 * AdvanSys SCSI controller microcode (advansys/mcode.bin)
 * Agere/Prism/Symbol Orinoco firmware (AP mode), version 9.48 Hermes I (agere_ap_fw.bin)
 * Agere/Prism/Symbol Orinoco firmware (STA mode), version 9.48 Hermes I (agere_sta_fw.bin)
 * Chelsio T3 optical EDC firmware (AEL2005 PHY) (cxgb3/ael2005_opt_edc.bin)
 * Chelsio T3 twinax EDC firmware (AEL2005 PHY) (cxgb3/ael2005_twx_edc.bin)
 * Chelsio T3 twinax EDC firmware (AEL2020 PHY) (cxgb3/ael2020_twx_edc.bin)
 * Chelsio T3B protocol engine firmware, version 1.1.0 (cxgb3/t3b_psram-1.1.0.bin)
 * Chelsio T3C protocol engine firmware, version 1.1.0 (cxgb3/t3c_psram-1.1.0.bin)
 * Chelsio T3 main firmware, version 7.4.0 (cxgb3/t3fw-7.4.0.bin)
 * Chelsio T3 main firmware, version 7.10.0 (cxgb3/t3fw-7.10.0.bin)
 * Chelsio T4 firmware, version 1.4.16.0 (cxgb4/t4fw-1.4.16.0.bin)
 * DAB-USB FPGA bitfile (dabusb/bitstream.bin)
 * DAB-USB firmware (dabusb/firmware.fw)
 * Xceive 5000 tuner firmware, version 1.6.114 (dvb-fe-xc5000-1.6.114.fw)
 * DiBcom dib0700 USB DVB bridge firmware, version 1.20 (dvb-usb-dib0700-1.20.fw)
 * Intel 82559 D101M microcode (e100/d101m_ucode.bin)
 * Intel 82559 D101S microcode (e100/d101s_ucode.bin)
 * Intel 82551-F and 82551-10 microcode (e100/d102e_ucode.bin)
 * ENE UB6250 MS Pro read/write firmware (ene-ub6250/msp_rdwr.bin)
 * ENE UB6250 MS init firmware (ene-ub6250/ms_init.bin)
 * ENE UB6250 MS read/write firmware (ene-ub6250/ms_rdwr.bin)
 * ENE UB6250 SD init stage 1 firmware (ene-ub6250/sd_init1.bin)
 * ENE UB6250 SD init stage 2 firmware (ene-ub6250/sd_init2.bin)
 * ENE UB6250 SD read/write firmware (ene-ub6250/sd_rdwr.bin)
 * kaweth/new_code.bin
 * kaweth/new_code_fix.bin
 * kaweth/trigger_code.bin
 * kaweth/trigger_code_fix.bin
 * Matrox G200 WARP engine microcode (matrox/g200_warp.fw)
 * Matrox G400/G550 WARP engine microcode (matrox/g400_warp.fw)
 * Multi-Tech USB CDMA modem firmware (mts_cdma.fw)
 * Multi-Tech USB EDGE modem firmware (mts_edge.fw)
 * Multi-Tech USB GPRS modem firmware (mts_gsm.fw)
 * Rage 128 CCE microcode (r128/r128_cce.bin)
 * Radeon HD IGP 7500/7600 series ME microcode (radeon/ARUBA_me.bin)
 * Radeon HD IGP 7500/7600 series PFP microcode (radeon/ARUBA_pfp.bin)
 * Radeon HD IGP 7500/7600 series RLC microcode (radeon/ARUBA_rlc.bin)
 * Radeon HD 6800 series MC microcode (radeon/BARTS_mc.bin)
 * Radeon HD 6800 series ME microcode (radeon/BARTS_me.bin)
 * Radeon HD 6800 series PFP microcode (radeon/BARTS_pfp.bin)
 * Radeon HD 6300/6500/6800 series RLC microcode (radeon/BTC_rlc.bin)
 * Radeon HD 6300 series MC microcode (radeon/CAICOS_mc.bin)
 * Radeon HD 6300 series ME microcode (radeon/CAICOS_me.bin)
 * Radeon HD 6300 series PFP microcode (radeon/CAICOS_pfp.bin)
 * Radeon HD 6900 series MC microcode (radeon/CAYMAN_mc.bin)
 * Radeon HD 6900 series ME microcode (radeon/CAYMAN_me.bin)
 * Radeon HD 6900 series PFP microcode (radeon/CAYMAN_pfp.bin)
 * Radeon HD 6900 series RLC microcode (radeon/CAYMAN_rlc.bin)
 * Radeon HD 5400 series ME microcode (radeon/CEDAR_me.bin)
 * Radeon HD 5400 series PFP microcode (radeon/CEDAR_pfp.bin)
 * Radeon HD 5400 series RLC microcode (radeon/CEDAR_rlc.bin)
 * Radeon HD 5800/5900 series ME microcode (radeon/CYPRESS_me.bin)
 * Radeon HD 5800/5900 series PFP microcode (radeon/CYPRESS_pfp.bin)
 * Radeon HD 5800/5900 series RLC microcode (radeon/CYPRESS_rlc.bin)
 * Radeon HD 5700 series ME microcode (radeon/JUNIPER_me.bin)
 * Radeon HD 5700 series PFP microcode (radeon/JUNIPER_pfp.bin)
 * Radeon HD 5700 series RLC microcode (radeon/JUNIPER_rlc.bin)
 * Radeon HD IGP 6200/6300/7300 series ME microcode (radeon/PALM_me.bin)
 * Radeon HD IGP 6200/6300/7300 series PFP microcode (radeon/PALM_pfp.bin)
 * Radeon HD 7800 series CE microcode (radeon/PITCAIRN_ce.bin)
 * Radeon HD 7800 series MC microcode (radeon/PITCAIRN_mc.bin)
 * Radeon HD 7800 series ME microcode (radeon/PITCAIRN_me.bin)
 * Radeon HD 7800 series PFP microcode (radeon/PITCAIRN_pfp.bin)
 * Radeon HD 7800 series RLC microcode (radeon/PITCAIRN_rlc.bin)
 * Radeon R100-family CP microcode (radeon/R100_cp.bin)
 * Radeon R200-family CP microcode (radeon/R200_cp.bin)
 * Radeon R300-family CP microcode (radeon/R300_cp.bin)
 * Radeon R400-family CP microcode (radeon/R420_cp.bin)
 * Radeon R500-family CP microcode (radeon/R520_cp.bin)
 * Radeon R600 ME microcode (radeon/R600_me.bin)
 * Radeon R600 PFP microcode (radeon/R600_pfp.bin)
 * Radeon R600-family RLC microcode (radeon/R600_rlc.bin)
 * Radeon R700-family RLC microcode (radeon/R700_rlc.bin)
 * Radeon HD 5500/5600 series ME microcode (radeon/REDWOOD_me.bin)
 * Radeon HD 5500/5600 series PFP microcode (radeon/REDWOOD_pfp.bin)
 * Radeon HD 5500/5600 series RLC microcode (radeon/REDWOOD_rlc.bin)
 * Radeon RS600 CP microcode (radeon/RS600_cp.bin)
 * Radeon RS690 CP microcode (radeon/RS690_cp.bin)
 * Radeon RS780 ME microcode (radeon/RS780_me.bin)
 * Radeon RS780 PFP microcode (radeon/RS780_pfp.bin)
 * Radeon RV610 ME microcode (radeon/RV610_me.bin)
 * Radeon RV610 PFP microcode (radeon/RV610_pfp.bin)
 * Radeon RV620 ME microcode (radeon/RV620_me.bin)
 * Radeon RV620 PFP microcode (radeon/RV620_pfp.bin)
 * Radeon RV630 ME microcode (radeon/RV630_me.bin)
 * Radeon RV630 PFP microcode (radeon/RV630_pfp.bin)
 * Radeon RV635 ME microcode (radeon/RV635_me.bin)
 * Radeon RV635 PFP microcode (radeon/RV635_pfp.bin)
 * Radeon RV670 ME microcode (radeon/RV670_me.bin)
 * Radeon RV670 PFP microcode (radeon/RV670_pfp.bin)
 * Radeon RV710 ME microcode (radeon/RV710_me.bin)
 * Radeon RV710 PFP microcode (radeon/RV710_pfp.bin)
 * Radeon RV730 ME microcode (radeon/RV730_me.bin)
 * Radeon RV730 PFP microcode (radeon/RV730_pfp.bin)
 * Radeon RV770 ME microcode (radeon/RV770_me.bin)
 * Radeon RV770 PFP microcode (radeon/RV770_pfp.bin)
 * Radeon HD IGP 6400/6500/6600 series ME microcode (radeon/SUMO_me.bin)
 * Radeon HD IGP 6400/6500/6600 series PFP microcode (radeon/SUMO_pfp.bin)
 * Radeon HD IGP 6200/6300/6400/6500/6600/7300 series RLC microcode (radeon/SUMO_rlc.bin)
 * Radeon HD 6370D/6380G/6410D ME microcode (radeon/SUMO2_me.bin)
 * Radeon HD 6370D/6380G/6410D PFP microcode (radeon/SUMO2_pfp.bin)
 * Radeon HD 7900 series CE microcode (radeon/TAHITI_ce.bin)
 * Radeon HD 7900 series MC microcode (radeon/TAHITI_mc.bin)
 * Radeon HD 7900 series ME microcode (radeon/TAHITI_me.bin)
 * Radeon HD 7900 series PFP microcode (radeon/TAHITI_pfp.bin)
 * Radeon HD 7900 series RLC microcode (radeon/TAHITI_rlc.bin)
 * Radeon HD 6500/6600/7500 series MC microcode (radeon/TURKS_mc.bin)
 * Radeon HD 6500/6600/7500 series ME microcode (radeon/TURKS_me.bin)
 * Radeon HD 6500/6600/7500 series PFP microcode (radeon/TURKS_pfp.bin)
 * Radeon HD 7700 series CE microcode (radeon/VERDE_ce.bin)
 * Radeon HD 7700 series MC microcode (radeon/VERDE_mc.bin)
 * Radeon HD 7700 series ME microcode (radeon/VERDE_me.bin)
 * Radeon HD 7700 series PFP microcode (radeon/VERDE_pfp.bin)
 * Radeon HD 7700 series RLC microcode (radeon/VERDE_rlc.bin)
 * Tehuti network card firmware (tehuti/bdx.bin)
 * Broadcom BCM5703/BCM5704 TSO firmware (tigon/tg3_tso.bin)
 * Broadcom BCM5701A0 firmware (tigon/tg3.bin)
 * Broadcom BCM5705 TSO firmware (tigon/tg3_tso5.bin)
 * VIA VT6656 firmware (vntwusb.fw)
Homepage: http://git.kernel.org/?p=linux/kernel/git/firmware/linux-firmware.git

ximena@anneke:~$



5. Now, we will install our missing firmware:
ximena@anneke:~$ apt-get install firmware-linux-nonfree


At the end of the process, check dmesg or /var/log/messages to check if everything is in order after the installation of the new firmware.

Friday, August 2, 2013

HOWTO Add a Swap File in GNU/Debian based Linux Systems

If you need additional swap space to improve the system performance or when find yourself in a situation where you can't add a new partition to your system or you can't extend your current swap, this can be a good choice to follow.

Note that with the 2.6 Linux kernel, swap files are just as fast as swap partitions. Even though I recommend using a swap partition. ;)

Step #1: Create Storage File

Login as the Root User, open a terminal window and follow the instructions below.

NOTE: You need to use the dd command to create swap file.

Type the following command to create 512MB swap file (1024 * 512MB = 524288 block size):
ximena@anneke:~$ dd if=/dev/zero of=/swapfile bs=1024 count=524288

Where:
    if=/dev/zero : Read from /dev/zero file.
Note that /dev/zero is a special file in that provides as many null characters to build storage file called /swapfile
    of=/swapfile1 : Read from /dev/zero write stoage file to /swapfile.
    bs=1024 : Read and write 1024 bytes at a time.
    count=524288 : Copy only 523288 input blocks.

Step #2: Set Up a Linux Swap Area


Type the following command to set up a Linux swap area in the file we created in Step #1:
ximena@anneke:~$ mkswap /swapfile

NOTE: The mkswap command is used to set up a Linux swap area on a device or in a file.



Setup correct file permission for security reasons, enter:
ximena@anneke:~$ chown root:root /swapfile
ximena@anneke:~$ chmod 0600 /swapfile


A world-readable swap file is a huge local vulnerability. The above command make sure only root user can read/write to the file. Finally, activate /swapfile1 swap space immediately, enter:
ximena@anneke:~$ swapon /swapfile


To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Append the following line:
/swapfile              swap   swap     defaults     0 0

Next time Linux comes up after reboot, it enables the new swap file for you automatically.

Step #3 Checking if the Swap is Activated

ximena@anneke:~$ free -m

You will be able to see the new swap area activated ;)

Tuesday, July 23, 2013

HOWTO Compress a Directory on Linux?

How to Compress a Linux Directory?


To compress files or directories under Linux, GNU tar command is the best for this work. It can also be user remotely.

To Create and Compress the archive, you need to use tar command as follows:

tar -zcvf archive-name.tar.gz directory-name

Where,
    -z: Compress archive using gzip program
    -c: Create archive
    -v: Verbose i.e display progress while creating archive
    -f: Archive File name

For example, you have directory called /home/ximunix/blog and you would like to compress this directory then you run the following command:

ximena@anneke:~$ tar -zcvf ximunix_blog-1-jul-2013.tar.gz /home/ximunix/blog

The command above will create an archive file called ximunix_blog-1-jul-2013.tar.gz in your current directory (You can run the command "pwd" to check in which directory you are currently on).

If you wish to restore your archive then you need to use following command (it will extract all files in your current directory):

ximena@anneke:~$ tar -zxvf ximunix_blog-1-jul-2013.tar.gz

Where,
    -x: Extract files

If you wish to extract files in particular directory, for example in /tmp then you need to use following command:

ximena@anneke:~$ tar -zxvf ximunix_blog-1-jul-2013.tar.gz -C /tmp
ximena@anneke:~$ cd /tmp
ximena@anneke:~$ ls -l



How do I use tar command over secure ssh session?


The GNU version of the tar utility can be used through the network over ssh session.
The following command backups /home/ximunix/blog directory to the "bazinga" host (IP 192.168.1.101) over ssh session.

ximena@anneke:~$ tar zcvf - /home/ximunix/blog | ssh root@bazinga "cat > /backup/ximunix-blog.tar.gz"
OR
ximena@anneke:~$ tar zcvf - /home/ximunix/blog | ssh root@192.168.1.101 "cat > /backup/ximunix-blog.tar.gz"

You can also use the "dd" command for clarity purpose:
ximena@anneke:~$ tar cvzf - /home/ximunix/blog | ssh root@192.168.1.101 "dd of=/backup/ximunix-blog.tar.gz"

You can restore tar backup over ssh session:
ximena@anneke:~$ cd /
ximena@anneke:~$ ssh root@192.168.1.101 "cat /backup/ximunix-blog.tar.gz" | tar zxvf -


NOTE: If you wish to use the above command in a cron job, consider SSH keys to get rid of the passwords.

Sunday, April 28, 2013

HOWTO Backup Local Linux Host Using rsnapshot utility

rsnapshot is an awesome free Linux backup utility to perform rsync backup of both local and remote file system.


In this post, we will try to explain how to install and configure rsnapshot utility to take rsync backup of local file system.

rsnapshot uses the combination of rsync and hard links to maintain full-backup and incremental backups. Once you’ve setup and configured rsnapshot, there is absolutely no maintenance involved in it. rsnapshot will automatically take care of deleting and rotating the old backups.

It also takes very less disk space. The first full backup will take the same size as your original files and directories. Subsequent rsnapshot full backups takes only less space, as it takes backup of only the modified files from the previous full backup.

Install rsnapshot

For Ubuntu systems, run the following step:
root@anneke:~# apt-get install rsnapshot

Once rsnapshot is intalled, we will make a backup of the config file, to have always a default backup in case we need it. For this, run the following step:
root@anneke:~# cp -p /etc/rsnapshot.conf /etc/rsnapshot.conf.bckp.orig

Configure rsnapshot and specify backup source directory


Open the /etc/rsnapshot.conf and uncomment the following lines.

# vi /etc/rsnapshot.conf

cmd_cp          /bin/cp
cmd_ssh /usr/bin/ssh
cmd_du          /usr/bin/du
cmd_rsnapshot_diff      /usr/local/bin/rsnapshot-diff
logfile /var/log/rsnapshot


Define your destination backup directories in /etc/rsnapshot.conf as shown below. In this example,

/etc – source directory that should be backed-up
localhost/ – destination directory where the backup will be stored.


# vi /etc/rsnapshot.conf

backup  /etc/           localhost/
backup  /home/          localhost/

Note: Change /etc/ to the appropriate directory that you would like to backup.

Test rsnapshot configuration


Perform configuration test to make sure rsnapshot is setup properly and ready to perform linux rsync backup.

root@anneke:~# rsnapshot configtest
Syntax OK

If all is well, it should say Syntax OK. If there's a problem, it should tell you exactly what it is. Make sure your config file is using tabs and not spaces, etc.



Verify rsnapshot Backup Configuration

You can backup linux directories or files at various intervals. By default, the hourly and daily backups are configured.

Verify the hourly backup configuration


root@anneke:~#  rsnapshot -t hourly
echo 4369 > /var/run/rsnapshot.pid 
mv /var/cache/rsnapshot/hourly.1/ /var/cache/rsnapshot/hourly.2/ 
/bin/cp -al /var/cache/rsnapshot/hourly.0 /var/cache/rsnapshot/hourly.1 
/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded /home \
    /var/cache/rsnapshot/hourly.0/localhost/ 
/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded /etc \
    /var/cache/rsnapshot/hourly.0/localhost/ 
touch /var/cache/rsnapshot/hourly.0/ 
root@anneke:~# 


Verify rsnapshot Daily Backup Configuration

Verify the daily rsnapshot backup process is configured properly.

root@anneke:~# rsnapshot -t daily
echo 4371 > /var/run/rsnapshot.pid 
/var/cache/rsnapshot/hourly.5 not present (yet), nothing to copy
root@anneke:~# 

Add Crontab Entry for rsnapshot

Once you’ve verified that the rsync hourly and daily backup configurations are setup properly in the rsnapshot utility, it is time to set up the crontab as shown below:

root@anneke:~# crontab -e
0 */4 * * * root /usr/local/bin/rsnapshot hourly
30 23 * * * root /usr/local/bin/rsnapshot daily

Verify the rsnapshot Job Manually (One time check-up)

For the first time, you may want to execute the rsnapshot backup manually to make sure it is working as expected.

By default all the rsync backup taken by rnspashot utility will be stored under /var/cache/rsnapshot directory.

Since rsnapshot was never executed, this directory may not exist as shown below.

root@anneke:~# ls -al /var/cache/rsnapshot
ls: /var/cache/rsnapshot: No such file or directory

Execute the rsnapshot backup utility manually for hourly configuration as shown below.

root@anneke:~# /usr/local/bin/rsnapshot hourly

Since we’ve executed the hourly backup, rsnapshot linux backup utility would’ve created the following /var/cache/rsnapshot directory with the hourly.0 directory

Browse through the /var/cache/rsnapshot/hourly.0/ directory to make sure the files and directories that you’ve configured are backed up accordingly.

root@anneke:~# ls -al /var/cache/rsnapshot/
total 16
drwx------  4 root root 4096 Apr 28 17:19 .
drwxr-xr-x 19 root root 4096 Apr 28 15:49 ..
drwxr-xr-x  4 root root 4096 Apr 28 17:20 hourly.0
drwxr-xr-x  3 root root 4096 Apr 28 17:14 hourly.1
root@anneke:~# 

root@anneke:~# ls -al /var/cache/rsnapshot/hourly.0/localhost/etc/
total 1212
drwxr-xr-x 149 root root    12288 Apr 28 17:19 .
drwxr-xr-x   4 root root     4096 Apr 28 17:19 ..
drwxr-xr-x   3 root root     4096 Oct 17  2012 acpi
-rw-r--r--   1 root root     2981 Oct 17  2012 adduser.conf
-rw-r--r--   1 root root       10 Apr  3 16:32 adjtime
drwxr-xr-x   2 root root     4096 Apr  8 12:49 alternatives
-rw-r--r--   1 root root      401 May 25  2012 anacrontab
...

Hope this guide helps!





Thursday, April 4, 2013

LAMP Server on Debian/Ubuntu based Distros


This guide provides step by step instructions for installing a full featured LAMP stack on an Ubuntu 12.10. In this guide, you'll learn how to set up Apache, MySQL, and PHP.

1. Set up the Hostname

Before you begin installing and configuring the components described in this guide, please make sure you've followed our instructions for setting your hostname. Issue the following commands to make sure it is set properly (The first command should show your short hostname, and the second should show your fully qualified domain name (FQDN)):

hostname
hostname -f


2. Install and Configure the Apache Web Server

Make sure your package repositories and installed programs are up to date by issuing the following commands:

apt-get update
apt-get upgrade --show-upgraded

To install the current version of the Apache web server (in the 2.x series) on an Ubuntu system use the following command:

apt-get install apache2

- Configure Name-based Virtual Hosts

There are different ways to set up virtual hosts, however we recommend the method below. By default, Apache listens on all IP addresses available to it.

First, create a file in the /etc/apache2/sites-available/ directory for each virtual host that you want to set up. Name each file with the domain for which you want to provide virtual hosting. See the following example configurations for the hypothetical "test.com" and "test.org" domains.

File:/etc/apache2/sites-available/test.com
<VirtualHost *:80>
     ServerAdmin webmaster@test.com
     ServerName test.com
     ServerAlias www.test.com
     DocumentRoot /srv/www/test.com/public_html/
     ErrorLog /srv/www/test.com/logs/error.log
     CustomLog /srv/www/test.com/logs/access.log combined
</VirtualHost>

File:/etc/apache2/sites-available/test.org
<VirtualHost *:80>
     ServerAdmin webmaster@test.org
     ServerName test.org
     ServerAlias www.test.org
     DocumentRoot /srv/www/test.org/public_html/
     ErrorLog /srv/www/test.org/logs/error.log
     CustomLog /srv/www/test.org/logs/access.log combined
</VirtualHost>

Notes regarding this example configuration:

All of the files for the sites that you host will be located in directories that exist underneath /srv/www You can symbolically link these directories into other locations if you need them to exist in other places.
ErrorLog and CustomLog entries are suggested for more fine-grained logging, but are not required. If they are defined (as shown above), the logs directories must be created before you restart Apache.
Before you can use the above configuration you'll need to create the specified directories. For the above configuration, you can do this with the following commands:

mkdir -p /srv/www/test.com/public_html
mkdir /srv/www/test.com/logs

mkdir -p /srv/www/test.org/public_html
mkdir /srv/www/test.org/logs

After you've set up your virtual hosts, issue the following commands to enable the sites:

a2ensite test.com
a2ensite test.org

This command symbolically links your virtual host file from sites-available to the sites-enabled directory. Finally, before you can access your sites you must reload Apache with the following command:

service apache2 reload

If you wanted to disable the test.com site, for example issue the following command:

a2dissite test.com

The a2dissite command is the inverse of a2ensite. After enabling, disabling, or modifying any part of your Apache configuration you will need to reload the Apache configuration again with the /etc/init.d/apache2 reload command. You can create as many virtual hosting files as you need to support the domains that you want to host.

- Testing Apache

Open up any web browser and then enter the following into the web address:

http://localhost/

You should see a message saying "It works!" , congrats to you! 

3. Install and Configure the MySQL Database Server


The first step is to install the mysql-server package, which is accomplished by the following command:

apt-get install mysql-server

During the installation you will be prompted for a password. Choose something secure (use letters, numbers, and non-alphanumeric characters) and record it for future reference.

At this point MySQL should be ready to configure and run. While you shouldn't need to change the configuration file, note that it is located at /etc/mysql/my.cnf for future reference.

- Configure MySQL and Set Up Databases

After installing MySQL, it's recommended that you run mysql_secure_installation, a program that helps secure MySQL. While running mysql_secure_installation, you will be presented with the opportunity to change the MySQL root password, remove anonymous user accounts, disable root logins outside of localhost, and remove test databases. It is recommended that you answer yes to these options. If you are prompted to reload the privilege tables, select yes. Run the following command to execute the program:

mysql_secure_installation

Next, we'll create a database and grant your users permissions to use databases. First, log in to MySQL:

mysql -u root -p

Enter MySQL's root password, and you'll be presented with a MySQL prompt where you can issue SQL statements to interact with the database.

To create a database and grant your users permissions on it, issue the following command. Note, the semi-colons (;) at the end of the lines are crucial for ending the commands. Your command should look like this:

create database anneke;
grant all on anneke.* to 'ximena' identified by '5t1ck';
flush privileges;

In the example above, anneke is the name of the database, ximena is the username, and 5t1ck password. Note that database user names and passwords are only used by scripts connecting to the database, and that database user account names need not (and perhaps should not) represent actual user accounts on the system.

With that completed you've successfully configured MySQL and you may now pass these database credentials on to your users. To exit the MySQL database administration utility issue the following command:

quit

With Apache and MySQL installed you are now ready to move on to installing PHP to provide scripting support for your web pages.

4. Install and Configure PHP


Issue the following command to install PHP:

apt-get install php5 php-pear

Once PHP5 is installed we'll need to tune the configuration file located in /etc/php5/apache2/php.ini to enable more descriptive errors, logging, and better performance. These modifications provide a good starting point if you're unfamiliar with PHP configuration.
Make sure that the following values are set, and relevant lines are uncommented (comments are lines beginning with a semi-colon (;)):

File excerpt:/etc/php5/apache2/php.ini

max_execution_time = 30
memory_limit = 64M
error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
display_errors = Off
log_errors = On
error_log = /var/log/php.log
register_globals = Off

After making changes to the PHP configuration file, restart Apache by issuing the following command:

service apache2 reload

If you need support for MySQL in PHP, then you must install the php5-mysql package with the following command:

apt-get install php5-mysql

To install the php5-suhosin package, which provides additional security for PHP 5 applications (recommended), issue the following command:

apt-get install php5-suhosin

Restart Apache to make sure everything is loaded correctly:

service apache2 reload

- Test PHP

In the terminal copy/paste the following line:

vi /var/www/info.php

This will open up a file called info.php

Copy/Paste this line into the phptest file:

<?php phpinfo(); ?>

Save and close the file.

Now open you're web browser and type the following into the web address:

http://localhost/info.php

The page should show all the info regarding the php installed in your system:

Congratulations! You have now set up and configured a LAMP system.

Thanks to Linode Library for the procedure!

Sunday, January 6, 2013

20 Practical RPM Examples


RPM (Red Hat Package Manager) is a default Open Source Package Management utility for Red Hat based systems like (RHEL, CentOS and Fedora). The tool allows system administrators and users to install, update, uninstall, query, verify and manage system software packages in Linux operating systems. The RPM formerly known as .rpm file includes compiled software programs and libraries needed by the packages. This utility only works with packages built on .rpm format.

RPM is free and released under GPL (General Public License).
RPM keeps the information of all the installed packages under /var/lib/rpm database.
RPM is the only way to install packages under Red Hat based Linux systems, if you’ve installed packages using source code, then rpm won’t manage it.
RPM deals with .rpm files, which contains the actual information about the packages such as: what it is, from where it comes, dependencies info, version info etc.


1. How to Check an RPM Signature Package
Always check the PGP signature of packages before installing them on your Linux systems and make sure its integrity and origin are OK. Use the following command with –checksig (check signature) option to check the signature of a package called pidgin.

[root@anneke]# rpm --checksig pidgin-2.7.9-5.el6.2.i686.rpm
pidgin-2.7.9-5.el6.2.i686.rpm: rsa sha1 (md5) pgp md5 OK
[root@anneke]#

2. How to Install an RPM Package
To install a rpm software package, use the following command with -i option. For example:

[root@anneke]# rpm -ivh pidgin-2.7.9-5.el6.2.i686.rpm
Preparing...                ########################################### [100%]
   1:pidgin                 ########################################### [100%]
[root@anneke]#

Flags:
-i : install a package
-v : verbose for a nicer display
-h: print hash marks as the package archive is unpacked.

3. How to check dependencies of RPM Package before Installing
Let’s say you would like to do a dependency check before installing or upgrading a package. Use the following command to check the dependencies of BitTorrent-5.2.2-1-Python2.4.noarch.rpm package. It will display the list of dependencies of theq package.

[root@anneke]# rpm -qpR BitTorrent-5.2.2-1-Python2.4.noarch.rpm
/usr/bin/python2.4
python >= 2.3
python(abi) = 2.4
python-crypto >= 2.0
python-psyco
python-twisted >= 2.0
python-zopeinterface
rpmlib(CompressedFileNames) = 2.6
[root@anneke]#

Flags:
-q : Query a package
-p : List capabilities this package provides.
-R: List capabilities on which this package depends..

4. How to Install a RPM Package Without Dependencies
If you know that all needed packages are already installed, you can ignore those dependencies by using the option –nodeps (no dependencies check) before installing the package.

[root@anneke]# rpm -ivh --nodeps BitTorrent-5.2.2-1-Python2.4.noarch.rpm
Preparing...                ########################################### [100%]
   1:BitTorrent             ########################################### [100%]
[root@anneke]#

The above command forcefully install rpm package by ignoring dependencies errors, but if those dependencies files are missing, then the program will not work at all, until you install them.

5. How to check an Installed RPM Package
Using -q option with package name will show whether a rpm is installed or not.

[root@anneke]# rpm -q BitTorrent
BitTorrent-5.2.2-1.noarch
[root@anneke]#

6. How to List all files of an installed RPM package
To view all the files of an installed rpm packages, use the -ql (query list).

[root@anneke]# rpm -ql BitTorrent
/usr/bin/bittorrent
/usr/bin/bittorrent-console
/usr/bin/bittorrent-curses
/usr/bin/bittorrent-tracker
/usr/bin/changetracker-console
/usr/bin/launchmany-console
/usr/bin/launchmany-curses
/usr/bin/maketorrent
/usr/bin/maketorrent-console
/usr/bin/torrentinfo-console
[root@anneke]#

7. How to List Recently Installed RPM Packages
The following rpm command with -qa (query all) option, will list all the recently installed rpm packages.

[root@anneke]# rpm -qa --last
BitTorrent-5.2.2-1.noarch                     Tue 04 Dec 2012 05:14:06 PM BDT
pidgin-2.7.9-5.el6.2.i686                     Tue 04 Dec 2012 05:13:51 PM BDT
cyrus-sasl-devel-2.1.23-13.el6_3.1.i686       Tue 04 Dec 2012 04:43:06 PM BDT
cyrus-sasl-2.1.23-13.el6_3.1.i686             Tue 04 Dec 2012 04:43:05 PM BDT
cyrus-sasl-md5-2.1.23-13.el6_3.1.i686         Tue 04 Dec 2012 04:43:04 PM BDT
cyrus-sasl-plain-2.1.23-13.el6_3.1.i686       Tue 04 Dec 2012 04:43:03 PM BDT
[root@anneke]#

8. How to List All Installed RPM Packages
Type the following command to print the all the names of installed packages on your Linux system.

[root@anneke]# rpm -qa
initscripts-9.03.31-2.el6.centos.i686
polkit-desktop-policy-0.96-2.el6_0.1.noarch
thunderbird-17.0-1.el6.remi.i686
[...]
[root@anneke]#

9. How to Upgrade a RPM Package
If we want to upgrade any RPM package “–U” (upgrade) option will be used. One of the major advantages of using this option is that it will not only upgrade the latest version of any package, but it will also maintain the backup of the older package so that in case if the newer upgraded package does not run the previously installed package can be used again.

[root@anneke]# rpm -Uvh nx-3.5.0-2.el6.centos.i686.rpm
Preparing...                ########################################### [100%]
   1:nx                     ########################################### [100%]
[root@anneke]#

10. How to Remove a RPM Package
To uninstall an RPM package, we use the package name, not the original package name nx-3.5.0-2.el6.centos.i686.rpm. The -e (erase) option is used to remove package.

[root@anneke]# rpm -evv nx

11. How to Remove an RPM Package Without Dependencies
The –nodeps (do not check dependencies) option forcefully remove the rpm package from the system. But keep in mind removing particular package may break other working applications.

[root@anneke]# rpm -ev --nodeps vsftpd

12. How to Query a file that belongs to which RPM Package
Let’s say, you have list of files and you would like to find out which package belongs to these files. For example, the following command with -qf (query file) option will show you a file /usr/bin/htpasswd is own by package httpd-tools-2.2.15-15.el6.centos.1.i686.

[root@anneke]# rpm -qf /usr/bin/htpasswd
httpd-tools-2.2.15-15.el6.centos.1.i686
[root@anneke]#

13. How to Query Information of an Installed RPM Package
Let’s say you have installed an rpm package and want to know the information about the package. The following -qi (query info) option will print the available information of the installed package.

[root@anneke]# rpm -qi vsftpd
Name        : vsftpd   Relocations: (not relocatable)
Version     : 2.2.2   Vendor: CentOS
Release     : 11.el6   Build Date: Fri 22 Jun 2012 01:54:24 PM BDT
Install Date: Mon 17 Sep 2012 07:55:28 PM BDT      Build Host: c6b8.bsys.dev.centos.org
Group       : System Environment/Daemons           Source RPM: vsftpd-2.2.2-11.el6.src.rpm
Size        : 351932                               License: GPLv2 with exceptions
Signature   : RSA/SHA1, Mon 25 Jun 2012 04:07:34 AM BDT, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://vsftpd.beasts.org/
Summary     : Very Secure Ftp Daemon
Description : vsftpd is a Very Secure FTP daemon. It was written completely from scratch.
[root@anneke]#

14. Get the Information of RPM Package Before Installing
You have download a package from the internet and want to know the information of a package before installing. For example, the following option -qip (query info package) will print the information of a package sqlbuddy.

[root@anneke]# rpm -qip sqlbuddy-1.3.3-1.noarch.rpm
Name        : sqlbuddy                     Relocations: (not relocatable)
Version     : 1.3.3                        Vendor: (none)
Release     : 1                            Build Date: Wed 02 Nov 2011 11:01:21 PM BDT
Install Date: (not installed)              Build Host: rpm.bar.baz
Group       : Applications/Internet        Source RPM: sqlbuddy-1.3.3-1.src.rpm
Size        : 1155804                      License: MIT
Signature   : (none)
Packager    : Erik M Jacobs
URL         : http://www.sqlbuddy.com/
Summary     : SQL Buddy รข Web based MySQL administration
Description : SQLBuddy is a PHP script that allows for web-based MySQL administration.
[root@anneke]#

15. How to Query documentation of Installed RPM Package
To get the list of available documentation of an installed package, use the following command with option -qdf (query document file) will display the manual pages related to vmstat package.

[root@anneke]# rpm -qdf /usr/bin/vmstat
/usr/share/doc/procps-3.2.8/BUGS
/usr/share/doc/procps-3.2.8/COPYING
/usr/share/doc/procps-3.2.8/COPYING.LIB
/usr/share/doc/procps-3.2.8/FAQ
/usr/share/doc/procps-3.2.8/NEWS
/usr/share/doc/procps-3.2.8/TODO
[root@anneke]#

16. How to Verify a RPM Package
Verifying a package compares information of installed files of the package against the rpm database. The -Vp (verify package) is used to verify a package.

[root@anneke downloads]# rpm -Vp sqlbuddy-1.3.3-1.noarch.rpm
S.5....T.  c /etc/httpd/conf.d/sqlbuddy.conf
[root@anneke]#

17. How to Verify all RPM Packages
Type the following command to verify all the installed rpm packages.

[root@anneke]# rpm -Va
S.5....T.  c /etc/rc.d/rc.local
.......T.  c /etc/dnsmasq.conf
.......T.    /etc/ld.so.conf.d/kernel-2.6.32-279.5.2.el6.i686.conf
S.5....T.  c /etc/yum.conf
S.5....T.  c /etc/yum.repos.d/epel.repo
[root@anneke]#

18. How to Import an RPM GPG key
To verify RHEL/CentOS/Fedora packages, you must import the GPG key. To do so, execute the following command. It will import CentOS 6 GPG key.

[root@anneke]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

19. How to List all Imported RPM GPG keys
To print all the imported GPG keys in your system, use the following command.

[root@anneke]# rpm -qa gpg-pubkey*
gpg-pubkey-0608b895-4bd22942
gpg-pubkey-7fac5991-4615767f
gpg-pubkey-0f2672c8-4cd950ee
gpg-pubkey-c105b9de-4e0fd3a3
gpg-pubkey-00f97f56-467e318a
gpg-pubkey-6b8d79e6-3f49313d
gpg-pubkey-849c449f-4cb9df30
[root@anneke]#

20. How To rebuild Corrupted RPM Database
Sometimes rpm database gets corrupted and stops all the functionality of rpm and other applications on the system. So, at the time we need to rebuild the rpm database and restore it with the help of following command.

[root@anneke]# cd /var/lib
[root@anneke]# rm __db*
[root@anneke]# rpm --rebuilddb
[root@anneke]# rpmdb_verify Packages

Thanks to http://www.tecmint.com