How to install Oracle Database 12c on RedHat Enterprise Linux 6

IMHO, installing Oracle Database is not straight forward. There are lots of prerequisites packages and configurations that need to be installed and configured before you can actually install Oracle Database. Especially if you have a headless server that does not have any physical display attached to it, because you cannot install Oracle Database on a headless server without a response file (a response file is basically a configuration file that automate the installation process – however in order to create a response file, you will need another machine with display). Oh yes, I don’t have any other machine, and for god sake, I only want to install a single instance of Oracle Database, so why so complicated? By the way, here is the full instruction that will help you install a single instance Oracle Database, straight forward from the beginning to the end. A. Install prerequisites packages and configuration Oracle has a very handy package called oracle-rdbms-server-12cR1-preinstall however it’s only available for Oracle Linux (yes, Oracle Linux). However, we can easily add yum repository to RHEL and install that package: sudo wget -O /etc/yum.repos.d/public-yum-ol6.repo sudo wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle After this, installing prerequisites packages is straight forward: yum install oracle-rdbms-server-12cR1-preinstall B. Install Oracle Database Since our server does not have any physical display attached to it, we need to create a virtual display and use X11 forwarding to setup Oracle Database. First step is to create virtual display xorg-x11-server-Xvfb Login under “oracle” account (this account should be created when we install prerequisites packages) and create a virtual display: Xvfb :1 -screen 0 1280x1024x24 Fire another SSH session with parameter -X (to enable X11 forwarding) and login under “oracle” account. Then, download and extract 2 installation files into the same directory and run the Oracle Universal Installer unzip unzip

How to solve “Too many authentication failures for…” problem

Recently I am having trouble connecting to my home server from my laptop. Every time I connect, it said: Received disconnect from my_ip: 2: Too many authentication failures for my_username The strange thing is, connect from any other machine did not give me this problem. Is there anything wrong with my laptop? Even with multiple failures, my home server should reset login count sometimes. Turn out the problem belongs to my SSH keys. I recently added 2 keys to my newly deployed servers. Each time I connect to my home server, my laptop will offer public key one by one, and apparently I have more private keys than the maximum number of retries, which is 6 on my home server. Solution: Explicitly specify the correct private key in host entry in the ~/.ssh/config file by adding IdentitiesOnly: Host my_home_server_ip IdentityFile ~/.ssh/some_rsa_key IdentitiesOnly yes Port 22 Specify the correct private key: ssh -i some_id_rsa -o ‘IdentitiesOnly yes’ username@my_home_server_ip The last resort, disable Public Key Authentication completely: ssh -o PubkeyAuthentication=no username@my_home_server_ip Happy connecting!

Extract pages from PDF in Linux

I am not usually have to extract pages from a pdf file, but when I do, I used Adobe(R) Acrobat 7.0 that resides on my old Windows XP machine (believe me, it’s still work at this time). Today one friend asked me to extract a page from his pdf file, and I only have my MAC and Linux workstation with me. Fortunately, I figured out I can just use a single command to do this. Kudos to pdftk. For example: pdftk A=inputfile.pdf cat A1-10 output outputfile.pdf This command will extract page 1 to 10 from inputfile.pdf to outputfile.pdf Very handy. Happy extracting!

How to install rtorrent and rutorrent

In order for rutorrent to work, rtorrent must be compiled with xmlrpc-c support. Here is the full instruction. First, check to make sure the following libraries are installed on your system. At any step below, if you cannot run ./configure script correctly, you might have to install -dev or -devel packages of these libraries gcc ncurses libsigc++-2.0 libssl xmlrpc-c subversion Download and install xmlrpc-c if your distro does not support it svn co xmlrpc-c cd xmlrpc-c ./configure make make install Download and install libtorrent and rtorrent wget wget tar xzfv libtorrent-0.13.3.tar.gz tar xzfv rtorrent-0.9.3.tar.gz cd libtorrent-0.13.3 ./configure make make install cd ../rtorrent-0.9.3/ ./configure –with-xmlrpc-c=/usr/local/bin/xmlrpc-c-config make make install Execute this line to copy rtorrent config to your home directory cp /usr/share/doc/rtorrent/examples/rtorrent.rc .rtorrent.rc Add the following line to the end of your .rtorrent.rc scgi_port = Create download and session directories as pointed out in .rtorrent.rc. You might also change these directory as desired. Download, extract rutorrent and plugins and placed them anywhere under your web root so that you can access it via HTTP wget wget tar -xf rutorrent-3.5.tar.gz cd rutorrent tar -xf ../plugins-3.5.tar.gz cd .. mv rutorrent /var/www/ Delete /var/www/ruttorrent/.htaccess to disable htaccess authentication (you can always enable it in the future) Fire up your web browser and open You will see the GUI very similar to uTorrent. Happy torrenting. Download responsibly.

How to find all files of a particular size in a particular directory

Last weekend, I worked on a Linux malware cleaning project. After 30 minutes of finding, I found 2 suspected scripts that are not included in Drupal by default. I soon realized that there are many of them, and I have a very limit access to his website (just normal account SSH access). Fortunately, after doing some research, I found that I can easily find all files of a particular size in his home directory. Simple like that: Suppose we want to find all files that has size = 1234 bytes and in /home/codepie directory, just type the following command find /home/codepie -type f -size 1234c -exec ls {} \; You might wonder what does ‘c’ in command mean. As units you can use: b – for 512-byte blocks (this is the default if no suffix is used) c – for bytes w – for two-byte words k – for Kilobytes (units of 1024 bytes) M – for Megabytes (units of 1048576 bytes) G – for Gigabytes (units of 1073741824 bytes) Additionally, you can also search for bigger (+) or smaller (-) files. Just add a plus (+) or minus (-) for bigger and smaller files, respectively. find /home/codepie -type f -size +1234c -exec ls {} \; Have fun finding!

How to know exactly which Linux distribution you are using

I myself usually have to connect to a lot of Linux server to troubleshot. As you know, different Linux distribution has different config file location. For example, Apache config file in CentOS server is /etc/httpd/httpd.conf but in Ubuntu/Debian is /etc/apache2/apache2.conf It would be easier for us if we know exactly the distribution name from the beginning. Here are several solutions: 1. From the boot time message dmesg | head -1 You might see something like this: Linux version 2.6.31-14-generic (buildd@crested) (gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8) ) #48-Ubuntu SMP Fri Oct 16 14:05:01 UTC 2009 2. Using /proc/version cat /proc/version You might see something like this: Linux version 2.6.31-14-generic (buildd@crested) (gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8) ) #48-Ubuntu SMP Fri Oct 16 14:05:01 UTC 2009 3. Using /etc/issue cat /etc/issue You might see something like this: Debian GNU/Linux 6.0 \n \l 4. Using /etc/*-release cat /etc/*-release You might see something like this: Gentoo Base System release 1.12.9 Disclaimer: The results are different because I’m using different machine when testing. have fun :)

How to install Ant correctly on Ubuntu

When using Ant the first time, you might notice that it return errors ant -version Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar Is it because of wrong jdk version? You probably tried to locate tools.jar and found this: locate tools.jar /usr/lib/jvm/java-6-sun- Is it the same tools.jar required by ant? How can you point to this file so ant will not return any error? Here is the solution: Make sure you have the “multiverse” repository Install all Sun Java 6 packages sudo apt-get clean sudo apt-get update sudo apt-get install sun-java6* This process might take a while, so you might need to grab a cup of coffee and wait. Check that you are using the newly installed jdk javac -version The output should be something like this: javac 1.6.0_06 Check that you are using the correct jre java -version The output should be something like… java version “1.6.0_06” Java(TM) SE Runtime Environment (build 1.6.0_06-b02) Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing) If you find you are not using the correct Sun Java 6 jre you can fix it by: sudo update-alternatives –config java The above command will let you choose which jre to make default if you have multiple jre installed.

Host … is not allowed to connect to this MySQL server

Suppose you’ve installed LAMP (Linux, Apache, MySQL, PHP) in your server. Everything is working fine. One day, there was a problem on your server. You don’t want to use the command line mode of MySQL because it is very difficult to debug. So, you grab a tool, for example SQLyog to connect to that server. Surprisingly, you cannot connect and the sever give you a weird message: ERROR 2003: Can’t connect to MySQL server on ‘host_name’ (111) This is a very common problem. You forgot to change the bind address on my.cnf. Use Vim, Nano or any text editor to open /etc/mysql/my.cnf as root and change the bind address from (default) to Now your MySQL server are open to the world (be careful!) You might think now you will be able to connect. Things are not easy like that. You will get another error message: Host … is not allowed to connect to this MySQL server If you have nmap installed, you can see your server is already open port 3306 (which is MySQL default port). So, why you cannot connect? MySQL user table has something like ‘user’@’host’. By default, there is only 2 entries: ‘root’@’localhost’ and ‘root’@’’. You have to add one more entry. Connect to MySQL server and type the following: GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY ‘root-password’ WITH GRANT OPTION; Notice that ‘%’ is wildcard for “any host”. You will be able to login now. Good luck!