Encrypted tar archives

Got this from http://www.linuxquestions.org/questions/linux-newbie-8/howto-encrypt-a-t...

Create the encrypted archive
$ tar -cj special-dir |
openssl enc -aes128 -salt -out special-dir.tar.bz2.enc -e -a -k 'foo%my%pass'

Unencrypte the archive
$ openssl enc -aes128 -in special-dir.tar.bz2.enc -out special-dir.tar.bz2 -d -a

Restore the archive
$ tar xjf special-dir.tar.bz2

Date math in the shell

hooboy! The `date` man page gives this example

$ date --date='@2147483647'

but nowhere does it document use of the `@` symbol. However, you can see that this will let you do date math, e.g., compute the interval between two dates:


... time goes by ...

SECS=$(( `date +%s -d $NOW` - `date +%s =d $THEN` ))
echo Elapsed hh:mm:ss beween NOW and THEN is $((SECS - 16*3600))

'''Note''' 16*3600 is and adjustment for the timezone offset, automating this computation is an exercise left to the reader.

Green Drives and RAID

I do not like Green drives and RAID
the failure rate is high for what I paid.

Avoiding race conditions in Bash

I had prototyped the following code for a helper script run as a post-exec routine from rsnapshot:

if [ -f $LOCK ]; then
  /bin/ps -p `cat $LOCK` 2>&1 >/dev/null
  if [ $? -eq 0 ]; then
    echo rsnapshot already running
    exit 1
  echo $$ > $LOCK
# main body of script
rm $LOCK
exit 0

Cron Daemon FROM header

I wanted to do something simple. My cron emails had a FROM header:

Cron Daemon <root@hostname>

And I wanted to change this to

Hostname Cron Daemon <root@hostname>

so I could see this easily in the mail list.

It turns out that cron does not let you configure this anywhere. If you really want to do this, your have to turn off cron's mail feature and pipe custom headers along with the output of your script into a different email system, e.g.,

Resize NTFS partition - Windows 7 guest, Ubuntu Host

This is how I managed to resize the harddrive.vdi file of a VirtualBox Windows 7 guest form 40G to 60G, using a spare Ubunt guest to do some of the dirty work.

First, used the main VirtualBox window to detach the hard drive from my Windows virtual guest. Then I had to clone the .vdi file so that the --resize command would work.

$ vboxmanage clonehd win.vdi win7new.vdi
$ vboxmanage modifyhd --resize 61440 win7new.vdi

Now the virtual drive was 60G, but the partition and file system were still 40G.

LightDM “Failed during authentication”

With Ubuntu 14.04, I suddently stopped being able to log in. Just one account, and just via LightDM. After transing .Xauthority and various config files, I cleared my homedir back to just what /etc/skel has. This worked. Then I restored the prefs folders for subversion, firefox and chrome. Irritating.

Ubuntu Server install gotcha

Just installed Ubuntu 14.04 server with an existing VERY LARGE data volume mounted. At the end of the install it hung for over 1/2 hour, showing 97% completed and status Cleanup.

Then I noticed that my very large data volume was being accessed. Since I had configure the mountpoint and asked that it NOT be formatted, I assume that it was running updatedb on the thing in order to populate the locate database. No useful to me, so I killed & re-ran the install.


Turns out that ext4 doesn't really support file systems of up to 24T because the robust set of tools for checking and resizing ext4 file systems doesn't yet support anything larger than 16T (the old ext3 limit). Oops!

Nonetheless, I have a huge man-crush on on Theodore Ts'o because I believe him to be the author of this snippet from the resize2fs man page:

IRC micro howto

I use IRC rarely, so I always forget how. Here's what you need to know:

  1. Register a nickname with NickServe, set a password, and remember it
  2. After logging in to freenode, use the /nick command, using your saved nick, to set your nickname for the current session.
  3. Now use the /id command with your password to identify yourself
  4. After that, things might work.

Syndicate content