Blogs

Dev machine LAMP stop start restart

Say you have a debian laptop of limited horsepower. Say that on your laptop you don't want mysql and apache running all the time, so you can set them to only start up when you want them. Say you don't want XAMP or something that installs your services in no standard places that debian won't find them to update them. So write your own script to only start LAMP when you want it running.

First remove apache and mysql tendency to start with the machine:

update-rc.d -f mysql remove
update-rc.d mysql stop 20 2 3 4 5 .

update-rc.d -f apache2 remove
update-rc.d apache2 stop 20 2 3 4 5 .

then create a bash script that will allow you to do:

sudo lamp start
sudo lamp stop
sudo lamp restart

Here's the script:

#!/bin/sh
case "${1:-''}" in
'start')
/etc/init.d/mysql start
/etc/init.d/apache2 start
;;

'stop')
/etc/init.d/mysql stop
/etc/init.d/apache2 stop
;;

'restart')
lamp stop
lamp start
;;
*)
echo "start stop or restart, please"
;;
esac

then mod the script to be executable
chmod o+x lamp.sh

then move or link the script from a directory in your command path
ln -s path/to/lamp.sh /usr/bin/lamp

You're done.

Turn off "spatial finder" in debian?

On Mac OS 9 the main file manager program was called the "finder" and it opened a separate window for every folder or directory that you opened. By the time you drilled down 6 levels, 6 windows cluttered your desktop. Each window represented one specific open folder. This metaphor is supposed to help people visualize where they are in an abstract filesystem and make the system more useable. This was called the "spatial finder".

Of course, proponents of silly and annoying metaphors like this are totally wrong, and the Mac moved to the OS X finder where windows exhibit "browsing" behavior instead. There you open a window which represents not a folder, but a changing view into the filesystem which follows you up and down a directory tree. You only need one window, unless you want to view more than one place in the tree simultaneously.

The Gnome file manager "Nautilus" can do either a "spatial" or a "browse" mode. Debian, purists that they are, sets nautilus to spatial mode, while the ever practical Ubuntu guys set it to browse mode. This is one time that I agree with Ubuntu over Debian. Here's how to fix their shortsightedness.

In your nautilus window:
Edit > Preferences > Behavior > Always open in Browser window.

Done! The time you will save closing excess windows will repay the time it took to read this post in about 2-4 minutes of file browsing - I promise!

The easier way to install your ssh key on remote servers

You want to install your ssh key on a remote server so that you can log into it without a password. Most guides will show you something like this:

user@host:~$ scp ~/.ssh/key.pub remoteuser@remotehost:~/
$ ssh remoteuser@remotehost
remoteuser@remotehost's password:
remoteuser@remotehost:~$ cat key.pub >> ~/.ssh/authorized_keys
remoteuser@remotehost:~$ rm key.pub
remoteuser@remotehost:~$ exit

That's fine, but why not do it in one step?
user@host:~$ ssh-copy-id -i ~/.ssh/key.pub remoteuser@remotehost
remoteuser@remotehost's password:

And you're done.

how to semi permanently liberate your olpc

get developer key for your machine
put it on a usb key in /security folder
plug key in olpc before boot
during splash screen hit escape
at ok prompt type "disable-security" hit enter
olpc no longer needs developer key to run unsigned os images

semi-permanent in that it will not survive if you upgrade the firmware, but it will survive a re-installation of the OS

OLPC bad hash for eblock problem when upgrading

Your OS image (e.g. os767.img) that you want to upgrade to is corrupted from either being downloaded improperly or copied to your usb drive improperly. For me it was the latter.

Use the md5sum command to compare the file you have copied to your usb drive to the one on the olpc website (md5 sum file is also on the olpc website so you can compare).

If, like me, your file was getting corrupted moving from your desktop where you downloaded the file to your usb drive, try both of the following in sequence.

1) mount the usb drive with the sync option (under gnome 2.24 or newer you can get to this in the drive properties dialog under mount options -- type sync there and remount the device). Note that this option produces more wear on flash drives, and should be turned off after you successfully flash your olpc. On the other hand, if you are regularly getting large files with bits corrupted, especially on a cheap flash drive that you are not worried about, might not be that bad to leave it on.

2) use the cp command from the commandline rather than dragging the file to the usb drive from gnome, it doesn't cheat to make the copying seem faster.

How to write zeros to all sectors of a drive under linux

WARNING, THIS WILL DESTROY YOUR DATA IF YOU DO THIS TO THE WRONG DRIVE

shred -vfz -n 0 /dev/xxx

-v is for verbose (this takes a huge amount of time and you really will want progress updates)
-z is for write zeros
-n 0 is for how many passes of totally random data to write first, here none. Feel free to do random passes if you are doing this for data destruction purposes. It takes a long time.

(you should replace xxx with the raw drive, not the partition, e.g. sdd not sdd1. YOU WILL DESTROY YOUR DATA IF YOU DO THIS TO THE WRONG DRIVE. If you need to find out what your desired target disk has been recognized as (may change every boot) run fdisk -l or gparted and look for a disk of the right size and type in the results. BE VERY SURE, and make sure your data is for the current boot (may change).

Yeeeaaarrrrgghh!

Were going to New Hampshire, North Carolina, Indiana, Florida, Michigan, New Mexico, Colorado, Nevada......

Thanks Howie!