When syncing files over a trusted network, where speed matters more than someone’s ability to see contents of the transfer, might want to run rsync as a daemon instead of using remote shell as the transport.

In my tests, running rsync as a daemon produces file transfers almost twice as fast as when rsyncing over SSH.

Read the rest of this entry…

A project I’m working required a comma delimited file containing date ranges, in one week increments, from July 1987 to the present. That’s 1166 week ranges. What sounds like a potentially time consuming ordeal, takes about 10 sec to produce with the following shell one liner:

for n in $(seq 0 1166); \
do echo -e \
$(date +%m/%d/%Y --date="1987-07-01 +$n week")","\
$(date +%m/%d/%Y --date="1987-07-01 +$n week +6 day") \
>> date.ranges; done

Read the rest of this entry…

Most of the stuff I do is via the shell, but once in a while need to attach to an existing X session on my work desktop. My requirements are that the method:

  • Uses SSH for authentication
  • Tunnels VNC traffic over SSH for security and so no additional ports need to be opened

x11vnc is what I’ve been using. Here’s a little shell script I wrote that will take user@hostname as a variable, enumerate an existing GDM session on the remote computer, create an SSH tunnel and attach to it via VNC. It uses aggressive compression, which looks a bit ugly but still works over a low bandwidth connection. The auth file enumeration bit works with Gnome, but could probably be adapted for use with other window managers.

Read the rest of this entry…

1
2
3
4
5
sudo -s
if [ -f /tmp/nmap.* ]; then rm /tmp/nmap.*; fi
nmap -sP -PA 192.168.0.0/24 >> /tmp/nmap.sweep
for h in $(grep Host /tmp/nmap.sweep | awk '{print$2}'); do $c -PN -A $h >> /tmp/nmap.scan; done
less /tmp/nmap.scan

ubun7u_vect0rizedThis is a (long overdue) follow up on my ancient post on how to setup a Nokia E62 as a bluetooth modem on a Windows laptop. It’s been a couple of years now since I’ve purged the Winblows partition from my Dell Inspiron 1501 and it’s been happily running Ubuntu using the E62 to get to the Internets. Just got a Dell Mini 10 for work, so might as well post the steps while they’re still fresh in memory (my RAM gets regularly purged, as it turns out).

Read the rest of this entry…

Partitioned a 4.2TB volume with fdisk, created a file system and all I got for was a lousy 2TB. WTF? fdisk man page explains:

fdisk  doesn’t  understand  GUID  Partition Table (GPT) and it is not designed for large 
partitions. In particular case use more advanced GNU parted(8).

Ok, parted it is then..

Read the rest of this entry…

Setup a new backup server and getting the following error from Cron in /etc/cron.daily/logrotate:

error: error running shared postrotate script for /var/log/mysql.log
/var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log
run-parts: /etc/cron.daily/logrotate exited with return code 1

Read the rest of this entry…

The shell one line script below will:

1. Find all files below current dir
2. Rename the file with download Source and date range as part of the new file name
3. Renamed file will stay at current location (e.g. file “./path/to/dir/crappyname” becomes “./path/to/dir/DC.Circuit-2006.06.02-2006.07.01.txt”)

Read the rest of this entry…

With User Private Groups, umask of 002 or 007 makes more sense than the traditional umask of 022 when multiple users are working with shared files. Libpam-umask is handy for overriding the default umask setting.

Starting with Debian Lenny, libpam-umask is part of libpam-modules (which was auto installed on every Debian Lenny setup I’ve done so far), so just need to add the following to “/etc/pam.d/common-session”:

session    optional     pam_umask.so umask=002

Read the rest of this entry…

To trim a video clip, mencoder and ffmpeg expect a start time in hh:mm:ss, but instead of end time, want duration:

$ mencoder -ss 00:02:55 -endpos 00:07:15 -oac copy -ovc copy in.avi -o out.avi
$ ffmpeg -ss 00:02:55 -t 00:07:15 -vcodec copy -acodec copy -i in.avi out.avi

Video players make it easy to identify start/stop times, but difficult to figure out duration, so I wrote a little shell script that will calculate duration from start/stop times.

Usage example:

$ calc-duration 00:02:55 00:10:10
 
 Start: 00 hrs 02 min 55 sec
 Stop:  00 hrs 10 min 10 sec
 
 +----------------------+
 | duration is 00:07:15 |
 +----------------------+

Read the rest of this entry…