Friday, May 30, 2008

Setup multiple IP addresses on Ubuntu

I'm working on migrating a server again today and we decided that we want to put some of the services on 1 IP and the others on another so if we ever need to move one set of services over the IP can follow. This is the machine that is running Ubuntu 8.04 Server.

It turns out this is a pretty simple thing to do. First, edit your interfaces file:

sudo nano -w /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

Then add in a few new lines below the eth0 section to create a new virtual interface:
auto eth0:0
iface eth0:0 inet static
address 10.10.10.200
netmask 255.255.255.0
Then restart your networking:

$ sudo /etc/init.d/networking restart

And there you have it, your new virtual interface with your new IP.

$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:1d:09:15:74:af
inet addr:10.10.10.122 Bcast:10.10.10.255 Mask:255.255.255.0
inet6 addr: fe80::21d:9ff:fe15:74af/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:52 errors:0 dropped:0 overruns:0 frame:0
TX packets:42 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9780 (9.5 KB) TX bytes:5388 (5.2 KB)
Interrupt:17

eth0:0 Link encap:Ethernet HWaddr 00:1d:09:15:74:af
inet addr:10.10.10.200 Bcast:10.10.10.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:17

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:38081 errors:0 dropped:0 overruns:0 frame:0
TX packets:38081 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1614360 (1.5 MB) TX bytes:1614360 (1.5 MB)

Thanks go to NukeSilo.com for getting me started and the Debian guide on Network configuration for all the details.

Tuesday, May 20, 2008

File modification dates changed in Ubuntu 8.04 on copy or move

Before upgrading from Ubuntu 7.10 to 8.04, I had the annoying problem of file modification dates getting changed when copying files to an NTFS file system. I also found that the problem was fixed in a newer version of ntfs-3g and all I had to do was get the package from the Ubuntu backports repository. Yipee!

But now I am running Ubuntu 8.04 and the problem has returned just in a new and nastier form. Now file modification dates are always updated in any move or copy, including ext3 to ext3! I did find that I could get around this problem when copying from the command line with cp using the -p switch to "preserve the specified attributes (default: mode, ownership, timestamps), if possible additional attributes: context, links, all". That didn't work for me when copying to an ntfs partition though. I got an error message: cp: preserving times for `/path/My Documents in Windows/testfile.zip': Operation not permitted

I could (and did) use sudo to make it work on ntfs though. I am glad there is a work around but I really do not want to have to drop to a command line every time I want to move or copy a file that I want the modification date preserved. I want to use Nautilus to drag and drop things!

I knew from my previous issue with ntfs that the copy command doesn't preserve the modification date by default but copying in Nautilus did and now it doesn't. There was a major change from 7.10 to 8.04 with the file system though. GNOME now uses GVFS instead of GnoneVFS (confusing similar names I know). And from my research, it looks like that is the problem. There are bug reports here (Ubuntu) and here (GNOME). Now let's hope it gets fixed for 8.04 and soon! Until then I guess I will be dropping to the command line to move my photos around, argh!

Friday, May 16, 2008

Weird sound issues on Ubuntu 8.04, only one speaker or no sound at all

Now that I have upgraded to Ubuntu 8.04 I am utilizing PulseAudio instead of esd so the audio subsystem should be much better right? According to the Hardy release notes, PulseAudio

... makes it possible to mix audio from multiple applications together, assign audio from individual applications to specific sound cards, adjust volume levels of each individual application, and perform advanced operations on audio streams such as transferring the audio to another computer or changing sample formats and channel counts.
That sounds great. Only thing is it has been doing some strange things. Occasionally I lose sound on some or all applications. I haven't exhaustively tried to fix this problem yet but so far restarting has been the only solution.

I also just recently had a problem where only my left speaker was giving me any output. Fortunately muting and unmuting fixed that. I also read that adjusting the volume of both or more channels will also fix it.

Thursday, May 15, 2008

Backup and restore a MySQL database using mysqldump

Today I am working on migrating some web apps to a new server. The old server was running Fedora Core 1 (yeah, really old) and the new box is running Ubuntu 8.04 server edition. (This is the first time I have ever used the server version. A coworker chose the distribution. I think I would have gone with CentOS (a RHEL clone) but it will be nice to play with Ubuntu server too. I am not some super Ubuntu fanboy!)

So I am moving a MediaWiki 1.5 installation (you know, the software that runs Wikipedia) and upgrading it to 1.12. Copying the files and upgrading proved to be pretty simple and painless so far as I can tell but backing up and restoring the MySQL DB between version 3.23.58 and 5.0.51a got me a little concerned. I wanted to copy over an archive of the /var/lib/mysql/mediawiki db data directory and restart MySQL but that didn't work. It has in the past when going from a 3.x to a 4.x but I may have been pushing my luck even then too.

The best way I found to do this though is to use mysqldump. I have used this before but I always forget all the syntax (which is why I am writing this post). mysqldump will spit out SQL statements to recreate your database and reinsert all the data. The problem with that is you then have a gigantic .sql file that you have to import into your new database. That feels a lot less foolproof to me than if just copying the data directory would (had it worked).

Anyway, to backup your database with mysqldump, do this:

$ mysqldump -u root -p DBNAME > DBNAME.sql

And then to restore that, do this:

$ mysql -u root -p
mysql>CREATE DATABASE NEW_DBNAME;
mysql> \q
Bye
$ mysql -u root -p NEW_DBNAME <>

There you have it. There is also the option to use msqlhotcopy but I didn't bother with it.

Other tutorials and thoughts:

Tuesday, May 13, 2008

Ubuntu and Debian users, update OpenSSL now!

It was announced today that there is a critical issue with OpenSSL packages in Debian based distributions such as Ubuntu:

A weakness has been discovered in the random number generator used by OpenSSL on Debian and Ubuntu systems. As a result of this weakness, certain encryption keys are much more common than they should be, such that an attacker could guess the key through a brute-force attack given minimal knowledge of the system. This particularly affects the use of encryption keys in OpenSSH, OpenVPN and SSL certificates.
Be sure to check update manager and download the latest updates!


Sunday, May 11, 2008

Web pages looking bad in Linux? Install msttcorefonts.

I'm doing a little work on a website at the moment but the menu looks terrible in Linux. On Windows it is nice and fits on one line. On Linux the menu breaks to a second line and looks TERRIBLE!

Before Microsoft's TrueType core fonts

The reason for this is I am using 'Trebuchet MS' as the font in my style sheet. Since Ubuntu Linux does not have that font installed, it goes with my backup of sans-serif. The best way to fix this is to install the package msttcorefonts. That will install a number of MS fonts including: Andale Mono, Arial Black, Arial, Comic Sans MS, Courier New, Georgia, Impact, Times New Roman, Trebuchet, Verdana and Webdings

After Microsoft's TrueType core fonts
If you are designing a web page you can, and should, pick another backup font too because you can't expect most people running Linux to have these fonts installed. In my case, I went with Helvetica as the backup and then sans-serif as the final failsafe. That at least keeps my menu on 1 line.

And for a much more in depth read on all the fonts and what looks like what on Linux, check out this great article: Linux Font Equivalents to Popular Web Typefaces

Saturday, May 10, 2008

New Update Icons in Ubuntu 8.04

Have you noticed the new update icons in Ubuntu 8.04 (Hardy Heron)? The old update icon was an orange box with what looks like a white sun in the middle. It was OK. The new icon is a nine sided star (enneagram) with a white arrow pointing down. I have also noticed a new "Critical Updates" icon that I never saw in Ubuntu 7.10 (Was it there and I just never saw it?). The critical updates icon is a big red down arrow with an exclamation mark in the middle.

I really do like the new icons. They look a lot more defined and get your attention better. I especially like that there is an icon that indicates critical updates now too. I do wish the critical updates icon was more like the regular update icon though. They are so different that it is not obvious at first that they both signify updates are available. Maybe Ubuntu could use the same icon and change the color and/or the little icon inside the icon.

My one other beef with the new update icon is it also looks like the application crash notification icon. I think it is a bad idea to make both of those icons look so similar. Check out the image below to see what I mean.

The new update icons in Ubuntu
(click on the image for the full size version,
PNGs don't resize well!)
Ubuntu 8.04 Update Icons
So what do you think of the new icons?

Thursday, May 8, 2008

Free Open Source Software Costing Vendors $60 Billion, How Naive!

I read a post over at CNet a while ago that Study Finds "Free Open Source Software Is Costing Vendors $60 Billion". Granted I have not read the $1,000 report but the title is a very naive assessment of the cost and benefits of Open Source software.

I imagine the argument in the report goes something like this: You can get a free and open source web browser, web server, operating system, office suite, database or two, ftp client, im client, email client, file de/compression utility, image editor, anti virus, PDF generator, etc. (the list could go on almost forever) so you don't buy the commercial version. Not buying the commercial version is $60,000,000,000 worth of unsold software. That argument is likely true in a lot of instances. Why would someone pay for software when they could get software that meets the same needs for free?

The biggest issue I have with this assessment though is it treats the use of Open Source over commercial software as zero sum. The idea that if you use Apache instead of buying IIS, Microsoft just lost X dollars in revenue (add it to the $60 billion) and you saved X in expenses, The End. But if you are also a commercial software vendor, which is very possible, then you can use the money you saved to develop your commercial application and make many multiples of X more. If you are not a commercial software vendor then you just saved money that you can spend on a better more specialized software package. Sure Microsoft got a smaller piece of the pie (or no pie) but thanks to the money you saved and were able to invest in your own product or spend on some other software you could not have bought otherwise, the pie is now considerably larger.

Open source software also raises the bar for commercial software leading to better, more useful software and ultimately more software sales. When Microsoft sees that Apache is a serious competitor to IIS, they can either improve IIS so it is better than Apache or they can ditch it and focus on improving their more profitable software like Windows and Office. Do you remember how it took Microsoft forever and a day to get from IE 6 to 7? Do you know why? They didn't have any reason to until Firefox became serious competition. Open Source software raises the bar for commercial software that competes with it and that is good for all consumers. Open Source provides the basics and lets commercial vendors concentrate on the specialized. The Gimp certainly has not killed Photoshop.

And one last note. What about all the revenue from services provided by the companies that back Open Source software. IBM, Red Hat and others are doing pretty well.

What are others saying?

Sunday, May 4, 2008

Resize and rotate images easily with Gnome in Ubuntu

Today I wanted to post some pictures to a site but to upload them I needed them to be considerably smaller. I know lots of ways to resize images in Linux but I needed an easy way to resize them. In Windows, I am used to using the Image Resizer Power Toy. (Why is that not a default feature?) The image resizer in Windows allows me to just right click on one or more images and resize them to any number of sizes. That is pretty handy and a feature I was looking for in Linux too. Sadly, there is not one already installed by default. I knew I could use the Gimp to do what I wanted but that was overkill. I wanted a simple and fast solution.

That was when I found the nautilus-image-converter package thanks to this and this. You can install it from Synaptic (System -> Administration -> Synaptic Package Manager) like I did or from the command line with apt-get like so (make sure Ubuntu Universe is enabled first under System -> Administration -> Software Sources):

sudo apt-get install nautilus-image-converter

After installing it, you will need to restart Nautilus. The best way to do that would be to log out and log back in. You could also quit and restart Nautilus with the command

nautilus -q; nautilus &


which will quit and then start it back up in the background. Once Nautilus has restarted it will load the new extension and you will be able to resize and rotate images from the right click menu. You can also resize and rotate multiple images if you select multiple images first. Both resizing and rotating allow you to take the action on the current image or make a copy and rename it with .resized or .rotated. The copy option is the default for both actions. See the screen shots below for all the options available.

The new resize and rotate options

The resize image(s) dialog

The rotate image(s) dialog
There you have it. Easy image resize and rotate in Gnome. And want it to be default, vote for the idea below: