Category Archives: Linux

Ubuntu Server 7.04 Fiesty: Installation Problems and Changing Network Settings from DHCP to Static IP

Tonight I deployed another installation of Ubuntu Server 7.04 Fiesty. The biggest problem I ran into was setting up the network card. Apparently, the Ubuntu setup wizard tries to contact the network in at least two points during the installation wizard. In one of the points of the installation, failure to contact a server on the internet results in the installation hanging. I got around this by running the installation while connected to my residential DHCP network and then redeploying the server to the DMZ, which requires defining a static IP.

This created another problem – How do you change the network settings from DHCP to static IP address? In order to solve this problem, you need to update your interfaces file to use an assigned static IP address and configure the server to use your network’s DNS servers.

To change your network settings from DHCP to static IP, type:

sudo vi /etc/network/interfaces

The file displayed should have a line that says ‘ iface eth0 inet dhcp’ or something similar. Change the file to look like the following:

....
....
....
auto eth0
iface eth0 inet static
address 71.164.212.40
netmask 255.255.255.0
network 71.164.212.0
broadcast 71.164.0.255
gateway 71.164.212.1

Afterwards, restart your network interface by typing:

sudo /etc/init.d/networking restart

Next, you need to configure your DNS servers. You need at least two entries. To edit your DNS entries type:

sudo vi /etc/resolv.conf

My file looked like this:

nameserver 4.2.2.1
nameserver 4.2.2.2

After saving the file, you should be able to connect to the network.

If you would like to edit your hosts file, type the following in your shell.

sudo vi /etc/hosts

You can add more references to your localhost in here. Mine looks like this:

127.0.0.1       localhost
127.0.0.1 alex-server
127.0.0.1 sandbox-server

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

If you would like to change the hostname of your server, type the following:

sudo vi /etc/hostname

After typing in your new hostname, you need to run a script to implement the change. Type:

sudo /etc/init.d/hostname.sh start

References

Killing processes and PostgreSQL Queries

I’ve been working on issues related to processes and PostgreSQL these past few days. Minor as they were, I think these are common issues that aren’t documented very well. I recently had a problem canceling queries issued from PGAdmin. I decided to cancel the queries by looking up the process id and canceling the process thats running the query.

You can look up the process id, or the ‘pid’ column, by executing the following query in psql or PGAdmin:

select * from pg_stat_activity;

This query will return a list of all processes currently being run by your server. After finding the query you want to cancel, go to the BASH prompt and type:

sudo kill pid_number

Another problem that I ran into the other day was figuring out which processes a java server was running on. I did this by querying processes by name or browsing through all of the server’s processes. To query processes by a name, I typed:

ps -o user,pid,ppid,command -ax | grep java

If you still can’t find the process, you can browse all processes by typing:

procinfo

New Article

Milestone: First Django Application Ever

I finally deployed a Django application to a public facing Linux server. You can read all about it in a write up below. For those of you who don’t know what I’m talking about, Django is another ‘rapid application development’ web framework that comes with all sorts of useful tools to help web application developers get their software finished faster. Some of these time saving features include an auto generated administration tool, an ORM object mapper, and a template engine.

So how does developing on Django compare with development on ASP.NET? Well, for non-MS Office related development I would say it is faster and more suitable for custom applications. Alot of this has to do with the object relational mapper, which accomplishes the same things as Microsoft’s Dlinq, and the generated admin tool. These two features alone completely remove a large amount of coding that usually has to be done when creating an ASP.NET application.

I highly recommend anyone out there give Django a try. Check out this tutorial for a quick introduction.

New Article

New Milestone: My First Linux Application

TuxLast night I finished my first program that runs on Linux. If you haven’t guessed yet, its built on the PostgreSQL and Python application stack. The program is a server that checks and updates different files, while at the same time, has the ability to accept remote connections through telenet for administering the server.

I can’t go into deeper details about what the program does because of an agreement with my employers, however, I can talk about what I had to learn in order to put everything together. Later on in the week, I plan on posting a write up on Python and the Twisted Framework. While researching Twisted, it was maddening at the sparse amount of example code for some parts of the framework.  For me, it was authentication and integration of application code outside of protocols. Even now after completing everything, I’m still clueless on a whole slew of issues. I know most of the nerds out there will just say, ‘So? why don’t you just read through the source? It’s on your computer in plain sight.’ Since I’m still new to Python, reading through the source for the frameworks is like reading Chinese. As I’ve mentioned before, it all looks like a hodgepodge of pseudo code.

Developing on an Open Source Platform versus the Microsoft .NET Platform

It’s been 11 days since I switched my development environment over to Linux. I’m still running into new problems and figuring out new solutions on a daily basis. My latest problem concerned running a simple bash shell script.

As for news on software development, I’m still looking over PostgreSQL and will probably post another article on it in a few days. I’m about to start heavy development on that end. I’m also looking into Python. There are two major frameworks I’ve been researching and developing with –Twisted Framework and Django. I’ve had some time to read through a lot of documentation concerning both and so far things look promising. I encourage anyone out there to check them out.

As a Microsoft developer, how does developing on an open source platform compare to the Microsoft platform? Before I get into that, I need to explain the differences between the two development philosophies behind these platforms. First of all, the philosophies on developing on the two platforms are very different. Microsoft makes superior tools to anything I’ve seen on a free platform, but I think that stems from their development philosophy – use great  tools to expedite and ship code faster. I think the need for these tools has stemmed from the design of their application-tier (.NET) languages because they are extremely verbose in nature. This has resulted in the development and need for effective code generators, snippets, macros, and auto completion tools found in the Visual Studio IDE.

Because I haven’t been developing on an open source platform for long, I can’t comment in depth or with too much knowledge yet. From what I have seen so far with the design of different programs, things are taken from a minimalist approach.

The open source application PostgreSQL is built to serialize and query data. Their are no extra bells and whistles – such as Reporting Services, Notification Services, Data Warehousing, Message Queues, etc. that are found in SQL Server 2005. This doesn’t mean PostgreSQL is inferior. Instead, the application fulfills its primary design goals extremely well. Because of its minimalist approach, it can be quickly deployed and configured quickly. It took me less than one week to get myself up to speed on administration, developing, and deploying on that platform. 

Same thing with Python, although their seems to be just as many extensions and frameworks out there as the .NET platform. The beauty of Python is that it takes less keystrokes to accomplish the same tasks in C# or VB.NET. This saves not only time but diminishes the need for all those elaborate code generation tools found in Visual Studio 2005. Although, sometimes I find myself wishing for Intellisense. Either way, both philosophies can build software quickly. It’s just one alternative is a lot cheaper than the other.

New Article

Getting Around Linux: Compiling Python Extensions and Ubuntu’s Missing Packages

Last night I spent an awful lot of time trying to figure out how to compile an extension for Python. My struggles were quickly solved with the help of a charitable poster on Ubuntuforums.org. On default installations of Ubuntu 7.04 Fiesty, no development packages for the C compiler (aka gcc) and Python are included. In the end, the remedy was to install the C compiler and the Python development packages.

In order to accomplish this, type the following in the Bash prompt.

sudo apt-get install python-dev

This installs the Python development packages. You also need to type:

sudo apt-get install build-essential

This installs the C compiler.

After adding these magical packages, the extension I was trying to add compiled and was ‘successfully’ working. I put ‘successfully’ in quotes because I later found out that their were errors in the extension regarding a function call to localization, which was fixed about an hour later after some debugging.

Just in case you were wondering, the extension I was adding is called pgasync. It’s a asynchronous data adapter for PostgreSQL. If this works reliably, it may be able to scale better than using psycopg2, which is synchronous.

Getting around Linux: Newbie Mistakes or How to Screw Up an Ubuntu Installation

It’s been 8 days since I switched my development environment completely over to Linux. The first two days were quite trying in terms of customizing my environment. On one of the first attempts, I followed instructions entitled ‘The Perfect Desktop – Ubuntu 7.04 Feisty Fawn’ on howtoforge.com. This resulted in a very capable but bloated installation of Ubuntu. I didn’t even know what half the programs I installed did.

Lesson 1: Don’t Change the Home Directory for Login or User Account.

Shortly after finishing and playing around with all the various programs, I attempted to reboot the computer and re-login. When I attempted to login again, there was a problem. After authenticating, a few errors popped up – one of them I vaguely remember telling me how I couldn’t access my home directory.

While I was installing a few programs, I got tired of changing ownership of some of the directories in the /etc/ folders. I decided to change my home directory to root, hoping that will solve the problem. News to everyone out there, changing root folders for your login doesn’t work and not only that – if you don’t change your home directory back to your original settings, you won’t be able to login again.

Not all programs have a package available for installation off of the Ubuntu Package Manager or apt-get. In attempt to get around this limitation, I tried manually extracting some programs into various locations on the system but ran into permission problems. In order to get around the problem of write and execute permissions for your login, I found it much easier to just extract and run programs from directories within your /home/user_name/ folder.

Lesson 2: Don’t Try to Manually Remove Any ‘.deb’ Packages or Any Files Installed by Ubuntu Package Manager

I successfully installed Eclipse using the Ubuntu Package Manager, but I ran into some problems and misconfigured a few extensions that I was trying to ‘install’ myself. So like any ex-Windows user, I thought the solution would be to remove and reinstall the program. Well, that proved problematic because removing an application through the Ubuntu Package Manager doesn’t result in the files being completely deleted.

After a quick Google search, I found a post that told me how to uninstall Eclipse manually. So after deleting a few files here and there, the program was gone and I was like ‘sweet’. So then I attempted to reinstall Eclipse from the Ubuntu Package Manager, but I couldn’t. Each attempt resulted in a bunch of warning and error messages which resulted in no new installation of Eclipse.

I never figured out a solution to this, rather I just reinstalled Ubuntu. It takes about 10 minutes to do that on my machine. So what the hell, right?

Lesson 3: Reinstalling Ubuntu will Probably be Faster than Trying to Solve your Misconfiguration Mishap

In one day, I probably reinstalled Ubuntu on my development machine about 3 times before I got it right. You know what they say, third time is always a charm. Although most people probably don’t have this luxuary due to files they haven’t backed up or customizations that took endless hours to get just right, I was messing with a clean install so I could get away with that.

After just over a week of continuously working with Ubuntu, I have to say it’s not bad at all. There are many wonderful things I like about Linux and there are still many wonderful things I still like about Windows. I would recommend installing Ubuntu to anyone who wants to try a cheaper – and in some cases better – alternative to upgrading to Windows Vista.

From a software developer’s stand point, I can’t say for sure yet. I haven’t gone through the whole ‘software development life cycle’ on the Linux platform. I’m sure there are many problems I have yet to encounter developing software for Linux . As I get to them, I’ll be sure to post it here for everyone in the world to see.

Database vs Database and the Linux PATH variable

Last night I was doing some research on PostgreSQL and got as far as configuring the server, getting a Schema up, and creating my first functions. In terms of capability between SQL Server 2005 and PostgreSQL, so far PostgreSQL seems to offer a comparable alternative, at least with the requirements for our system. A lot of features that were recently introduced into SQL Server 2005 such as custom data types, language support outside of T-SQL, and support for new SQL syntax has been around in Postgre for awhile, but that doesn’t mean PostgreSQL is better. As usual, you have to look at your requirements for your system before deciding which database servers out there are a better match for your project.

For our project, the two crucial requirements that counted out SQL Server 2005 were the ability to run on Linux and low licensing fees. The licensing costs of SQL Server 2005 does not scale well. Even with volume license deals, the licensing costs still encourage companies to scale up their hardware to save on licensing fees. Part of our strategy involves scaling out over cheap redundant boxes, its the exact same strategy that most successful tech startups have chosen because its more economical in the beginning of the system’s or company’s life.

Last night while I was configuring Postgre on my local Ubuntu machine, I ran into a small problem regarding editing the ‘system’ PATH in the bash shell. The PATH variable in Bash is similar to the PATH entry in the Window’s System Variables. This variable allows a user to execute files in any location located in the directories referenced by the PATH variable. Like the Windows counter part, there is a global file that contains PATH entries for all users and a local file for the current user. The global file is located at ‘/etc/environment’. You may have to login as ‘su’ in order to access the file. The local file is located at ‘~/.bashrc’, which is actually in the user’s home directory.

To add an entry to the PATH variable for the local user, just add the following lines

First – Type: gedit ~/.bashrc

PATH=$PATH:/path_to_program_is/bin
export PATH

To add an entry to the PATH variable for the environment, just add your entry with a colon and the new entry to the end of the PATH definition.

First – Type:  sudo gedit  /etc/environment

PATH="XXXXX:XXXXX/XXXX:XXXX:XXX/XXXX/XXXX:XXXXX:/path_to_program_is/bin"

For more information, consult this thread in the ubuntuforums.