Posts Tagged ‘Linux’

Script to get a localhost’s IP address in Linux

I’ll keep this snippet really short:

$ ifconfig eth0 | grep "inet addr:" | cut -d: -f2 | awk '{ print $1 }'

Which results in:


DB2 on Ubuntu: The database manager shared memory set cannot be allocated

I’ve been trying to get DB2 Express-C working on Ubuntu but I get an error when trying to start DB2:

ashlux@SERVER:~/java/db2exc$ db2
(c) Copyright IBM Corporation 1993,2007
Command Line Processor for DB2 Client 9.7.2

db2 => db2start
SQL1220N  The database manager shared memory set cannot be allocated.

After some searching I discovered that the problem is probably shmmax being too low. A site on tuning Oracle which shows how to increase shmmax:

sudo  -s "echo 2147483648 > /proc/sys/kernel/shmmax"

DB2 successfully starts up now.


New computers makes me happy

You could build Legoland too, right?

You could build Legoland too, right?

Earlier this week I put together a new computer for myself with parts bought from newegg. Building a computer really isn’t that difficult. As Jeff Atwood explains, “If you can put together a LEGO kit, you can put together a PC from parts.” Choosing the parts that will fit into your budget can be time consuming, but there are plenty of online resources including forums full of people willing to help out.

So here’s a list of the components I ordered:

Monitor: ASUS VH242H 23.6-Inch Widescreen LCD Monitor – Black I would sure like a second one of these turned vertically but that will have to wait.

Case: Cooler Master CM 690 II Advance ATX Mid-Tower Case (RC-692-KKN2) As the name implies, this is the successor to the CM 690. The black finish on the inside is a nice touch.

Mobo: I had several people online suggest the ASUS P6X58D Premium for my motherboard, but I had a hard time justifying it over the ASUS P6T series just to get USB 3.0 and SATA 3.0. Ultimately I decided to settle on the ASRock X58 Extreme LGA 1366 Intel X58 ATX Motherboard for its ease of overclocking and it’s positive reviews. I suppose time will tell whether I regret that or not.

CPU: Quad core Intel for the CPU: Intel Core i7 Processor i7-920 2.66GHz 8 MB LGA1366 CPU BX80601920. I was surprised to see how much AMD stinks with the high-end market nowadays.

Memory: The mobo I chose can support up to 24 GB, but I’m starting out with 6 GB of CORSAIR DOMINATOR DDR3 1600 RAM (3 x 2 GB).

PSU: OCZ 700W StealthXStream Power Supply

Primary HDD: I might have splurged a little on the HDD by getting an solid state drive (SSD). Prices aren’t great for the sizes, but performance is great. I grabbed an Intel X25M 80GB Mainstream Solid State Drive SSDSA2MH080G2R5 for running the OS and applications. I partitioned the drive into two sections, 12 GB for Linux and the rest for Windows 7.

Secondary HDD: After spending quite a bit on the SSD dirve, I needed a second drive mostly for data like movies, music, etc. I chose the Samsung 500 GB SATA II Hard Drive HD502HJ for its price and performance. 500 GB isn’t a huge amount of space, but with a mobo and case that supports over 9000 hard drives, I can add another one later.

GPU: Despite ATI cards being generally better than Nvidia, I really wanted a Nvidia card since the Linux support is better. Unfortunately prices for nvidia cards have gone up in the last month or so leaving ATI the only option that made sense to me. So I picked up a Sapphire Radeon HD 5870 1 GB DDR5 PCI-Express Graphics Card 100281SR.


IE, X, and You

While trying to get IEs4Linux installed (Why not call it ie4linux instead?), I ran into some issues with the latest Ubuntu 9.10 Karmic Koala.

The program ‘’ received an X Window System error.
This probably reflects a bug in the program.
The error was ‘RenderBadPicture (invalid Picture parameter)’.
(Details: serial 5546 error_code 158 request_code 148 minor_code 7)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the –sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)

To solve this, I just told IEs4Linux to not use a GUI by using this command instead: ./ies4linux –no-gui.

A side effect is you lose the GUI to configure the install so you’ll have to use other flags if you want to deviate from the default install. To see the other options available use –help and –full-help.


Issues with IntelliJ IDEA 9 M1 (Maia) in Linux and OSX (build #10372)

Unlike the godess, IntelliJ 9 M1 isn't shy about being buggy

Unlike the godess, IntelliJ 9 M1 isn't shy about being buggy

IntelliJ 9 (codenamed Maia) looks promising with lots and lots of great features. There seems to be an endless list of newly supported technologies, tweaks, and usability features.

Maia has been superb in Mac OSX Snow Leopard. Unfortunately, my Ubuntu 9.04 desktop is an entirely different story.

A big feature of Maia that I’m looking forward to is background file indexing. It sounds like a great idea, be able to edit and browse projects instantly while you wait for the indexing to finish. The catch is advanced browsing and editing features are not available until after indexing finishes.

Both in OSX and Linux I ran into issues with the background file indexing.

Comparatively, my experience with background file indexing with OSX was less severe, so I’ll start there. Like when I normally load a project with IntelliJ, a loading dialog pops up with a status bar and I can watch the name of files zoom by as they’re being indexed. Unlike previous versions of Intellij, there’s a button to put the indexing into the background.

Instantly I click the button. I mean, why waste time, right? Unfortunately browsing was completely unusable with everything being sloooooow. In IntelliJ’s defense, I have only booted up IntelliJ once so far on my Mac. And this is a pre-release. (I usually just leave IntelliJ running and beyond this, everything has been wonderful).

The issues with Ubuntu were a bit more troubling. To my surprise, the background indexing did not bring the UI to a screeching halt like it did on my Mac. What I wasn’t prepared for was worse.

With background indexing appearing to run smooth, I was pumped to get the most out of the new feature. Immediately I dug into the directory with the project’s JSPs. Annoyingly every minute or so the listing of files would disappear and be rebuilt. After a few times, I realized the background indexing would finish then start right back up in a minute.

This restarting of the background indexing went on for about a half hour I was busy with some activities that didn’t require a PC so I just let it do its thing hoping it would stop. Of course the constant indexing did not stop. The directory listing did not stop reloading.

Giving up, I restarted IntelliJ and everything loaded just fine every time since.

The next two problems showed up intermittently in Linux.

Firstly, on more than one occasion and seemingly randomly. If I had two files in two tabs, selecting the unselected tab would do nothing except show that the second tab was selected. The displayed file contents would not show up. I could open up additional files and switch to them just fine, but I could never get the other file’s contents to show up even then. The tab issue occurred on more than one occasion. Closing and reopening the misbehaving tabs fixed the issue each time.

The next issue was more troubling: I would simply lose the ability to edit files. I could type until I was blue in the face and text would not show up. The inability to edit files cropped up frequently and was not solvable without restarting IntelliJ.

After poking around at IntelliJ IDEA 9 M1 on Linux I gave up and reverted back to using IntelliJ 8. I am still successfully using IntelliJ 9 M1 on OSX, but my usage has been very light lately due to other events.

I sincerely hope IntelliJ 9 gets to a stable point. IntelliJ is such a time saver I really do not want to program in Java with anything less feature full.

Bottom line: The new features in Maia are wonderful. Feel free to download and use Maia, just don’t expect to be throwing out IntelliJ 8 just yet.


Backing up MySQL Databases with mysqldump

We all know that backing up critical data is very important. Unfortunately, it’s not always very clear how to go about doing that.

Luckily, making back ups of MySQL databases is easy by using mysqldump.

Backing up all databases

Backing up all databases is as easy as as this:

mysqldump -u username -p password –all-databases -c > mysqldump.sql

Did you expect it to be much harder? Sorry to disappoint.

The –all-databases option backs up all databases (genius naming!). The –complete-insert or -c uses complete insert statements in the backup script.

With the above command, mysqldump outputs all the SQL needed to regenerate all databases from scratch with all the data from the time of the dump. Users and other MySQL tables are also included in the dump.

Backing up a specific database or table

Sometimes it’s useful to only backup a small portion of the MySQL instance, either an entire database or a specific set of tables.

Not surprisingly, you can backup a specific database with mysqldump:

mysqldump -u username -p password YourDatabase > yourdatabase.sql

It’s just as easy to backup one or more tables in a database:

mysqldump -u username -p password YourDatabase table1 table2 > yourdatabase.sql

Compressing the backup

If you have a lot of data, compression with gzip will be helpful to eliminate disk space waste:

mysqldump -u username –password=password –all-databases -c | gzip -9 > mysqldump.sql.gz

Automating backups

If you’re dealing with a database of any significant importance, it’s critical to automate the backup process. In the Unix world there is cron. I won’t go into specifics on how to use cron since it is easily worthy of its own posting.

If you ever need your backup, it’ll suck. With backups, it’ll suck less. With automated backups, it’ll suck much much less.

mysqldump isn’t the right tool for all your MySQL backup needs, but its ease of use gives you no excuse. More complicated backup techniques, including incremental backups, can be found in the MySQL reference guide.


SSH warns “it is possible that someone is doing something nasty!”

Let this be a warning to all: SSH knows what you’re doing and SSH is not pleased.

Innuendos aside, I got this nice little error trying to SSH into my brand new server at home. And by “brand new”, I mean it’s my wife’s old desktop that is now running Ubuntu Server 9.04.

  $ ssh myserver
  Someone could be eavesdropping on you right now (man-in-the-middle attack)!
  It is also possible that the RSA host key has just been changed.
  The fingerprint for the RSA key sent by the remote host is
  Please contact your system administrator.
  Add correct host key in /home/ashlux/.ssh/known_hosts to get rid of this message.
  Offending key in /home/ashlux/.ssh/known_hosts:2
  RSA host key for myserver has changed and you have requested strict checking.
  Host key verification failed

So how did this happen? Basically, I used to have my router setup to forward the SSH port to my computer. Basically my computer at work had the RSA key for my computer, not the new server.

Contrary to the tidbit about requesting “strict checking”, using the -o stricthostkeychecking=no gave the same result.

Luckily the error message gave me one big hint as to how to fix this: “Offending key in /home/ashlux/.ssh/known_hosts:2″. The solution was simple enough, just delete the second line of the known_hosts.

SSH is working again. *cheers*