Tuesday, 26 June 2012

Centos 6/RHEL install Wine

A short post on installing Wine on Centos 6/RHEL and other rpm based distros if you still need to use Windows apps and are not using any kind of Dual Boot or Virtual Machine set up as it can be helpful for the odd program from which you may want to use in Linux.

If you haven't yet installed Linux then you can install Centos 6 from a netinstall cd and configure a Fluxbox lightweight desktop with Thunar and Rxvt terminal. Alternatively you can use a distro or setup of your own.

Wine is in the Epel repo so make sure you have it installed with

$ sudo rpm –-import http://mirrors.coreix.net/fedora-epel/RPM-GPG-KEY-EPEL-6

$ sudo rpm -Uvh http://mirrors.coreix.net/fedora-epel/6/i386/epel-release-6-8.noarch.rpm

Install the package.

$ sudo yum install wine

Configure it.

$ winecfg

Brings up the config dialogue box where you can check paths to folders, sound, graphics etc and add programs.

It will also ask to install a gecko file, so allow this also.

To add a program first go to the .wine hidden folder in your home directory and load the exe into the program files directory there.

Then open up winecfg and click the 'add application' button and browse to it.

You can also click on the exe and install it that way into the program files directory, again within the .wine hidden folder.

The most common method for standard .exe installation files is to right click and select 'open with Wine Windows Program Loader' and allow the program to 'install' into the Program Files directory within .wine folder as if using a virtual machine.
Once you've 'installed' it you can remove the original .exe file.
Some .exe files run in 'Wine Windows Program Loader' without installation.

There are various options depending which kind of file you are using and whether it needs to be installed or will run directly.

You can send a shortcut to the Desktop so you can run the program without running wine, do this by browsing to the program files directory in the .wine hidden folder,right clicking and sending to desktop.

Sometimes, a program won't run from the Desktop shortcut, in which case you would just browse to it in the hidden .wine folder and run it from there.

Now you can use the odd Windows program or some of the portable apps which are available to download.(See below)

On encoding media files, if you download zConvert for Windows and install it on Wine (change install path to 'C:\Program Files\zConvert') you can encode media files to a variety of formats and play them on a wide range of devices.(Put them in the /home/<user>/.wine/drive_c/Program Files/zConvert directory for best results)

(For video encoders which work well natively check out Transcoder Arista and Avidemux)


Another trick you can use is to download the free apps from
http://www.lupopensuite.com/, and copy the apps you want from the apps folder to put them into wine on Linux.

Lupo apps which work in wine are FastStone PhotoResizer/Capture/Image-Viewer, Infanview, OperaUSB, AbiWord Portable, OikoCssEditor, PDF-Exchange Viewer, Universal Extractor and others. Also 7zip, which is handy for extracting iso files as well as standard zip files.

See Fluxbox key bindings for more. 

Generally, Wine runs very well on Centos/RHEL and is probably easier to use than on Ubuntu.

One thing you have to remember is that wine installs pulse audio, so if you prefer alsa you have some extra configuration to do, or remove pulse altogether as you don't actually need it for wine.

More repos








Saturday, 16 June 2012

Centos 6/RHEL Netbeans Ide installation

A short post on installing Netbeans Ide on Centos 6/RHEL or similar based rpm distros.

Netbeans is a free multi-platform IDE from Sun and encompasses a wide range of web technologies, including Java, Ruby, PHP, C++ and quite a number of others.

The latest edition of Netbeans has full support for HTML5, CSS and JavaScript. It now includes an HTML project wizard which allows you to select popular boilerplate templates and JavaScript frameworks.

It is very straightforward and simple provided you have the Sun Java JDK installed. I recommend following the JDK install guide if you haven't.

Once Java is installed go to http://netbeans.org/index.html and download the install pack to your home folder.

I used the Java EE version, chmod it u+x

$ chmod u+x netbeans-7.2.1-ml-javaee-linux.sh

to make it executable, then run the file.                     

$ ./netbeans-7.2.1-ml-javaee-linux.sh      


Make any selections you require and proceed.

Install it to ~/.netbeans-7.2.1

(A hidden folder in your home folder)

At the end you will be asked to submit usage information.

Finish.


Open the program by clicking the icon it placed in your Desktop folder (if using Fluxbox) or on your Desktop (using gnome or similar)

Allow it to download junit before you proceed.


A large selection of plugins is available also.


Fluxbox users can also add the path to their ~/.fluxbox/keys file, the path being in this case

/home/anton/.netbeans-7.2.1/bin/netbeans




See Fluxbox key bindings for more.

Centos 6 repos 







Centos 6/RHEL LibreOffice-3.5 installation (NO openJDK)

This short post is to install LibreOffice on Centos 6/RHEL or similar rpm based distro without the unwanted packages from the repo.

LibreOffice is a very nice lightweight alternative to Microsoft Office and Open Office and is very well suited for Centos 6 (or Fedora/Red Hat). With a full set of features such as Spreadsheet, Presentation, Database and Formula it makes a very useful addition to your Linux Desktop. It is very easy to install with a few simple commands. 

Update The pre-release 4.0 edition now has export chart as graphic facility in Calc, so charts can be saved separately.

Note: It can be installed from the repo BUT that comes with packages you may not want such as openjdk and others, this method installs ONLY LibreOffice and we use the Sun JDK for the Java dependencies with NO openJDK necessary whatsoever.

You will need
  • Java installed, follow the tutorial here if not, it covers the Sun JDK and plugins.
  • The tar.gz installation pack from LibreOffice site.
So first download

LibreOffice3.5 from http://www.libreoffice.org

To your home directory

Extract the contents

$ tar xvf LibO_3.5.4_Linux_x86_install-rpm_en-US.tar.gz

(or x86_64)

Move to the extracted directory

$ cd LibO_3.5.4rc2_Linux_x86_install-rpm_en-US

(or x86_64)

Move to the RPMS directory

$ cd RPMS

Then install all the rpm files

$ sudo rpm -ivh *.rpm

Now move to the desktop-integration folder

$ cd desktop-integration

A self explanatory choice of 3 is given

libreoffice3.5-freedesktop-menus-3.5.4-2.noarch.rpm
libreoffice3.5-mandriva-menus-3.5.4-2.noarch.rpm
libreoffice3.5-suse-menus-3.5.4-2.noarch.rpm

$ sudo rpm -ivh libreoffice3.5-freedesktop-menus-3.5.4-2.noarch.rpm

Is the one you need for Centos/RedHat

Finish

To run it just type

$ libreoffice3.5                (or the version you use)

(Ensure you have the desktop integration package installed)



The Desktop integration pack is required even though it doesn't actually place anything on the Desktop in Fluxbox.

If using Fluxbox you can add an entry to your ~/.fluxbox/keys file, for example 

$ vi ~/.fluxbox/keys

Mod1 o : ExecCommand libreoffice3.5

And then just hit Alt + o to run it.

See Gnumeric for spreadsheet program. 

See Fluxbox key bindings for more.




Sunday, 10 June 2012

Centos 6/RHEL Install Genuine Nvidia Drivers

There are two ways to install drivers for Nvidia cards on Centos 6/RHEL, one is to use the Kmod from the repo and the other, slightly more involved, is to use the driver direct from Nvidias site.

This tutorial is to install the Nvidia drivers from Nvidia's site
and although the Kmod packages are the Nvidia drivers repackaged, you may still have some reason to use Nvidia's Linux drivers. You can accomplish this task using the Kmod drivers also.
 
We will not be using any repositories and if you have installed your Centos 6 as per this tutorial and set up the kernel correctly you should not get any errors about the wrong compiler.

We are changing the defaults in /etc/inittab because 'telinit 3' and 'Ctl+Alt+F4" do not always disable X server properly and the Nvidia script complains.

I have also put the section on kernels at the bottom of this page so you can fix them, if necessary, before proceeding. It is not difficult to do, simply a matter of removing the out of date ones and updating/installing the matching kernel-headers/kernel-devel files.

You will need

  • The Genuine Nvidia Driver/Script from Nvidia
  • A disable-nouveau.conf file  (which you will create)
  • A line in /etc/grub.conf to disable nouveau from loading.
2 commands to check your kernels match.


$ uname -r                                

$ rpm -qa kernel-devel     

If the numbers don't match scroll down to the bottom of this page to the kernels section, follow it and return here.

Install compile tools if not already installed.

$ sudo yum -y install gcc gcc-c++ automake autoconf make         

Getting the Nvidia Driver

Go to http://www.nvidia.com/Download/index.aspx?lang=en-us and select your driver, it will have a .run or .sh extension, download to your home directory. The one I used is NVIDIA-Linux-x86-295.49.run      

$ chmod u+x NVIDIA-Linux-x86-295.49.run    make it executable

(substitute the above file for your version of it)

Leave it in your home directory.

Blacklisting nouveau driver.           

$ sudo vi /etc/modprobe.d/disable-nouveau.conf   enter

blacklist nouveau options nouveau modeset=0

and save the file 

See Vim Editor for vi commands                                 

$ sudo cp /etc/grub.conf /etc/grub.conf.bak    

Backup grub.conf  
                                       
$ sudo vi /etc/grub.conf                

Find this section

  kernel /vmlinuz-2.6.32-220.el6.i686 ro root=/dev/mapper/vg_centos-lv_root rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=uk LANG=en_US.UTF-8 rd_LVM_LV=vg_centos/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 rhgb quiet crashkernel=auto rd_LVM_LV=vg_centos/lv_root rd_NO_DM
initrd /initramfs-2.6.32-220.el6.i686.img

After the line rhgb or somewhere appropriate enter this line

rdblacklist=nouveau nouveau.modeset=0    

Save the file. Now change the run level 

$ sudo vi /etc/inittab       

Scroll down and change default to '3'   

Save, exit & reboot. 

Login as root in console mode.                       

Installing the driver

Go to the Nvidia script in your home directory.

# cd /home/<user_name>        

# ./NVIDIA-Linux-x86-295.49.run     hit enter to run it

Substitute the above file for your version of it.

Follow the dialogue box, largely 'accept' and 'write to xorg.conf' at the end, and your drivers are installed. If you get an error message about the wrong compiler version then scroll down to the bottom of this page and follow the section on how to update the kernel in Centos6/RHEL

# vi /etc/inittab           change back to '5'

Reboot (Not telinit 5)

Log on as a normal user and open up this tutorial to finish off your settings.

$ lspci | grep VGA           shows current video hardware

Setting up with Nvidia settings

Open a terminal

$ su -c 'nvidia-settings'              enter password

The Nvidia settings dialogue box will open so you can adjust resolutions and refresh rates etc in the 'X Server Configurations' tab and save everything to xorg.conf to make it permanent and keep the same setup on reboot.

A thread on Nouveau & Modeset in Slackware.

To reverse the procedure if you have to use a different graphics card then just

$ sudo rm /etc/X11/xorg.conf /etc/modprobe.d/disable-nouveau.conf 

$ sudo cp /etc/grub.conf.bak /etc/grub.conf

Check screen resolution

If it is not obvious and you want to check resolution

$ xdpyinfo | grep 'dimensions'


dimensions:    1024x768 pixels (413x260 millimeters)

$ xrandr | grep '*'

1024x768       75.0*    60.0
 

Switch cards on a Laptop.

If using a laptop with both onboard and dedicated cards then you can use Bumblebee, which enables you to switch between them.
Bumblebee is in both Elrepo & Atrpms repos as 'bbswitch', so install one of them and issue the command

$ sudo yum -y --enablerepo=elrepo install bbswitch 

Atrpms repo may also add a new kernel so you can either keep it and remove old/update to new as below, or just remove it and keep your current ones.

If you don't wish to install the repos you can just download the package from either one, in Elrepo it is listed as 'bumblebee'.

Kernels

To ensure smooth compiling set up the the supporting  kernel files, you should do this before you install Nvidia drivers.

Reinstall Nvidia Drivers after a kernel upgrade

It does not involve much after a kernel upgrade to re install the drivers, because the files /etc/modprobe.d/disable-nouveau.conf & /etc/grub.conf keep their lines intact, so all you need to do is re run the Nvidia driver (old one or download a new one)

Provided that you have set up the new kernel wih matching devel, firmware and headers as above then the steps would be similar to below.

Remove xorg.conf  (or you can't boot to graphical interface)

$ sudo rm -rf /etc/X11/xorg.conf   

Get your driver in place and chmod it as above

$ sudo vi /etc/inittab        (set to 3)

Reboot, login as root, cd to home directory and run the driver package again, it will remove the old driver and write a new xorg.conf file. Then set inittab back to 5, reboot and run

$ su -c 'nvidia-settings'

Remove driver completely 

Run the driver again as above but pass the --uninstall flag to it

$ rm -rf /etc/modprobe.d/disable-nouveau.con

& take out the blacklist-nouveau lines in /etc/grub.conf
         








Saturday, 9 June 2012

Centos 6/RHEL Java JDK7 with Eclipse & Ant installation

This tutorial is to install and set up Sun Java JDK 7 and Eclipse on the Centos 6 as described here or Fedora/Red Hat and rpm based distros. I prefer to use Sun Java 7 as the default JDK so I dont see much point in running the openJDK version, I generally remove it if it gets installed. Some programs such as Jenkins and IntelliJIDEA require the Sun version, so you might as well use it exclusively, it is free to use after all.

Additionally, the JDK includes the JRE so again you may as well just use the JDK and configure browser plugins to use its JRE with the 'alternatives' command as you will see below. If you just want Java JDK then you can ignore the section on Eclipse.

If you are using the Android SDK with Eclipse you might want to stick with the 32 bit OS, as 64 bit is a little tricky to get working properly, but its entirely up to you.


Setting up JDK 7


Install jpackage-utils if not already installed


$ sudo yum -y install jpackage-utils

You will need Java before installing Eclipse so first download it from http://www.oracle.com  The current version is jdk-7u6.


For 32bit use jdk<file_name>i586.rpm package


$ sudo rpm -Uvh <file_name>.rpm   

  
For 64bit use jdk<file_name>x64.rpm version

$ sudo rpm -Uvh <file_name>.rpm

(Ignore missing file errors)  

 Add the JAVA_HOME path/variable to ~/.bashrc

$ sudo vi ~/.bashrc      


Place as below under 'User specific aliases and functions'

export JAVA_HOME="/usr/java/jdk1.7.0_06"

export JAVA_PATH="$JAVA_HOME"
export PATH="$PATH:$JAVA_HOME"

See Vi Editor for commands


Change the version number to yours, save & source the file

$ source ~/.bashrc
     
Make sure the alternatives is set correctly, if its not

$ sudo rm /var/lib/alternatives/java     


Will purge the old setup.

(On a new installation it may show 'not found')

then set it up again with your new jdk.     


$ sudo alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_06/bin/java 1

$ sudo alternatives --config java     

Hit enter for the default or select a number

This will set your new jdk as the default alternative, to check


$ alternatives --display java   


java - status is manual.

 link currently points to /usr/java/jdk1.7.0_06/bin/java
/usr/java/default/bin/java - priority 1
Current `best' version is /usr/java/jdk1.7.0_06/bin/java.

$ which java                           

/usr/bin/java         


$ java -version                        


java version "1.7.0_06"

Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
Java HotSpot(TM) Server VM (build 23.2-b09, mixed mode)   

$ echo $JAVA_HOME                     


/usr/java/jdk1.7.0_06


Reboot.


If you just wanted Java you can skip the next chapter and go to the one below on browser plugins.

Setting up Eclipse


Now go to http://www.eclipse.org and download the Eclipse IDE version you require to your home directory. Get the 'tar.gz' variant. I use the Indigo 3.7 version as I find it works fine.


Eclipse is in the Centos repos, however, that version also brings with it a lot of other packages which you may not need like openJDK and a few others, so I find it better to just get an eclipse.org version and add to it what I require.


$ cd /usr/local         


$ sudo su        


# tar xvf ~/<eclipse_tar_file_name>


   So you have eclipse installed at /usr/local/eclipse/

   Now change the permissions to run it

# chown -R <user_name> eclipse

# chmod -R 700 eclipse

Revert back to normal user


# exit


create a symlink to /usr/bin

$ sudo ln -s /usr/local/eclipse/eclipse /usr/bin/eclipse


Create a symlink/shortcut to open it

$ cd <path_to_where _you _want _the _shortcut>


$ ln -s /usr/bin/eclipse              


Now you can do Alt+F2 and type 'eclipse' or click on your shortcut wherever you placed it to run eclipse. (I put one in the Desktop folder of thunar) If you are using Fluxbox you can put a command in the 'keys' file in the /home/<user_name>/.fluxbox hidden directory - enter at the top something like 'F4 : ExecCommand eclipse' and you can run it by hitting F4 or whatever.


Apache Ant 

You can install Ant now if you are going to use it, the binary 1.7 version can be obtained from below, it's for any arch.

Ant-1.7.1noarch.rpm 

You may need to install dependencies

$ sudo yum -y install java-devel xerces-j2 xml-commons-apis

get it in to your home directory then install it with

$ sudo rpm -Uvh ant-1.7.1-7.jpp5.noarch.rpm

Set up a few extra variables now in your ~/.bashrc

$ sudo vi ~/.bashrc 

If you have set up the $JAVA_HOME as above, then between the 
JAVA_PATH & PATH variables, first place your ANT_HOME

ANT_HOME="usr/share/ant"          

and append it to the PATH so your file looks similar to below

export JAVA_HOME="/usr/java/jdk1.7.0_06"
export JAVA_PATH="$JAVA_HOME"
ANT_HOME="usr/share/ant"
export PATH="$PATH:$JAVA_HOME:$ANT_HOME"


You may want to put in the CLASSPATH export and the JAVA_FONTS if you are using them.

export CLASSPATH=.:/usr/java/jdk1.7.0_06/lib/tools.jar
JAVA_FONTS=/usr/share/fonts/truetype
export JAVA_FONTS

Don't forget to source the file when done.

$ source ~/.bashrc

So your .bashrc file might now look similar to below

export JAVA_HOME="/usr/java/jdk1.7.0_06"
export JAVA_PATH="$JAVA_HOME"
export CLASSPATH=.:/usr/java/jdk1.7.0_06/lib/tools.jar
ANT_HOME="usr/share/ant"
export PATH="$PATH:$JAVA_HOME:$ANT_HOME"

JAVA_FONTS=/usr/share/fonts/truetype
export JAVA_FONTS

Leave off anything you are not using.

With this all done you should now be able to run Ant directly from the command line after moving to the directory containing your build.xml file in the workspace using the command

$ ant -f build.xml

So Ant can be used both in and outside of Eclipse.

See Fluxbox key bindings for more.


Fixing Browser plugins 


Firefox is in the standard repos and Google-Chrome is available as an rpm package so installing is straighforward.


First, make sure Firefox is installed


(Needed for the plugins directory)


$ sudo yum -y install firefox


You may have to create a plugins directory, if so


$ sudo mkdir /usr/lib/mozilla/plugins      


To fix the java plugins issue the following commands

32bit

$ sudo alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/jre/lib/i386/libnpjp2.so 20000


64bit

$ sudo alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jdk1.7.0_06/jre/lib/amd64/libnpjp2.so 20000

this will install the plugin using the JRE from within the JDK package, no need for a separate JRE package.

Oracle's site and other web tuts state you should use the 32 bit JRE for web applets on a 64bit system, I have found this unnecessary and just use the JDK above.

Now visit http://javatester.org/ with firefox to test the java plugin works. You should find it does and also that java in chrome works now aswell.


So thats it, installed Java 7 and plugins, with Eclipse from eclipse.org, using just 2 downloaded packs and without messing up your system with a lot of other things you dont require like openJDK.


You can switch between installed versions like 6 & 7 and others.

Other 'alternatives' commands for java


  • java
$ sudo alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_06/jre/bin/java 20000


  • javaws


$ sudo alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.7.0_06/jre/bin/javaws 20000


  • Java Browser (Mozilla) Plugin 32-bit 

$ sudo alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jdk1.7.0_06/jre/lib/i386/libnpjp2.so 20000


  • Java Browser (Mozilla) Plugin 64-bit 

$ sudo alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jdk1.7.0_06/jre/lib/amd64/libnpjp2.so 20000


  •  javac if you have JDK (Java Development Kit) 

$ sudo alternatives --install /usr/bin/javac javac /usr/java/jdk1.7.0_06/bin/javac 20000


  • jar if you have JDK (Java Development Kit)

$ sudo alternatives --install /usr/bin/jar jar /usr/java/jdk1.7.0_06/bin/jar 20000


I have put together an Eclipse Keplar with Java JDK which runs from a USB device on Linux systems, (any, not just Centos) I have tested it on a couple of systems and it appears to be fine.

You can download and try it from the link below. When you have got it in your home folder move in to it and chmod the Eclipse executable before running it, it will find its own Java in the enclosed jre directory and it will probably ask to create a workspace in /home/<user>.

$ cd eclipse

$ chmod u+x eclipse

Download Portable Eclipse with JDK.



Centos 6/RHEL WEP Wireless Setup

This tutorial is to set up WEP wireless on the Centos 6 Minimal Desktop although it can be used for other rpm based distros, for anyone who has a router that will only encrypt in WEP, or just live where only WEP is available, otherwise you may benefit from the Wireless WPA2 with Static IP Tutorial.

We just want to connect a single computer via wireless so it shouldn't be a big deal, after all this is not some multiple domain server monster with many different configurations.


I went for the simple command line method and set up a script after setting my router to encrypt the key via basic WEP in 128bit open format (not shared or restricted)


WEP is easy to crack and shouldn't be used normally, especially in cities and densely populated areas as you are bound to have someone nearby who will crack your wireless at the drop of a hat.


You can set it to hidden ssid & use 128bit encryption with a hex key, which should help a little if you are forced to use WEP.

Use a little common sense, in critical situations you'd be advised NOT to do it this way but if your router only has WEP encryption (rare now) than you can get away with this method.

This method is for WEP using DHCP



You will need
  • A detected wireless device
  • dhcp and wireless-tools installed
  • The ifcfg-wlan0 file described below
  • The bash script described below
The procedure is as follows, this assumes that you actually have installed a driver for your pci/usb wireless device and that it is detected by your OS. Your system may call wlan0 something else, likewise with eth0.

Get dependencies

$ sudo yum -y install dhcp wireless-tools


Check your network

$ sudo ifconfig -a              





If wlan0 is not showing then there is a problem with your drivers and you cannot proceed. Try  http://linuxwireless.org/en/users/Drivers/ to see if there is one for your device. 

You can also use lsmod

$ lsmod | less

Scroll down with up/down arrows to see if it shows up.

Additionally, you can use getinfo if you install it.

$ getinfo.sh network

Set up the router.

Set up your router with a WEP encryption key in open 128bit format.


You can give it a hex key or asci (string) which is converted by the router  to hex, some routers don't give you the converted key back in which case get a calculator that will convert a string to hex, or use the online converter below, and get the value that way. I use a phrase converted to a hex value.

(If your string is 'thebigfatlazydog' just enter that into a converter and get the hex value back, this hex value is used in the command to connect. Some applications require you to enter the hex value even though you may have set a string in your router settings)


So use the online converter 

The WEP encryption has to be open , not shared or restricted.

Building the ifcfg-wlan0 file.


We will write a configuration file called ifcfg-wlan0 (or the name it is detected as, remember, we're doing this manually) in /etc/sysconfig/network-scripts/ it should look similar to:


TYPE=Wireless

DEVICE=wlan0          
BOOTPROTO=dhcp
BROADCAST=192.168.0.255
HWADDR=48:02:2a:91:63:90
NETMASK=255.255.255.0
ONBOOT=no
ONHOTPLUG=yes
PEERDNS=no
USERCTL=yes
IPV6INIT=no
ESSID=minimallinux
CHANNEL=6
MODE=Managed
RATE=150Mb/s

Now issue the dmesg command to obtain MAC/HWADDR

$ dmesg 


Or if you already have a ifcfg-wlan0 file

$ sudo grep wlan0 /var/log/dmesg
(you'll probably have to unplug and replug your device, especially usb)

****************************************************************

Look for 'ADDRCONF(NETDEV_UP): wlan0: link is not ready' and  'MAC Address =
48:02:2a:91:63:90

OR similar to

usb 1-7: New USB device found, idVendor=0bda, idProduct=8176

then lower down the output

EEPROMVID = 0x0bda
EEPROMPID = 0x8176




_ReadMACAddress MAC Address from EFUSE = 48:02:2a:91:63:90


****************************************************************

which tells you that your device is detected and has a MAC Address of 48:02:2a:91:63:90 (which you will need for your ifcfg-wlan0 file, that is the HWADDR)

Now build the ifcfg-wlan0 config file


$ sudo vi /etc/sysconfig/network-scripts/ifcfg-wlan0 and enter the above with the appropriate alterations to suit your system.


See Vim Editor for vi commands 

You should also be able to get the BROADCAST, NETMASK and HWADDR entries from the 'ifconfig -a' command


Once the config file is in place with the correct details reboot the computer.


Making the connection.


First make sure that dhcp and wireless-tools are installed


$ sudo su                    


# yum -y install dhcp wireless-tools


Stop existing network connection


# service NetworkManager stop 


Or disable it
             
# chkconfig --level 2345 NetworkManager off

You can check by issuing


# chkconfig --list NetworkManager     

which should show all levels at off.

# ifconfig eth0 down                           


To take down eth0

Now issue the command


# ifconfig wlan0 up         


To bring up the interface

# iwlist wlan0 scan         

You should get output like

wlan0     Scan completed :

          Cell 01 - Address: 1C:BD:B9:BE:8A:26
                    ESSID:"minimallinux"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.437 GHz (Channel 6)
                    Encryption key:on
                    Bit Rates:300 Mb/s
                    Quality=100/100  Signal level=100/100

which shows that it found my network with essid 'minimallinux' protected by an encryption key on channel 6 at 2.437Ghz, the ESSID goes into the /etc/sysconfig/network-scripts/ifcfg-wlan0 file.


Now issue the command


# iwconfig wlan0 essid minimallinux key 73237255565679686974657979


the essid being the name of your wireless network and the key being simply the hex key you have designated (or converted from a text string)


No output back is fine, after around 10 seconds issue the command


# dhclient wlan0             


Obtains an address via dhcp, again no output back is fine.

You can ping your router to check


# ping 192.168.0.1              (use your router address)


64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.826 ms

64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.800 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=1.36 ms
64 bytes from 192.168.0.1: icmp_seq=4 ttl=64 time=0.811 ms
64 bytes from 192.168.0.1: icmp_seq=5 ttl=64 time=0.930 ms
64 bytes from 192.168.0.1: icmp_seq=6 ttl=64 time=0.839 ms

Means it is working             


# ping yahoo.com                


64 bytes from ir1.fp.vip.mud.yahoo.com (209.191.122.70): icmp_seq=1 ttl=46 time=153 ms

64 bytes from ir1.fp.vip.mud.yahoo.com (209.191.122.70): icmp_seq=2 ttl=46 time=153 ms
64 bytes from ir1.fp.vip.mud.yahoo.com (209.191.122.70): icmp_seq=3 ttl=47 time=148 ms
64 bytes from ir1.fp.vip.mud.yahoo.com (209.191.122.70): icmp_seq=4 ttl=46 time=166 ms

That's it, we are online.





If you reissue the dmesg command now, the line


ADDRCONF(NETDEV_UP): wlan0: link is not ready


  changes to


ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready


If you reissue the ifconfig -a command as root again it should show your connection up, this time with the address etc that it has been assigned like this


wlan0     Link encap:Ethernet  HWaddr
48:02:2a:91:63:90
          inet addr:192.168.0.100  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::4a02:2aff:fe93:c74/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:644 errors:0 dropped:5771 overruns:0 frame:0
          TX packets:746 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:233983 (228.4 KiB)  TX bytes:153079 (149.4 KiB)

The connection script.

To avoid having to type all those commands every time, you can put everything in a little script and place it in the /usr/local/bin directory, issuing one command to start it.

# vi /usr/local/bin/wireless.sh       

Type into it

#! /bin/bash

ifconfig wlan0 up
iwconfig wlan0 essid minimallinux key 73237255565679686974657979
sleep 10
dhclient wlan0

Changing the essid and the key to yours. Save & chmod it.


# chmod u+x /usr/local/bin/wireless.sh  


To make it executable

Now when you log on you can open a root terminal


$ sudo su

# wireless.sh 


To start your wireless connection.

Static IP and Onboot

If you use wireless exclusively then you might want to give it a static IP and have it connect on booting the system. In this case you won't need the shell script, but create a keys file for the router key and to put some extra lines in the ifcfg-wlan0 file.

$ sudo vi /etc/sysconfig/network-scripts/keys-wlan0

Put in the file

KEY=YOURWEPKEYSTRINGORHEX

Change the lines in ifcfg-wlan0

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-wlan0

BOOTPROTO=static
DHCPCLASS=
IPADDR=192.168.0.100       #pick an IP in a valid range
GATEWAY=192.168.0.1        #your router IP address


So that's Centos 6 with a wireless usb and WEP standard encryption.


WPA2 requires the use of either wpa_supplicant and hostapd or Wicd, NetworkManager and similar programs, so thats for another post, as is wireless with a static IP & network bridge.

See also the post on Realtek USB Wireless for Centos 6