How to see files installed by a package

If you’ve ever downloaded a package on Debian (or any of its derivatives) and want to see which files were installed, it’s easily accomplished using the ‘dpkg-query’ command:

$ dpkg-query -L vsftpd


The above example is for the ‘vsftpd’ package, but this equally applies to all of the other packages installed using dpkg/apt.

In case you’re on a system which uses yum (Fedora, RedHat, CentOS etc…) you can use ‘rpm -ql [package name]’:

# rpm -ql yum-cron

Amazon EC2 I/O benchmarks

So, after my previous post where I used bonnie++ to benchmark my desktop machine, I decided to benchmark the I/O performance of the virtual server (or as Amazon like to call it, an “instance”) with the same tool.

The results are as follows:
Note that I’ve taken a screenshot of the results as opposed to pasting them in this time, as the last time I couldn’t get the columns to line up.

So, what can we tell from these numbers? How do they compare with my desktop SATA hard drive? Here are the same numbers from the SATA drive:

Well, we can see that when it comes to the Sequential Output numbers, the local SATA wins in all three of the numbers and the CPU utilization is exactly the same on both of the systems. It’s the same story for the Sequential Input numbers, although there doesn’t seem to be as much of a difference as with the Sequential Output numbers.

In the Random Seeks, the AWS machine blows away the local SATA drive, both in terms of Random seeks per second and the latency numbers. The only place where it loses out is in consuming much more CPU than the local system.

In the Sequential Create category, AWS also comes out on top, although, for some reason I wasn’t able to get Read and Delete numbers for the local disk.

The Random Create category is pretty much even, with neither system really standing out.

So, there you have it, the AWS infrastructure isn’t as bad as I had originally thought. Also, one thing to keep in mind is that the type of EC2 instance tested was just the basic “free” instance which Amazon provides. I would expect that better provisioned instances would perform even better when it comes to the same test.

LAMP stack with Ubuntu JeOS

JeOS stands for “Just enough operating system” and referrs to an operating system with the bare minimum software installed to run the application required. Ubuntu’s server edition makes it easy to install a JeOS minimal system.

To install a minimal LAMP (Linux, Apache, MySQL, PHP) stack on top of an Ubuntu JeOS instance, simply boot off of an Ubuntu server CD and then when it comes to the install screen, highlight the “Install Ubuntu Server” and then press F4 to bring up the “Modes” menu. From this menu select either “Install a minimal system” or “Install a minimal virtual machine”, depending on whether you are installing a VM or a physical server.

From there, carry on with the rest of the install process and when it comes time for the software selection, check the “LAMP Stack” option. During the install process you’ll be asked for a MySQL root password.

After this is done, you’ll end up with an OS that takes up only about 650MB, compared to the regular Ubuntu server option which takes up 2GB. The main advantage of the smaller size is that the server or VM doesn’t run any unnecessary services or expend any extra resources in keeping superfluous software updated. In addition, if it is a VM, it makes it much easier to transport and turns it into more of an “appliance”

Eclipse – How to show line numbers

To get the editor pane to show line numbers go to ‘Window’ -> ‘Preferences’ -> ‘General’ -> ‘Text Editors’ and click the checkbox labelled ‘Show line numbers.
In graphical form:

PHP Development with NetBeans 7.0 – Debugging

In my previous post I talked about getting a PHP development environment set up using NetBeans and a locally installed Apache server on Ubuntu. In this post, we’re going to be creating a slightly more complicated project to showcase the debugging abilities of NetBeans, which integrates very nicely with Xdebug.

Xdebug is a PHP extension which enables you to debug your code, same as if you were using something like VisualStudio with C#. In order to install and enable Xdebug on Ubuntu, you just need to run the command:

sudo apt-get install php5-xdebug

After this package has been installed, you have to enable remote debugging on Xdebug (it is disabled by default). Add the line:


to the /etc/php5/conf.d/xdebug.ini file. In order for the changes to take effect, you will have to restart Apache:

/etc/init.d/apache2 restart

If you ever want to verify what the Xdebug settings are set to, you can see them on the default phpinfo() page.

Now that we’ve got Xdebug running, go ahead and create a new PHP project in NetBeans and name it ‘PHPIncrement_Add’:

You can leave the ‘Run Configuration’ screen settings set to the defaults:

In the template file, remove the php section and edit the file to include a simple form as below:

Then create a new PHP web page by right clicking on ‘Source Files’ -> ‘New’ -> ‘PHP Web Page’ and name the page results.php.

When results.php opens in the editor window, modify it to look like the following:

Ok, so now we have a simple web application, which takes two integers, increments them and then displays the result. We can go ahead and test this out by hitting the ‘Run Project’ button (or pressing F6) and we should see the following in our browser:

And after hitting the ‘Submit’ button, we can see the result:

So now we have a very simple, working PHP application. Now lets see how we can debug our program. We’ve already installed and configured Xdebug, we just need to modify a few options in NetBeans. In NetBeans, go to ‘Tools’ -> ‘Options’ -> ‘PHP’ -> ‘Debugging’ and check the ‘Watches and Balloon Evaluation’ checkbox:

After you check the box, you might get a warning saying “Please note that Xdebug is known to be unstable if this option is enabled”. I’ve never had Xdebug crash on me with this option enabled so far. Also note that I’ve left the ‘Stop at First Line’ option unchecked, this is just my personal preference.

Next we can go ahead and set some breakpoints by clicking in the left hand margin of the editor window, where the line numbers are shown:

To start our debugging session, we can click on the ‘Debug Project’ button, which is next to the ‘Run Project’ button, or alternatively press Ctrl+F5.

At the start we are presented with the index.php page, so just go ahead and enter some numbers and hit the ‘Submit’ button. Once this is done, you will automatically switch back to NetBeans, with the debugging session started:

If you select the ‘Variables’ tab on the bottom pane and press the ‘Step Into’ (F7) button, you can see the values of $number1 and $number2:

Press the ‘Continue’ (F5) button and the code should keep executing until it gets to the breakpoint in the incrementAdd function. Now the ‘Variables’ pane doesn’t show us the value of $result, however we can fix that simply by right clicking on $result in the editor pane, selecting ‘New Watch…’ and entering $result as the ‘Watch Expression’:

Note that the value of $result will be null on our breakpoint, but after pressing the ‘Step Into’ button, it’s value is set.

Hit the ‘Continue’ button and you will see the results.php page displaying the results of the calculation.

So, in this post we’ve successfully installed and configured Xdebug and got it working with our NetBeans IDE, as well creating a simple project and going through a basic debugging session. Please keep in mind that this is a very simple example and that debugging for such a basic project would probably not be necessary. The debugger is especially useful when we have a obscure bug which we need to track down, we want to see the flow of control in a complex piece of code or maybe verify what values are being passed to the database.