08.14.08
How to set time zone in Ubuntu Hardy Heron
You used to be able to use tzconfig to set the time zone in Ubuntu. With Hardy Heron you can no longer do this, so how do you do it? Simple:
sudo dpkg-reconfigure tzdata
Random notes from the tech world.
You used to be able to use tzconfig to set the time zone in Ubuntu. With Hardy Heron you can no longer do this, so how do you do it? Simple:
sudo dpkg-reconfigure tzdata
In Debian / Ubuntu, sometimes you want to keep a package at a specific version, and not upgrade it. For instance, the Perl module DateTime::Timezone in Ubuntu Dapper lists its version as 1:0.37-1, when the version is actually 0.37. This makes it difficult if I build a new package of the perl module at version 0.7701, because though I can force install that version, if I run an apt-get upgrade later, it’s going to install the former, because it sees it as version 1, which is greater than 0.77.
Fortunately, the fix is easy: put the package on hold. This prevents it from being upgraded, though that also means you won’t get updates to it from the main repositories. If you built it yourself, then that might not be such a bad thing. To put a package on hold, you do:
echo packagename hold | sudo dpkg --set-selections
Replace packagename above with the name of your package (for instance, I would put libdatetime-timezone-perl). Did it work? Let’s see!
$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree... Done
The following packages have been kept back:
libdatetime-timezone-perl
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
$
Looks good to me!
Reference
Due to the recent ssh vulnerability, many releases of Ubuntu found themselves with vulnerable ssh keys.
User Keys
Run ssh-vulnkey to see if you’re unlucky. If you are, you’ll have to regenerate your keys.
ssh-keygen -t rsa
That’s it. If you’re using dsa, use dsa in the above instead of rsa. You should let it overwrite your existing key file. Remember to clean up ~/.ssh/authorized_keys (or ~/.ssh/authorized_keys2) on the servers that might have your old key!
Server Keys
Dumping and re-creating your own keys is okay, but what about the server?
For ssh1 keys, do:
ssh-keygen -q -f /etc/ssh/ssh_host_key -N '' -t rsa1
For ssh2 keys, do the following:
ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa
Note that when you first connect to the server thereafter, it’ll warn you that the keys have changed. Well, obviously, you just regenerated them. You may have to manually edit
~/.ssh/known_hosts
to remove those lines.
Reference
If you’re like me, you may need to build your own packages in Debian, or perhaps have downloaded different versions of packages to install on your system. Sometimes you’d like to go the other way, though, and install an older version of a package you found in the repository, or even the same version, but a different build.
For example, let’s say you built your own version of perl, say 5.8.8-7blindedbytech1. Then, Debian finally gets the same version of perl into their repositories, say 5.8.8-7etch3. Unfortunately, doing an apt-get dist-upgrade isn’t going to install this version. This is particularly annoying if other packages have dependencies on these perl versions.
What’s one to do? Wouldn’t it be nice if you could specify which version of perl package to install? As it turns out, you can. When you do the apt-get install of the package, follow it by an equal sign (=) and the particular package version you want, e.g:
sudo apt-get install perl=5.8.8-7etch3
Obviously, this will only work if the specific version is in one of your repositories. You can do this with multiple packages, too. In fact, I had to, because perl-base was also a different version:
sudo apt-get install perl=5.8.8-7etch3 perl-base=5.8.8-7etch3
Be careful of dependencies. Don’t just blindly run these commands unless you know what you’re doing, and be sure to read the output messages, as it may have unintended effects. For instance, for me, the above command uninstalled mysql-server. Make sure you read the warnings it gives you, and you understand what they mean.
While I tend to like running Ubuntu on the desktop, I sometimes find myself needing to run Windows programs for various things. For that, I actually got VMware Workstation for Linux, and set up a Windows XP Professional image, with a partition size of 8 GB. I rarely use the image, so imagine my surprise when I actually ran out of disk space in the partition. I was further confounded to find that you couldn’t dynamically resize the partition. The problem is twofold: needing to resize the VMware disk image, and then needing to resize the partition on which Windows is installed to fill the VMware disk image.
Resize the VMware Disk Image
To resize the VMware disk image, we can use the program vmware-vdiskmanager. Make backups before proceeding. I had an 8 GB partition now, so let’s make it a 40 GB partition instead:
$ vmware-vdiskmanager -x 40GB /path/to/my/image/mywindowsimage.vmdk
Using log file /tmp/vmware-jlee/vdiskmanager.log
The old geometry C/H/S of the disk is: 16383/16/63
The new geometry C/H/S of the disk is: 16383/16/63
Disk expansion completed successfully.
WARNING: If the virtual disk is partitioned, you must use a third-party
utility in the virtual machine to expand the size of the
partitions. For more information, see:
http://www.vmware.com/support/kb/enduser/std_adp.php?p_faqid=1647
Good so far. Now, the disk image is 40 GB, but the partition on the disk is still set to 8 GB. What we want to do is grow the partition to fill the newly allocated space.
Boot an Ubuntu Live CD
To resize the partition, I can use a Linux live CD. Rather conveniently, I can use the same Ubuntu live CD that I used to install Linux on my desktop.
It took me a while to figure out how to boot a CD in VMware, mostly because the BIOS screen for VMware disappears so quickly. When starting up the VMware image, I hit F2 quickly before Windows started loading to enter the VMware BIOS. Then I could go to the Boot menu, and set the CD-ROM drive to boot before the hard disk. Otherwise, it would start directly into Windows.
Once that was done, I made sure that a Gutsy Gibbon live CD was in the CD-ROM drive, and restarted the VMware image.
Resize the Partition
Now I had the Ubuntu live CD running in my VMware image. I went to System -> Administration -> Partition Editor. I clicked on the partition, clicked “Resize/Move”, and dragged the right slider all the way to the right, to fill the disk. I clicked the “Resize/Move” button, then “Apply”. After it completed, I restarted the VMware image, which prompted Windows chkdisk to run, and then reboot again. Once Windows booted up, Windows noted that it had detected new hardware and needed a reboot. I let it do so, and just like that, I had grown my 8 GB drive to 40 GB.
Conclusion
So there you have it — if you have half an hour and a current Ubuntu live CD, you can resize your VMware image. As with any disk editing operations, you should always make backups before making changes. It’s kind of annoying that the image doesn’t dynamically grow, but it’s nice to know that it can be handled. What’s also cool is to be able to use Linux live CDs to edit properties of VMware instances.
Compiz Fusion on a Radeon Mobility X1400 graphics card? Hell yeah!
Oh, driver hell. Proprietary drivers are the bane of Linux’s existence, as any Linux user with a current ATI graphics card can tell you. I have a Lenovo Z61m on which I’d like to install Ubuntu Gutsy Gibbon, but good luck — the ATI Radeon Mobility X1400 will wreak havoc on your installation procedure. This is not new; Feisty Fawn had the same problem. Fortunately, you can in fact work around it.
Installing From the Live CD
First, there’s getting the live CD to work. You can download the alternate install CD and work from text mode, but I’d much rather use the regular live CD. Fortunately, you can! Boot up the live CD, and it’ll eventually die at some point, because the X server can’t launch properly. Hit Cntrl + Alt + F2 to jump to a virtual console. Type clear to clear the screen, then type the following:
sudo apt-get update sudo apt-get install xorg-driver-fglrx sudo depmod -a sudo aticonfig --initial sudo aticonfig --overlay-type=Xv startx
You’ll obviously need a working Internet connection to make this work. Congratulations, you can now use the live CD! Run the installer as per normal.
Special note for Lenovo users: Do not delete the FAT32 service partition! You can use this to restore your Windows partition or run other diagnostics. I found it worked well to resize the existing Windows partition and dual boot.
After installation, you’ll reboot your system and — surprise! It doesn’t work. It’ll die at loading the X server again. Hit Cntrl + Alt + F2, and enter the following:
sudo apt-get update sudo apt-get install xorg-driver-fglrx sudo apt-get install xgl sudo apt-get install xserver-xorg-video-radeonhd sudo depmod -a sudo aticonfig --initial sudo aticonfig --overlay-type=Xv startx
This is slightly different than before. Why? Well, no doubt you want to use those fancy Compiz Fusion effects, right? You didn’t need them to do the installation, but installation is done now. You’ll need to get the right drivers, as well as install xgl. Once you’ve done that, you might also need to edit /etc/X11/xorg.conf to change Option "Composite" "0" to Option "Composite" "1". After that, you should be able to enable Visual Effects through System->Preferences->Appearance, Visual Effects tab.
If you’re a debian user (this includes all of you Ubuntu folks!), then you may be familiar with the strangeness of status codes for dpkg -l. For example, let’s say you install postfix:
sudo apt-get install postfix
We can look at the package list with dpkg -l. Let’s take a look at postfix:
$ dpkg -l | grep postfix
ii postfix 2.2.10-1ubuntu0.1 A high-performance mail transport agent
The ii at the start is some sort of status. Let’s remove the package:
sudo apt-get remove postfix
All fine and good, until we take a look at dpkg again:
$ dpkg -l | grep postfix
rc postfix 2.2.10-1ubuntu0.1 A high-performance mail transport agent
Hmm. Instead of removing it from the list, we see this peculiar rc status. What the heck does that mean?
The answer lies in the dpkg listing itself.
$ dpkg -l | head -3
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
There are three columns here, though y ou usually don’t see the third.
So, if you take the first letter of each potential state for each of those, you get your status code for dpkg. Let’s look at the some of these status codes again:
ii: Desired: (I)nstall; Status: (I)nstalled; Err: none.
rc: Desired: (R)emove; Status: (C)onfig-files; Err: none.
pi: Desired: (P)urge; Status: (I)nstalled; Err: none.
Mystery solved!
In the old days, a techie might install Windows on a computer, then install Linux. Later, the techie might decide to trash the Linux partitions for some reason, but on reboot — oops! LILO was still there. These days, GRUB has taken the place of LILO, but the old problem is still there: how do you clear out the master boot record completely?
If you had a Windows 98 boot disk lying around, you probably remember the old magic of fdisk /mbr. This simple command did just what you wanted — flashed out the master boot record, and things worked like you expected.
However, in this day and age of Linux live CDs, there must be a way to do so without breaking out the floppies. As it turns out, there is, through a simple program known as dd.
The beginning of a hard drive is where you keep both the master boot record, as well as the partition table. What you want to do is write zeroes to the master boot record, but not the partition table. Many folks recommend writing zeroes to the first 512 bytes of the drive — this is wrong.
The truth is, the first 446 bytes of the drive are dedicated to the master boot record executable. The remaining 66 bytes are used to hold the partition table. Hence, what we need to do is read in a source of zeroes, and output it to the first 446 bytes of the drive. Simple! Let’s take a look at the command:
dd if=/dev/zero of=/dev/hda bs=446 count=1
This says to do just that — use as an input file the special device /dev/zero, an output file of the drive (substitute the drive identifier in question here!), with a block size of 446 bytes. Oh, and do it just once. No nonsense, quick, and effective. So, put away those MS DOS disks — that Linux live CD works just fine.
Are you running Beryl on Ubuntu? Do you have the problem where dialog boxes or new windows open under your existing window? This is most noticeable when web browsing, and coming across password-protected pages. I’ve been annoyed by this bug for about a month now.
It turns out, this is not a bug, it’s a feature. Beryl has a setting called “Focus Stealing Prevention”, designed to keep windows from stealing your focus. This is great if you really need to concentrate; it’s annoying if you need to find the password dialog box before proceeding.
To fix, open up the Beryl Settings Manager, and click on General Options. In here on the Main tab, you should find an option for “Level of Focus Stealing Prevention”. This is probably set to “Extreme”. Switch this to normal and voila — your windows should behave normally again.
Reference: LinuxQuestions.org: Beryl window preference problem
After recent updates, I started getting errors like the following:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
This occurred on both Dapper Drake as well as Feisty Fawn versions of Ubuntu. It was really annoying to see this whenever running apt-get. Fortunately, the solution is pretty simple. As noted above, this is a locale error, so the trick here is to install the language pack for my language. In this case, that would be English, so I ran the following:
sudo apt-get install language-pack-en
This added a dependency for language-pack-en-base, but after installation, the error went away.
« Previous Page — « Previous entries « Previous Page · Next Page » Next entries » — Next Page »
Bad Behavior has blocked 2090 access attempts in the last 7 days.