Tuesday, 28 May 2013

Centos 6/RHEL install & use Dmidecode

Dmidecode, or Desktop Mangement Interface, is a very useful tool for finding out details of the system hardware on your Centos 6 or RHEL box. 

Dmidecode outputs information about your hardware as recorded in the BIOS. You can also obtain the information about maximum supported system configuration. This includes model name, serial number, BIOS version, asset tag and other details depending on the manufacturer. This will often include usage status for the CPU sockets, expansion slots (e.g. AGP, PCI, ISA) and memory module slots, and the list of I/O ports (e.g. serial, parallel, USB). Important to note is that it does not scan your hardware but reports what information the bios holds on it. It should be run as root user.

It is in the base repo so just

# yum -y install dmidecode

# dmidecode --string baseboard-manufacturer                
Dell Inc.

# sudo dmidecode --string processor-manufacturer

# dmidecode --string processor-frequency
1800 MHz

Valid string keywords are:

Or you can specify individual components using -t or --type or even a comma separated list of type numbers.

# dmidecode -t processor   (edited output)

 Version: Intel(R) Celeron(R) CPU          430  @ 1.80GHz
        Voltage: 0.0 V
        External Clock: 200 MHz
        Max Speed: 4000 MHz
        Current Speed: 1800 MHz
        Status: Populated, Enabled
        Upgrade: ZIF Socket
        L1 Cache Handle: 0x000A
        L2 Cache Handle: 0x000B
        L3 Cache Handle: Not Provided
        Serial Number: 
        Asset Tag: 
        Part Number: 
        Core Count: 1
        Core Enabled: 1
        Thread Count: 1
                64-bit capable

# dmidecode -t memory

Handle 0x0027, DMI type 17, 27 bytes
Memory Device
        Array Handle: 0x0024
        Error Information Handle: Not Provided
        Total Width: 64 bits
        Data Width: 64 bits
        Size: 1024 MB
        Form Factor: DIMM
        Set: None
        Locator: DIMM3
        Bank Locator: 
        Type: DDR2
        Type Detail: Synchronous
        Speed: 667 MHz
        Manufacturer: 0000000000000000
        Serial Number: 071002C5
        Asset Tag: 000000
        Part Number: 128X64M-80E

# dmidecode -t connector   (edited output)

Port Connector Information
        Internal Reference Designator: Not Specified
        Internal Connector Type: None
        External Reference Designator: VIDEO
        External Connector Type: DB-15 female
        Port Type: Video Port

Handle 0x001C, DMI type 8, 9 bytes
Port Connector Information
        Internal Reference Designator: Not Specified
        Internal Connector Type: None
        External Reference Designator: AUDIO
        External Connector Type: None
        Port Type: Audio Port

Handle 0x001D, DMI type 8, 9 bytes
Port Connector Information
        Internal Reference Designator: Not Specified
        Internal Connector Type: None
        External Reference Designator: ETHERNET
        External Connector Type: RJ-45
        Port Type: Network Port

Each keyword corresponds to a list of type numbers which can also be used individually.

Commonly used parameters as a string are
  • bios – info about your bios.
  • system – info about the system hardware.
  • baseboard – info on the mother board.
  • chassis – info on what the system is made up of.
  • processor – processor info.
  • memory – memory info.
  • cache – info on the CPU cache.
  • connector – output interfaces. USB, firewire, ethernet etc.
  • slot – system bus information, voltages present, supplied etc.

The following additional numbered types are available

Type   Information
      ------ -------------
          0   BIOS
          1   System
          2   Base Board
          3   Chassis
          4   Processor
          5   Memory Controller
          6   Memory Module
          7   Cache
          8   Port Connector
          9   System Slots
         10   On Board Devices
         11   OEM Strings
         12   System Configuration Options
         13   BIOS Language
         14   Group Associations
         15   System Event Log
         16   Physical Memory Array
         17   Memory Device
         18   32-bit Memory Error
         19   Memory Array Mapped Address
         20   Memory Device Mapped Address
         21   Built-in Pointing Device
         22   Portable Battery
         23   System Reset
         24   Hardware Security
         25   System Power Controls
         26   Voltage Probe
         27   Cooling Device
         28   Temperature Probe
         29   Electrical Current Probe
         30   Out-of-band Remote Access
         31   Boot Integrity Services
         32   System Boot
         33   64-bit Memory Error
         34   Management Device
         35   Management Device Component
         36   Management Device Threshold Data
         37   Memory Channel
         38   IPMI Device
         39   Power Supply
# dmidecode -t 4
Is the same output as
# dmidecode -t processor 

Pipe the information using head

# dmidecode -t 4 | head -26

SMBIOS 2.5 present.

Handle 0x0004, DMI type 4, 40 bytes
Processor Information
        Socket Designation: Socket 775
        Type: Central Processor
        Family: Celeron
        Manufacturer: Intel
        ID: 61 06 01 00 FF FB EB AF
        Signature: Type 0, Family 6, Model 22, Stepping 1
                FPU (Floating-point unit on-chip)
                VME (Virtual mode extension)
                DE (Debugging extension)
                PSE (Page size extension)
                TSC (Time stamp counter)
                MSR (Model specific registers)
                PAE (Physical address extension)
                MCE (Machine check exception)
                CX8 (CMPXCHG8 instruction supported)
                APIC (On-chip APIC hardware supported)
                SEP (Fast system call)
                MTRR (Memory type range registers)
                PGE (Page global enable)
                MCA (Machine check architecture)

$ man dmidecode

$ dmidecode -h

for additional details.

Monday, 20 May 2013

Centos 6/RHEL install Abiword

Abiword is a lightweight cross platform open source Office program which runs nicely on Linux, probably a little quicker than two of the major applications which are also available, Open Office and LibreOffice. It is twinned with the Abicollab
project which allows multiple participants to work on the same document.

It comes with a useful array of tables, bullets, lists, images, footnotes, endnotes and styles with other features including mail merge & internationalisation.

It also has an extensible plugin architecture with a variety of plugins ranging from Document Importers to a Thesaurus, Image Importers and a Text Summarizer.

It can accomplish a wide range of tasks in document handling, for example it can import WordPerfect documents or graphics, view SVG graphics and work with Palm database files.

A large choice of file types is supported, including PDF which makes it ideal to use in conjunction with Print to PDF for Firefox, you can open web pages you have saved to PDF for further editing in Abiword if necessary. 

In addition, it can read and write files in its native form, MS documents, including MS Word 2007 Office Open XML (DOCX), PDF, OpenOffice, LaTeX, KWord, PostScript (PS) and Outlook mail.

AbiWord offers a simple text editor where you input formulas in LaTeX format for equation handling, and it features a powerful drop down styling menu accessed from the format toolbar, in addition to the Stylist, a facility to quickly change parts of the current document.
It can be used in a server environment thanks to the powerful built in command line interface which enables you to generate form letters, print documents or convert to any file format from the command line.

With features like these and the cross platform functionality including a portable version, Abiword is becoming a must have for the Linux desktop. To install it, first enable nux-dextop repo

Disable it or set priorities for it, then use as below.

$ sudo yum -y --enablerepo=nux-dextop install abiword

Should get you the latest binary version installed

$ abiword

will run it. 

See Fluxbox key bindings for Fluxbox shortcuts. 

Friday, 17 May 2013

Centos 6/RHEL install additional Repositories & Priorities

Here is a list of repos which are useful for extra packages while building up your system. You can use them manually and have them set at disabled until you need them or you can experiment with yum priorities which is the recommended way. Using priorities you can control which repo gets used if multiple repos supply the same packages. If using yum priorities you will need to perform some tasks to start with.


First obtain the priorities & yum-utils packages for Centos 6.

$ sudo yum -y install yum-plugin-priorities yum-utils

Now add lines to the two conf files

$ sudo vi /etc/yum/pluginconf.d/priorities.conf

Add this line


$ sudo vi /etc/yum.conf 

Add this line


Check out vi commands if needed

Simple priority usage is by adding a line in each repo file

$ sudo vi /etc/yum.repos.d/<reponame>.repo

priority=1                       Greatest priority

priority=99                      Lowest priority

Any repo not assigned a priority number will default to 99.

But it can become a little more complex, see the link above.

You can play around with the priorities settings for the repos you have installed, with the more useful ones set at around 10-20 and the less used ones set at 40-50 & with the include an exclude flags.

Read the manual for additional yum commands as you proceed, especially the 'includepkgs=' and/or 'exclude=' options.

$ man yum
$ man yumdb
$ man yum.conf 

Centos Repos

You can search an invidual repos contents by disabling them all and enabling the one you want to view, first get a list of your installed repos, repolist may not list all of them so

$ yum repolist                  or if some are excluded

$ ls /etc/yum.repos.d/

$ yum --disablerepo=\* --enablerepo=nux-dextop list all

You can enable additional Centos repos in the base repo file

$ sudo vi /etc/yum.repos.d/CentOS-Base.repo

Scroll down, for example, to enable centosplus or contrib and set enabled to 1.

You can then set priorities on each with the exclude= command to filter out packages you don't require in a space separated list.

exclude=php* kernel* 
exclude=(exclude packages you dont want updating)



Centos 6/RHEL Priorities settings restrictions

Third Party Repos

Some of the third party repos which are available.


$ sudo  rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

(Same package for 64 bit)


$ sudo rpm --import http://puias.princeton.edu/data/puias/6/i386/os/RPM-GPG-KEY-puias  

(Same key for 64 bit)

$ sudo vi /etc/yum.repos.d/PUIAS_6_addons_2.repo    put in it

name=PUIAS addons Base $releasever - $basearch - 2


Remi (PHP related and others, must have Epel also)

$ sudo yum -y install wget
$ wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm 
$ sudo rpm -Uvh remi-release-6.rpm


$ su -c 'yum -y localinstall --nogpgcheck http://download1.rpmfusion.org/free/el/updates/6/i386/rpmfusion-free-release-6-1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/6/i386/rpmfusion-nonfree-release-6-1.noarch.rpm'

(Enter password at prompt)

or go to http://rpmfusion.org/Configuration to find the current commands as they change often.


$ sudo rpm --import http://elrepo.org/RPM-GPG-KEY-elrepo.org 

$ sudo  rpm -Uvh http://elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm


$ sudo rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm

$ sudo rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm


$ sudo vi /etc/yum.repos.d/naulinux-school.repo

Enter into the file

name=NauLinux School

Save the file and run yum


$ sudo yum -y install wget                           
$ wget http://li.nux.ro/download/nux/dextop/el6/i386/nux-dextop-release-0-1.el6.nux.noarch.rpm
$ wget http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-1.el6.nux.noarch.rpm

Then install the downloaded repo pack       


$ sudo rpm -Uvh nux-dextop-release-0-1.el6.nux.noarch.rpm  


Create a blank repo file

$ sudo vi /etc/yum.repos.d/virtualbox.repo

Enter into the file

name=Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox

Save the file and run yum 


 $ sudo rpm --import http://packages.atrpms.net/RPM-GPG-KEY.atrpms 

$ sudo rpm -Uvh http://packages.atrpms.net/dist/el6/atrpms-repo/atrpms-repo-6-6.el6.i686.rpm

$ sudo rpm -Uvh http://packages.atrpms.net/dist/el6/atrpms-repo/atrpms-repo-6-6.el6.x86_64.rpm

If you are not using priorities, disable them to avoid conflicts, but leave EPEL enabled.

As there will be more than one repo file just

$ yum repolist
$ sudo vi /etc/yum.repos.d/<repo_name>  (set enabled to 0)

To find out information on any available package just query it.

$ repoquery -i gedit          (search default repos)

$ repoquery -i --enablerepo=nux-dextop deluge (additional repo)

$ repoquery -i --repoid=nux-dextop deluge (just one repo)

 Name        : deluge
Version     : 1.3.3
Release     : 1.el6.nux
Architecture: noarch
Size        : 0
Packager    : http://li.nux.ro/
Group       : Applications/Internet
URL         : http://deluge-torrent.org/
Repository  : nux-dextop
Summary     : A GTK+ BitTorrent client with support for DHT, UPnP, and PEX
Source      : deluge-1.3.3-1.el6.nux.src.rpm
Description :
Deluge is a new BitTorrent client, created using Python and GTK+. It is
intended to bring a native, full-featured client to Linux GTK+ desktop
environments such as GNOME and XFCE. It supports features such as DHT
(Distributed Hash Tables), PEX (ĀµTorrent-compatible Peer Exchange), and UPnP
(Universal Plug-n-Play) that allow one to more easily share BitTorrent data
even from behind a router with virtually zero configuration of port-forwarding.

You can also use 

$ yum list available gedit

$ yum list available | grep gedit

More examples of repoquery & yum
See the list of repoquery commands below.

Repoquery Options:

 --version             show program’s version number and exit

 -h, --help            show this help message and exit

 -l, --list            list files in this package/group

 -i, --info            list descriptive info from this package/group

 -f, --file            query which package provides this file

 --qf=QUERYFORMAT, --queryformat=QUERYFORMAT

                       specify a custom output format for queries

 --groupmember         list which group(s) this package belongs to

 -q, --query           no-op for rpmquery compatibility

 -a, --all             query all packages/groups

 -R, --requires        list package dependencies

 --provides            list capabilities this package provides

 --obsoletes           list other packages obsoleted by this package

 --conflicts           list capabilities this package conflicts with

 --changelog           show changelog for this package

 --location            show download URL for this package

 --nevra               show name-epoch:version-release.architecture info of


 --envra               show epoch:name-version-release.architecture info of


 --nvr                 show name, version, release info of package

 -s, --source          show package source RPM name

 --srpm                operate on corresponding source RPM

 --resolve             resolve capabilities to originating package(s)

 --alldeps             check non-explicit dependencies (files and Provides:)

                       as well, defaults to on

 --exactdeps           check dependencies exactly as given, opposite of


 --recursive           recursively query for packages (for whatrequires)

 --whatprovides        query what package(s) provide a capability

 --whatrequires        query what package(s) require a capability

 --whatobsoletes       query what package(s) obsolete a capability

 --whatconflicts       query what package(s) conflicts with a capability

 -g, --group           query groups instead of packages


                       filter which packages (all,optional etc) are shown

                       from groups

 --archlist=ARCHLIST   only query packages of certain architecture(s)


                       set value of $releasever in yum config and repo files


                       limit query to installed / available / recent /

                       updates / extras / all (available + installed)/

   repository (default) packages

--installed           limit query to installed pkgs only

 --show-duplicates     show all versions of packages

 --show-dupes          show all versions of packages

 --repoid=REPOID       specify a repo to query 


                       specify additional repos to query.


                       specify repos to disable


                       specify repoid & paths of additional repositories -

                       unique repoid and complete path required Example.


 --plugins             enable yum plugin support

 --quiet               quiet output, only error output to stderr (default


 --verbose             verbose output (opposite of quiet)

 -C, --cache           run from cache only

 --tempcache           use private cache (default when used as non-root)

 --querytags           list available tags in queryformat queries


                       config file location

 --tree-requires       list recursive requirements, in tree form

 --tree-conflicts      list recursive conflicts, in tree form

 --tree-obsoletes      list recursive obsoletes, in tree form

 --tree-whatrequires   list recursive what requires, in tree form

 --search              Use yum’s search to return pkgs


                       search fields to search using --search

Thursday, 9 May 2013

Centos 6/RHEL install Print pages to PDF for Firefox Web Pages

Not strictly for Linux but a very handy tool nonetheless, a Web Page PDF Printer Plugin for Firefox. There are probably a number of occasions when you view an article online and want to download it to save, but the only format available is a html page. Print pages to PDF is a handy Firefox Plugin which facilitates the downloading of suitable articles in PDF fomat.

Based on Wkhtmltopdf, QT and Webkit, it is a powerul little tool for converting chosen pages to PDF. All that is required on Linux is the X11 client libraries, which you will have if running a desktop. So as you can see below just drop it down from the toolbar as and when you need it. Capture the page and put it away.

You can add a button to the toolbar menu if you use it on a regular basis, so pdf on speedbutton is available. So head over to Print to Pages and get your PDF button. If you need Firefox also then version 20 for Centos/RHEL with some cool features is available below as PrintPagestoPDF won't work on later versions.


Firefox20 64bit 

Sunday, 5 May 2013

Centos 6/RHEL Mount Logical Volumes using Live CD

Occasionally, you might have a problem develop which stops you gaining access to your system either as user or root, even to do a rescue operation. This could be for a variety of reasons, such as you change a crucial script or an external script you use causes a system lock up. 

It means you have to mount the Logical Volumes on which your Centos 6 system is based, find the offending file or script and fix, delete or replace it using an alternative method.

So you need to perform a rescue operation whilst using a Live CD to gain access, because in the case of user/root login failure this may probably be the best or only way to do it.

As a recent example a maven shell script in the /etc/profile.d directory was incorrect and caused all system commands to disappear, ie no ls, cat, rm, su, sudo. Additionally, it prevented logging on as anyone, so the steps below were taken in order to fix the problem.

Use a Centos or Debian Live CD because when you are attempting a rescue you don't want the additional stress of hunting down needed but potentially obscure packages, you just want to be able to get them easily, do the job and finish. The package we need here is lvm2 which is in both Centos and Debian repos.

So first download Centos 6.4 Live CD iso or Debian Live CD iso and burn it to a disk or put it on a USB stick. (Not described in this post). 

Once done, boot from it, whether disk or USB and once you are in the live environment you can bring up the terminal emulator or use the console, run fdisk and list the available drives. Use
Ctrl+Alt+F4 to stop X server and go to the console. The live disk uses sudo for root access.

$ sudo fdisk -l

  Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        3891    31254426    7  HPFS/NTFS
/dev/sda2            3892        3955      512000   83  Linux
/dev/sda3            3955       38914   280803328   8e  Linux LVM

The sda3 entry is not suitable to mount in the normal manner because you do not have the correct path, so you need to do a little more probing to find this.

First install the tools package with apt

$ sudo apt-get install lvm2

And issue the command to find the LV Group which is under VG

$ sudo pvs                  

 PV         VG        Fmt  Attr PSize   PFree
 /dev/sda3  vg_centos lvm2 a--  267.79g    0 

'vg_centos' is fine to start with, but we need a little more.

Issue the command to display the directories and path.

$ sudo lvdisplay            

 --- Logical volume ---
  LV Path                /dev/vg_centos/lv_root
  LV Name                lv_root
  VG Name                vg_centos
  LV UUID                tiDVyK-ct0t-8GOJ-UuRn-uDWI-95jX-bqQWfy
  LV Write Access        read/write
  LV Creation host, time Centos, 2013-04-21 20:13:14 +0100
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  --- Logical volume ---
  LV Path                /dev/vg_centos/lv_home
  LV Name                lv_home
  VG Name                vg_centos
  LV UUID                yUzkjk-RMk0-0k77-NCkh-l2WB-y0So-gMzjDT
  LV Write Access        read/write
  LV Creation host, time Centos, 2013-04-21 20:13:29 +0100
  LV Status              available
  # open                 1
  LV Size                211.84 GiB
  Current LE             54231
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

You will probably have a swap also but above just shows the directories we are interested in.  

The LV Path is what we use to mount the Logical Volumes, and now
we have the full and correct path, they can be mounted as normal, we just need a directory to mount them into, so create a newroot directory. (As unprivileged user or root)

$ sudo mkdir newroot                      

$ sudo mount /dev/vg_centos/lv_root /newroot

$ sudo mount /dev/vg_centos/lv_home /newroot

Depending which directory you want to access. 

Use vgchange to make them active 

$ sudo vgchange -a y
  3 logical volume(s) in volume group "vg_centos" now active

Now you can navigate to the /newroot directory either in the terminal or using the file manager and access the file you need to fix, replace or delete.

Straighforward mounting of the Volume Group in Centos 6 using
a Live CD.

Using chroot

Use chroot if necessary as in the image below, doing this and then running the mount command shows the newly mounted volumes for the 'damaged' system as they appear in the newroot directory

Test already mounted volumes

You can test what is mounted by using one of below as root

# df -H

Filesystem             Size   Used  Avail Use% Mounted on
                        53G   5.5G    45G  11% /
tmpfs                  3.2G      0   3.2G   0% /dev/shm
/dev/sdb2              508M    33M   450M   7% /boot
                       224G   9.0G   204G   5% /home

# mount

/dev/mapper/vg_centos-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sdb2 on /boot type ext4 (rw)
/dev/mapper/vg_centos-lv_home on /home type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)