January 30, 2013

Java SE 6 Reaches End of Life (EOL) in February 2013

Oracle has announced that the end of life (EOL) of Java SE 6 has been set to February 2013. Which means that if you have not already upgraded to Java SE 7, now is the time. You can read more about the Oracle Java SE Support Roadmap here.

And for you folks that think that Java SE 7 is a new thing, well, I'm afraid that you are poorly updated. The Java SE 7 was released in February 2011.

January 19, 2013

Common apt-get and dpkg commands for Ubuntu (Debian)

If you have graphical interface for Ubuntu, you probably want to run synaptic, but sometime you don't and then it is good to know you Debian packages commands.

Update local cache of available packages

$ sudo apt-get update

Search after package

$ sudo apt-cache search <search_string>

Find out if a package is installed

$ sudo dpkg -s <package_name>

To install package

$ sudo apt-get install default-jdk

Get information about installed packaged

$ sudo dpkg -s <package_name>

Uninstall package

$ sudo apt-get purge <package_name>

How to Install Atheros AR8161 Ethernet Controller on Ubuntu 12.10 (Quantal)

Today I had a hard time to install Atheros AR8161 Ethernet Controller on Ubuntu 12.10 (Quantal). Below I will give you a fast guiding how I did.

First a few words about some common network commands that will help you along the way.

  • lspci - list all PCI devices
  • lshw - list hardware
  • lsmod — program to show the status of modules in the Linux Kernel
  • modinfo — program to show information about a Linux Kernel module
  • modprobe — program to add and remove modules from the Linux Kernel

For more detailed information, please use the man command, e.g. man lspci.

And here are a few examples of running the above commands.

$ sudo lspci -vv | grep Ethernet
02:00.0 Ethernet controller: Atheros Communications Inc. AR8161 Gigabit Ethernet (rev 08)

Now how to solve your network problem. Whenever you have problem always try to solve it by reading the official vendor pages. I know I do the same thing ask google and millions of answer turns up, but not all of them are good. For me, I first tried to install the drivers from compat-wireless, because I was to lazy to install each official ubuntu packages and they turned up to be quite buggy. So always use official stuff, before going into more experimental things.

So lets do it the official way and that is to use http://askubuntu.com. And here the answer comes up http://askubuntu.com/questions/217361/how-do-i-install-drivers-for-the-atheros-ar8161-ethernet-controller-on-64-bit-12. AND PLEASE USE ANSWER 1, the other will lead you astray.

January 15, 2013

Installing and Using PGP with GNU Privacy Guard (GnuPG) on RHEL 6.3

Introduction

In this blog I will show you how to use PGP client GNU Privacy Guard (GnuPG) on RHEL 6.3. PGP can be used to encrypt files which can be stored somewhere on remote disc or by sending as attached files.

Installation

Installation was quite smooth, except founding the missing dependency package pinentry-gtk, which should be installed automatically.

$ yum install gnupg2 pinentry-gtk

Test your installation

A simple test to see that GnuPG is installed properly is to ask for each version.

$ gpg --version
gpg (GnuPG) 2.0.14
libgcrypt 1.4.5
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: ~/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA
Cipher: 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, 
        CAMELLIA192, CAMELLIA256
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

Setup

Creating Private Key Pair

The first thing to do, after installation was successful, is to generate the necessary keys used for encrypting and decrypting files. To generate you private key pair, do the following.

$ gpg --gen-key 
gpg (GnuPG) 2.0.14; Copyright (C) 2009 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection? 
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 
Requested keysize is 2048 bits
Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0) 2y
Key expires at Thu 15 Jan 2015 08:39:54 PM CET
Is this correct? (y/N) y

GnuPG needs to construct a user ID to identify your key.

Real name: YOUR NAME
Email address: your.name@domain.com
Comment: 
You selected this USER-ID:
    "YOUR NAME <your.name@domain.com>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.

etc.

Exporting Public Key

To be able to receive encrypted files, you need to export your public key. The text files generated below can be emailed as attachment or more preferable distributed in a more secure way, such as manually handed over via USB memory.

$ gpg --armor --output "key.txt" --export "YOUR NAME"

Usage

Now you are ready to use GnuPG. A good tutorial guide for the most common usage can be found here http://www.glump.net/howto/gpg_intro.

Troubleshooting

How to Disable SELinux on RHEL 6.3

SELinux is a good thing, but when sitting on a test machine, you might not be interesting in configure SELinux to have you application running smoothly, without running into SELinux. So here I will show you how to disable SELinux. Remember that this is NOT recommended for a production environment.

First check the current status of SELinux.

$ sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          disabled
Policy version:                 24
Policy from config file:        targeted

Now to disable SELinux. Open /etc/selinux/config and edit the below.

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled

Now restart you system and run sestatus again to verify that you configuration changes had taken affect.

Reference

January 12, 2013

How to Install and Configure Subversion (SVN) on RHEL 6.3

In this blog I will show you how to install and configure Subversion (svn) on Red Hat Enterprise Linux (RHEL) 6.3.

1. Installation

First lets install subversion and apache web server, if you already have installed a apache web server, then leave out the httpd package below.

$ yum install subversion httpd mod_dav_svn

2. Configuration

2.1 Create a new Subversion Repository

Now lets create a new subversion repository named 'demorepo'.

$ Create a new Apache directory
sudo mkdir -p /var/www/svn/demorepo

$ Create a new Subversion repository
svnadmin create /var/www/svn/demorepo

$ Change owner of apache svn 
chown -R apache:apache /var/www/svn/demorepo

2.2 Authentication

It is highly recommended to have some authentication to your subversion repository. Here I will use simple login using the built in Apache Web Server module mod_auth_basic. The module is per default installed and configured with the RHEL httpd package, we only need to add new users.

$ htpasswd -c /etc/httpd/conf/passwords magkar

2.3 Configure Apache Web Server

Finally we need to configure the apache web server, for our new web location, but also to apply our authentication. We will facilitate the pre-configured configuration file /etc/httpd/conf.d/subversion.conf that comes with the mod_dav_svn package.

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn

   # Limit write permission to list of valid users.
   <LimitExcept GET PROPFIND OPTIONS REPORT>
      # Require SSL connection for password protection.
      # SSLRequireSSL

      AuthType Basic
      AuthName "Authorization Realm"
      AuthUserFile /etc/httpd/conf/passwords 
      Require valid-user
   </LimitExcept>
</Location>

Now we only need to restart our apache web server and test our demo subversion repository - http://localhost/svn/demorepo/.

$ service httpd restart

Reference

January 11, 2013

How to Setup and Use Artifactory as Proxy/Mirror for Remote Repositories

In this blog I will discuss and show you how to setup and use Artifactory as proxy (mirror) for remote repositories, such as Central Maven 2 repository or other remote repository, but also using for internal distribution for corporate releases.

First if you have not installed a Artifactory server, start with that. You can read about the installation steps in my previous blog - http://magnus-k-karlsson.blogspot.se/2013/01/how-to-install-artifactory-on-rhel-63.html.

The next step is to create a settings.xml for you company, that uses this newly installed Artifactory server as proxy/mirror. Creating you own settings.xml can be daunting task, but fear not Artifactory can create one for you. Simply open you web browser and open http://192.168.0.3:8081/artifactory/webapp/mavensettings.html. Here we will also select which internal repository we will use for internal distribution. You can create a new, but here we will use the already created repository 'libs-release'.

Then click Generate Settings and save it to ~/.m2/settings.xml. That was not so hard, lets try it out. Before you continue, make sure that you have installed Maven 3. If you are on a RHEL platform, please read my previous blog http://magnus-k-karlsson.blogspot.se/2013/01/how-to-install-maven-3-on-rhel-63.html.

Now lets create a simple project. I will use Apache Wicket Quickstart here, but you can use any maven project. Open http://wicket.apache.org/start/quickstart.html and copy past the maven command to your terminal.

$ mvn archetype:generate -DarchetypeGroupId=org.apache.wicket -DarchetypeArtifactId=wicket-archetype-quickstart -DarchetypeVersion=6.4.0 -DgroupId=com.mycompany -DartifactId=myproject -DarchetypeRepository=https://repository.apache.org/ -DinteractiveMode=false

...
Downloading: http://192.168.0.3:8081/artifactory/remote-repos/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
Downloaded: http://192.168.0.3:8081/artifactory/remote-repos/commons-cli/commons-cli/1.0/commons-cli-1.0.jar (30 KB at 60.3 KB/sec
...

As you can see that maven now request all dependency from you local artifactory server instead from a remote repository. And if you open the artifactory server log you will see that the mirrored remote repository is populated.

$ less /var/log/artifactory/artifactory.log

...
2013-01-11 12:52:44,496 [http-bio-8081-exec-1] [INFO ] (o.a.r.HttpRepo      :252) - repo1: Downloading content from 'http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-digest/1.0/plexus-digest-1.0.jar'...
2013-01-11 12:52:44,502 [http-bio-8081-exec-1] [INFO ] (o.a.r.HttpRepo      :252) - repo1: Downloading content from 'http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-digest/1.0/plexus-digest-1.0.jar.sha1'...

...

Now if everything is working, lets continue by adding a new remote repository. Lets log into artifactory and select the Admin tab and then Repositories from the left menu and add a new remote repository. Here I will use the new JBoss EAP 6 repository, but you can choose any valid remote repository.

Repository Key: jboss-eap-repository
URL: http://repo1.maven.org/maven2
Public Description: JBoss EAP Maven Repository
Includes Pattern: **/*
Checksum Policy: Generate if absent
Max Unique Snapshots: 0
Handle Releases: true
Handle Snapshots: true
Use default for the rest of the settings.

After added, we will add this remote repository to virtual repository remote-repos. The advantage of using virtual repositories, is that we do not need to updated our settings.xml. The remote-repos is already there by default.

Al right. Now lets test it. Lets open up our wicket pom.xml and add the JBoss EAP Java EE Spec dependency.

<repositories>
    <repository>
        <id>jboss-eap-repository</id>
        <name>JBoss EAP Maven Repository</name>
        <url>http://maven.repository.redhat.com/techpreview/all/</url>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>jboss-eap-repository</id>
        <name>JBoss EAP Maven Repository</name>
        <url>http://maven.repository.redhat.com/techpreview/all/</url>
    </pluginRepository>
</pluginRepositories>

<properties>
    <wicket.version>6.4.0</wicket.version>
    <jetty.version>7.6.3.v20120416</jetty.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <jboss.eap.spec.version>3.0.1.Final-redhat-1</jboss.eap.spec.version>
    <jboss.eap.impl.version>6.0.1-redhat-1</jboss.eap.impl.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.jboss.spec</groupId>
            <artifactId>jboss-javaee-6.0</artifactId>
            <version>${jboss.eap.spec.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.component.management</groupId>
            <artifactId>jboss-dependency-management-eap</artifactId>
            <version>${jboss.eap.impl.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

After editing you pom.xml, lets test it.

$ mvn clean install

...
Downloading: http://192.168.0.3:8081/artifactory/remote-repos/org/jboss/component/management/jboss-dependency-management-all/6.0.1-redhat-1/jboss-dependency-management-all-6.0.1-redhat-1.pom
Downloaded: http://192.168.0.3:8081/artifactory/remote-repos/org/jboss/component/management/jboss-dependency-management-all/6.0.1-redhat-1/jboss-dependency-management-all-6.0.1-redhat-1.pom (2 KB at 13.2 KB/sec
...

And in your artifactory server log.

...
2013-01-11 12:49:51,074 [http-bio-8081-exec-18] [INFO ] (o.a.r.HttpRepo      :252) - jboss-eap-repository: Downloading content from 'http://maven.repository.redhat.com/techpreview/all/org/jboss/spec/jboss-javaee-6.0/3.0.1.Final-redhat-1/jboss-javaee-6.0-3.0.1.Final-redhat-1.pom'...
2013-01-11 12:49:51,518 [http-bio-8081-exec-18] [INFO ] (o.a.r.HttpRepo      :252) - jboss-eap-repository: Downloading content from 'http://maven.repository.redhat.com/techpreview/all/org/jboss/spec/jboss-javaee-6.0/3.0.1.Final-redhat-1/jboss-javaee-6.0-3.0.1.Final-redhat-1.pom.sha1'...
...