Monthly Archives: May 2007

Getting Around Linux: How to Execute || Initiate || Run ‘install.sh’

I’ve been messing around with a few programs on Gnome lately and a few of them require the user to execute a file called ‘install.sh’ in the command prompt in order to initialize the installation process. In order to do this you just type:

sudo sh install.sh

- or just -

sh install.sh

Pretty straight forward right? Well… not always. Typically installing a downloaded package requires you to extract your files into a directory. There are two notes that Linux users assume everyone knows:

  • You have full read, write, and execution permissions to the directory and files you are extracting.
  • You actually know which directories and files have these permissions.

At first this sounds like a no brainer, but to the ex-Windows user who had administrative access to all permissions by default, this represents a new experience. When installing your own programs that are not from ‘apt-get’ or from the Ubuntu Package Manager, I suggest users download new packages and install new programs in subdirectories located under the ‘/home/user_name/’ directories.  As for myself I have directory for new packages called ‘/home/alex/downloaded_packages’

You can view privileges for all your new files and directory by navigating to the location of your extraction and typing:

ls -l

Which typically results in a directory listing that looks like this:

total 6100
-rwxr-xr-x 1 alex 725 Jul 10 15:07 stuff.txt
drwxr-xr-x 2 alex 512 Jun 13 16:19 dev
....

The entries that start with a d are directories. The next 3 letters are permissions for the owner. The owner is specified by the name in the third grouping of characters from the left.

Even after downloading the new package, the default permissions assigned to the extracted files and directories may not have sufficient privileges to install the program after running ‘sh install.sh’, resulting in a permissions error. To remedy this, you need to give all extracted files and directories execution privileges. You can do this by going to the location of the extracted files and typing the following:

find . -type d -exec chmod 700 '{}' ';'
find . -type f -exec chmod 700 '{}' ';'

The first command sets all directories in the current directory permissions to read, write, and execute, while the second command does the same for files. This will give the owner of the files sufficient permissions to run the ‘install.sh’ command.

If the above doesn’t work, you can try giving everyone full rights to the files in the current directory.  A warning though, this should only be done to files that are temporary and only to files that you trust. A lot of security holes in Windows is attributed to the fact that full rights are given to all files during execution. To do the aforementioned type:

find . -type d -exec chmod 777 '{}' ';'
find . -type f -exec chmod 777 '{}' ';'

Hopefully, this should give you the ability to run those ‘install.sh’ files you get. If you’d like more information on the above consult the following:

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.

PostgreSQL and its History

As I’ve played around with PostgreSQL, I’ve found it to be quite a capable database. I’ve begun to wonder how common PostgreSQL is used in production systems. After a little bit of research, apparently quite a few organizations use this database.

PostgreSQL was originally developed at the University of California at Berkley by Profesor M. Stonebraker in 1986. Postgres, as the database was originally called, was later commercialized by the company Informix and renamed Illustra. Informix was later purchased by IBM for 1 billion dollars. In 1996, Postgres95 – the open source version of Postgres – was created. This was later renamed to PostgreSQL 6.0.

After over a decade of development, I think its safe to say that this database is mature and commands a large install base due to corporate support by established companies (Sun, Fujitsu, Afilias, etc.) and the large development community behind it. I just find it weird that I don’t see a whole lot of PostgreSQL fanboys running around telling everyone and their mothers about this software. This is how obscure OSS projects gets well known – kind of like how MySQL and Linux got popular.

If you would like more information on the topic, please check the postgresql.org’s history page. I’ve also put up an article on PostgreSQL pertaining to domains.

New Articles

PostgreSQL: What is a Domain?

After running PgAdmin III and opening up a database schema, you may notice an item listed as ‘Domain’.  Think of domains as a custom data type that can be put together using data types already found in PostgreSQL along with the ability to set rules or constraints on this data type.

Domains are used to define a commonly used data object found through out a database. For example – A phone number object can be defined as a domain and reused through out a schema. You can define this phone number domain as 13 characters and include a constraint to match a regular expression that checks for a specific format. Once the domain has been defined, you can reuse the same domain in different tables to define the data type used for a specific column.

Launch the Bash shell and open up a sandbox database using psql.

I typed ‘$ psql -d <database_name>’

Next I created a domain for a phone number by typing the following:

CREATE DOMAIN phone_number as CHAR(13)
CHECK( VALUE ~ '((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}' );

Now, let’s add this domain to a new table.

CREATE TABLE customers 
(
id Serial Unique Not Null,
name varchar,
phone phone_number
);

We can now test to see if the constraints are enforced for the phone number.

INSERT INTO CUSTOMERS(name, phone) VALUES('Alex', '(123)123-1234');

INSERT INTO CUSTOMERS(name, phone) VALUES('Bob', '3213231313');

The second insert statement for bob should fail because it does not match the regular expression check for the phone_number data type or domain.  The convenience of creating the phone_number data type is that we can now reuse the same data type in other tables that may need to store phone numbers, giving us a central point of maintenance for adding or removing constraints and checks for this type of data.

If you would like more information on this topic, please check out the following links:

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.

Hello Houston and Hello Dallas and Hello Centralized Authentication

After a short trip to Houston and back, I noted a few sites that are along I-45. Their’s Fairfield’s Sam’s Boat, which I vaguely remember visiting years ago at a random stop for dinner. I recall the place being fairly clean and the food wasn’t bad either. Their’s also a gas station that sells alot of beef jerky by Centerville, but I’ve never really bothered to try it. Their’s also a fancy new bakery thats opened in Corsicana right by the Home Depot. All this stuff is right by the highway.

Over the weekend, I encountered a very common problem when administering a network of servers. Even though the development team numbers only a handful of people, recreating the same logins and passwords on each machine can quickly become tedius. The common term for the solution to this problem is ‘Centralized Authentication’. Centralized authentication is solved using Active Directory on the MS platform. Since we’re developing our system in Linux, I needed to search for some alternatives to Active Directory. After a few quick Google searches, I stumbled upon a few open source alternatives and even some tutorials.

Howtoforge.com: LDAP Authentication in Linux – Covers OpenLDAP, pam_ldap, nss_ldap, PADL mirgration tools

Openinput.com: Central Authentication server (old but still pertinent) – Covers OpenLDAP, Hendal Kerberos, SSH, PAM, NSS configuration

When it comes to centralized authentication, you’ll see the term ‘LDAP’ thrown in the conversation. LDAP is an open standard TCP/IP communications protocol for connecting to different applications or servers. It isn’t a data store. In the near future, I do plan on implementing a centralized authentication server thats compatible with LDAP. This will not only give us a much better way to manage users on our network, but provide us with a well supported and mature communications protocol to program against in our new applications.

 

Getting around Linux

For the past few months, I have been making a gradual migration over to the Linux platform. This has been mainly due to the maturity and ease of configuration of the Ubuntu distribution. In comparison to Debian, the setup for Ubuntu Server is almost identical with the exception of providing a slightly more refined setup wizard. I put up a short ‘article’ with some details on creating a new user in Linux.

I’ve also been experimenting with Ubuntu Desktop as a development environment for Python. My basic setup is Eclipse with pyDev, Subversion, pgAdmin III, python, and the Bash shell. Pretty bland huh? On another note, the vast majority of my execution commands are still in the Bash shell. I’m not a huge fan of running scripts from Eclipse because of the lack of arguments you can pass to the scripts. Although, I’m sure their is a way to do it – just don’t know how yet.

New Articles

Linux Administration: Creating or Adding a New User

Today I had to add a new user to a server running Ubuntu Server 7.04 using the Bash shell. The new user’s login will be ‘bob’.

  1. First create the user’s login to the system – type:  adduser bob
  2. Afterwards, I wanted to add the new user to a few groups, specifically groups I belong to in the system. So I typed: groups alex
  3. Now you can add whatever groups you think bob needs to belong to by typing: adduser username groupname

If you would like to know more about administering users, I recommend looking at the following links:

How to Get a Free SSL Certificate for IIS

As a exercise, I wanted to figure out how to create an SSL certificate that I could use on this website for securing the admin section and my credentials at login. After a quick google search, I yielded two solutions – either create a certificate using OpenSSL or use Microsoft’s IIS Resource Kit.

I opted for the OpenSSL solution, however in hindsight, it would’ve been alot easier if I had just used the MS Resource Kit. I had to jump through quite a few hoops to get the OpenSSL solution working. For tutorials on both methods check the following links.

Even though the OpenSSL tutorial says ‘for IIS 5’, the directions work fine for IIS 6. Another thing to note is that during installation of OpenSSL, it asked to replace a few DLL files. I replaced mine, but not before backing them up. So far I have not had to revert to my previously installed files.