Linux

I sometimes have to transfer files with spaces in the names, I like using a for loop, but the usual way doesn't work.

Usual way:

for file in `find . -type f|grep .ext$` do /do/something/to $file done

To get around this I use a while loop with a read instead. Using the read will read to the end of the line, enclosing within quotes escapes the spaces.

Unusual way:

find . -type f|grep .ext$ |while read file do /do/something/to "$file" done 

Or if you don't like using…



Symptom: iPod is blinking "Do Not Disconnect" even after you've umounted the filesystem. You need to eject the iPod. Umounting is not enough. You need to send an ALLOW_MEDIUM_REMOVAL to the usb device. The easiest way is with eject. Depending on your system, you may need to be root, or allow suid on eject (chmod u+s `which eject`). I've found that suid on eject is the most consistent solution, but I don't like suid executables on the system. sudo should also work, but I haven't tested this yet.

There is a patch in the recent eject that…



I have a partition formated vfat on my laptop so that I can access it from both Linux and Windows. I store my iTunes music there, so some of the directories have UTF8 characters. Bands like Moxy Früvous and Céline Dion show up as Moxy Fr?vous and C?line Dion by default. Adding the utf8 option to the mount solves the problem.
In /etc/fstab: /dev/sdb1 /media/usbdisk vfat utf8,user,noauto 0 0 I put in noauto because the filesystem will be mounted by root otherwise. I prefer to use the automounter (autofs) for this drive, so…



You can do this with rdist, but I prefer the rsync method.

You wish to backup a directory on machine A by making a copy on machine B. (In our case, machine B is a netapp, so we get further backup for free).

On machine A, create a new key using ssh-keygen [user@A]: cd; cd .ssh [user@A]: ssh-keygen -t dsa -C 'rsync@A' -f rsync_dsa Generating public/private dsa key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in rsync_dsa. Your public key has been saved in rsync_dsa.pub. The…



I've wasted enough time with these seemingly simple tasks to warrant a quick post. The problem is that you've created keys, put the relevant files all over the place, but nothing seems to be working.
  • Permissions
    authorized_keys and authorized_keys2600
    .ssh700
    Home Directory711
    Keys (id_dsa,id_rsa)600
    Public Keys (id_dsa.pub,id_rsa.pub)644
    The permissions shown are the maximum, you could put less…



Note: this is super old, use puppet instead these days...

 

Script: update_machine update_file
We use this simple script (no error checking as usual) to update our machine configuration.
We keep the configuration files in cvs and download them to a new machine.

Usage: update_machine directory root

directory
subdirectory to apply
root
where to apply the files (filesystem root, useful when doing this at…



Script: iptohex

No error checking, just a simple time saver. Converts an ipaddress into hexadecimal suitable for use by tftp tools and pxe booting. The builtin command gethostip does this also, I include the script incase someone finds it useful.

Example:

uphill@surrey[1]: 
iptohex 10.168.192.134
0AA8C086


#!/bin/bash

IPADDR=$1

if [ x${IPADDR}x = xx ]; then
echo "usage: $0 "
exit 1
fi

for octet in `echo $IPADDR |tr…



There is an excellent package for working with an iPod on Linux. gtkpod. Since version 0.99.2 it supports importing of Video's To install gtkpod, you'll need libgpod. With both installed, you can run gtkpod (it'll be in your menu under Sound & Video, called iPod Song Manager) and tell it where your system mounted your iPod. On my machine the mini mounts to /media/ipod and the video mounts to /media/usbdisk. gtkpod 0.99.4…



My co-worker just got an iPod so I thought I would try and encode a DVD onto it (an unencrypted DVD that I own, for backup purposes only, not to be used for public performances, etc, only I looked at it, I shut it off when someone looked over my shoulder...blah blah). The ffmpeg that comes stock on RHEL4 is insufficient to do the transcoding. I built a newer version and mucked around a bit and got this going. I have a simple wrapper (there are numerous versions of such scripts floating around).

ffmpeg-20060306…



Say you have some files named a100 to a200 that you want to rename to b200 to b100 (it really does happen).

y=200
for x in `seq 100 200`
do
   mv a$x b$((y--))
done

seq is a fairly useful tool, it can also take a reversed list.

for x in `seq 200 -1 100`
do
printf "$x "
done