I learned of a cool feature in the cd command, which to my knowledge works under zsh, bash, ksh and possibly other shells.

cd - takes you to your previous directory, letting you easily switch back and forth between two directories. Take /home/ryan and /etc for example:

ryan@lambda:~$ cd /etc
ryan@lambda:/etc$ cd -
/home/ryan
ryan@lambda:~$ cd -
/etc
ryan@lambda:/etc$

Please share any other cool shell tricks you may know :D

Comments 13 Comments »


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Sun, 27 Sep 2009 20:00:00 -0500

In light recent new attacks against SHA-1 [1,2], and the NIST guidance
on 1024 bit keys and SHA-1 hashes [3,4], I have decided to move to a new
OpenPGP key of a larger size. As such, I will slowly be transitioning
away from my old key.

My old key will continue to be valid for some time to come, but I'd
prefer all new correspondences to use the new one. I'll also be
switching to my new key for my outgoing signatures (email and code). For
this to work well, I'd like my new key to be re-integrated into the web
of trust. I've signed this message with both the old and the new keys,
to certify the transition.

The old key was:

pub 1024D/E95EDDC9 2006-02-22
Key fingerprint = 4EBE 56CB 0EFE CBED 2A92 8D4F 7BD1 5207 E95E DDC9

And the new key is:

pub 10240R/4A11C97A 2009-09-23 [expires: 2019-09-21]
Key fingerprint = 4E46 9519 ED67 7734 268F BD95 8F7B F8FC 4A11 C97A

To fetch my new key from a public key server, you can simply do:

gpg --keyserver subkeys.pgp.net --recv-key 4A11C97A

If you already know my old key, you can now verify that the new key is
signed by the old one:

gpg --check-sigs 4A11C97A

If you don't already know my old key, or you just want to be double
extra paranoid, you can check the fingerprint against the one above:

gpg --fingerprint 4A11C97A

If you are satisfied that you've got the right key, and the UIDs match
what you expect, I'd greatly appreciate it if you would sign my key:

gpg --sign-key 4A11C97A

Lastly, if you could upload these signatures, I would appreciate it.
Could you please upload the signatures to a public keyserver directly:

gpg --keyserver subkeys.pgp.net --send-key 4A11C97A

If you prefer, you may also email me your signatures in an encrypted
mail to my new key to ensure that I really own the addresses[5] I claim
to own in with my UIDs (as done with the ``caff'' keysigning tool from
the ``signing-party'' Debian package).

Please let me know if there is any trouble, and sorry for the
inconvenience.

Thanks,
Ryan "ryanakca" Kavanagh

[1] http://eurocrypt2009rump.cr.yp.to/837a0a8086fa6ca714249409ddfae43d.pdf
[2] http://www.debian-administration.org/users/dkg/weblog/48
[3] http://csrc.nist.gov/groups/ST/hash/statement.html
[4] http://csrc.nist.gov/publications/nistpubs/800-57/SP800-57-Part1.pdf
[5] ryan@ryanak.ca uses my IPv6-only mailserver, ryanak.ca. If you do
not have access to an IPv6 mailserver, could you please upload that
UID's signature directly to a public keyserver.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iQUcBAEBCgAGBQJKv/yAAAoJEI97+PxKEcl63qwn/1pX953oy4Z0cD1RA1msY6D3
d23aClUOnsh9YcRHiJny7oL18iA6o8otD9aE6pgmK/kHKGxHdEYEzafE+Ic6qqoV
QB6XIME8ySEGIEbHF5PNoUfkyIiN7hHzydFMLrE15Rs+LfXc8eMbwe3Qkk1fVSYZ
z523/+krOZmTohOd1hFg59H0qULG7PSj6yZY3NGThXvDvEbCj1SpspkeAiUIz5ii
Ystod1lxyusKBcCo98l3QgVGx1/SsrRsbfH7ijr5PuTwa3ouBPSdJT5lVmR/BPZ9
vk779PBbWOTEpXkFH/Y7cgCgpJoNdeoQ6hg8wBFEZVa1w2MTggBhhobkmufrOLDD
Gqt3edDYuiRZ2m0yy6LY0sVz05JHDmn6bAlI94TsxRZfJQ9UOA8PKg/7vPwkPcH9
RHwcn8w8j7KR1WXzY28aathjc1rDVGquhl6Ai5gbpnChjLtFr8JkvJ8MUi0J5pTF
3CuiSJO3NQsFWX4n8DAhu4WXhshYU1Wbxw4XjYJjKifsd0TGrM+DyLaEe+iprVco
0KxSSSw7HvKP20PxHy0+ioaEXwi4waAwxMofXUys9iPzklB3pTne8LIWWWOhZjzT
uHqgDIasN/RlH7ej05LHOC9OCKbHuqOvPjG0rVxqUocRY8NL8LVLBvggwk6Be2C4
osos+ORptm+mDyeH4kwY/8vqUmwiSlaRRrXZl4AoYjph6xd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6DY1l8h/KAgk7/SOEXhGO3ruQGPXl
lnHwN4e/97NLJdBsnMhX9U3jDf6eg5hgBx7KxrQuAG3Jm4qCIgFSw16dDivkyT2E
2DPYfVz9iX5vm8UNp6M4JY+oLE01MU6Y0eaDYkEbJWnI04BXGkKFjYB/EL5Pjsxv
WIe7qOvHUa82Te1+gNJL3sNNrE/uVbYHxyPWQmRfjQi6rCT/Yp9030bF6GCy0CfK
KykPJHx6XKr/p611N3JQOrwgjZCUjeJ1nevYNIU/dYKDUuuC/gBoiJiTlFXym+HG
GwcoXKm7fVf0dUJyXAJU+QMM9gPNFg6Km5CBp1goymTg54k6oj6Da9OKRcePoGGJ
ZEmAh9wsG8yzNCceITWgVtkbJYRyQuTTI/mgnZntWgg6mfNIVYbDRlkIgUdMV6eN
rd+W/rc8i7iDh+zw/3TCwYEzijr5i46czD2+jQ2Qh51jrVpcq5aDO/JyR5m3VNvr
ReG/YpS0oqFBPmd/xMQFLgupHVC7+47RL5lTAnY5OVxJ0FUzhBiSj45NOZm8r6yX
hi0k7d8GXJzUHReBuWJneZqw5Y22VbKwtBn0aSGmZt9vaovr1H4zGtFSIxJ//y5+
pQ6zk/E+VdKrKTkeVbRR+M3NVrS55NbA9ROyoFZV
=efnp
-----END PGP SIGNATURE-----

Comments No Comments »

The Quassel irc client was shipped as default in Kubuntu 9.04 and has this lovely feature allowing you to monitor multiple windows simultaneously, see this screenshot for a better idea of what it does.

However, I often want to access IRC from computers I don’t control and thus installing Quassel each and everytime I want to access IRC (it’s main feature is that it’s a distributed IRC client, multiple clients can connect to one core) is impractical. I thus resort to SSH (using one time passwords, who knows what’s sniffing my keystrokes), screen and irssi. However, irssi, out of the box, does not provide you with a ‘monitor’ window similar to Quassel’s. Here are the instructions on how to get one and what the finished product should look like.

Read the rest of this entry »

Comments No Comments »

I’ve been trying to figure out why I was always getting mount.nfs: mount system call failed when trying to mount an NFS share from my Debian server on my Kubuntu box. I guess I wasn’t paying attention when dpkg / debconf configured ‘portmap’ package on the Debian box. The solution is to run dpkg-reconfigure portmap as root on the server and select no when asked:

 ┌────────────────────┤ Configuring portmap ├─────────────────────┐
 │                                                                │
 │ By default, portmap listens to all IP addresses. However, if   │
 │ this machine does not provide network RPC services (such as    │
 │ NIS or NFS) to remote clients, you can safely bind it to the   │
 │ loopback IP address (127.0.0.1).                               │
 │                                                                │
 │ This will allow RPC local services (like FAM) to work          │
 │ properly, while preventing remote systems from accessing the   │
 │ RPC services.                                                  │
 │                                                                │
 │ This configuration can be changed by editing the OPTIONS line  │
 │ in the /etc/default/portmap file and adapting the use of the   │
 │ -i option to your needs.                                       │
 │                                                                │
 │ Should portmap be bound to the loopback address?               │
 │                                                                │
 │                 <Yes>                    <No>                  │
 │                                                                │
 └────────────────────────────────────────────────────────────────┘

I hope this will help whoever else encounters the same issue.

Comments 7 Comments »

At work I was asked to write a small script that allows users to get their quota from a Windows machine since apparently Windows doesn’t have an equivalent to the ‘quota‘ command. All these users also have accounts on UNIX boxes (running either SunOS 5.8 or Linux), so I figured the quickest way would be to SSH into one of these and make the output of the ‘quota‘ command easier to read.

This is composed of three parts, the first is a BAT script that calls putty with the hostname and points to a file with a list of commands to run. The second is this said list of commands to run. The third (and best part) is a short Perl script that will take the output of ‘quota -v‘ and format it depending on whether we’re running Solaris or Linux.

You will have to substitute HOSTNAME.DOMAINNAME.TLD with the Solaris/Linux box’s hostname. You may also have to change C:\Program~1\putty.exe with the path to your putty install. Place the following BAT file wherever. I put it in ‘Quota.bat‘ on the user’s desktop.

BAT file

REM - Quota.bat by Ryan Kavanagh <ryanakca@kubuntu.org>
@ECHO OFF
CLS
CALL C:\Program~1\putty.exe -ssh HOSTNAME.DOMAINNAME.TLD -l %USERNAME% -t -m C:\Program~1\winquota\quota

Now to the list of commands to run on the remote host, to be put in C:\Program~1\winquota\quota:

BASH script

#!/bin/bash
# By Ryan Kavanagh <ryanakca@kubuntu.org>
perl /usr/local/bin/quotacheck.pl
sh -c "echo -e 'This script will exit in:\t15 seconds\c'; sleep 1;"
sh -c 'for i in {14..10}; do echo -e "\b\b\b\b\b\b\b\b\b\b"$i" seconds\c"; sleep 1; done'
sh -c 'for i in {9..1}; do echo -e "\b\b\b\b\b\b\b\b\b\b "$i" seconds\c"; sleep 1; done'
sh -c 'echo ""'

This calls the Perl script. The rest of the script is to provide the user enough time (15 seconds) to read the output. If we didn’t have this, Putty would exit as soon as the display from quotacheck.pl had been displayed.

Place the following Perl script in /usr/local/bin/quotacheck.pl with executable permissions and you should be good to go.

Perl script

#!/usr/bin/perl
# quotacheck.pl -- Prettyfies the quota command's output
# Copyright (C) 2009  Ryan Kavanagh <ryanakca@kubuntu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                            
 
use strict;
use English;
 
my @quota = `quota -v`;
 
sub fmt_quota {
    my $line = shift;
    # Get rid of leading whitespace so that we can work with Linux's quota
    # command as well.
    $line =~ s/^\s+//;
    my @a = split /\s+/, $line;
    my %data;
    my $os = $OSNAME;
    my $unit;
    if ($os == 'solaris') {
        # Solaris' quota uses 1kb as the unit
        $unit = 1024;
    } elsif ($os == 'linux') {
        # Linux's quota uses 512kb blocks as the unit
        $unit = 512;
    } else {
        $unit = 1;
        print "Disk usage unit might be incorrect";
    }
    if (($a[1] &gt; $a[2]) &amp;&amp; ($a[2] != 0)) {
        # The disk usage is over the quota, we'll receive a disk grace time
        %data = (
            'fs' =&gt; $a[0],
            'd_usage' =&gt; sprintf("%.2f", $a[1] / $unit) . 'M',
            'd_quota' =&gt; sprintf("%.2f", $a[2] / $unit) . 'M',
            'd_limit' =&gt; sprintf("%.2f", $a[3] / $unit) . 'M',
            'd_grace' =&gt; $a[4],
            'f_usage' =&gt; $a[5],
            'f_quota' =&gt; $a[6],
            'f_limit' =&gt; $a[7],
        );
    } else {
        # We won't receive a disk grace time.
        %data = (
            'fs' =&gt; $a[0],
            'd_usage' =&gt; sprintf("%.2f", $a[1] / $unit) . 'M',
            'd_quota' =&gt; sprintf("%.2f", $a[2] / $unit) . 'M',
            'd_limit' =&gt; sprintf("%.2f", $a[3] / $unit) . 'M',
            'f_usage' =&gt; $a[4],
            'f_quota' =&gt; $a[5],
            'f_limit' =&gt; $a[6],
        );
    }
    if (($data{'f_usage'} &gt; $data{'f_quota'}) &amp;&amp; ($data{'f_quota'} != 0)) {
        # The file usage is over the file quota, we'll receive a file grace
        # time.
        if (exists($data{'d_grace'})) {
            # The disk grace time is set, therefore we want $a[8].
            $data{'f_grace'} = $a[8];
        } else {
            $data{'f_grace'} = $a[7];
        }
    }
    my @lines;
    use integer;
    my $fs_pad = (80 - length ($data{'fs'})) / 2;
    no integer;
    # Push the header
    push(@lines, " " x $fs_pad . $data{'fs'} . " " x $fs_pad . "\n");
    push(@lines, " " x 15 . sprintf("%-15s%-15s%-15s%s", "YOUR USAGE",
            "YOUR QUOTA", "YOUR LIMIT", "GRACE TIME") . "\n");
    push(@lines, sprintf("%-15s%-15s%-15s%-15s%s", "DISK USAGE",
            $data{'d_usage'}, $data{'d_quota'}, $data{'d_limit'},
            $data{'d_grace'}) . "\n");
    push(@lines, sprintf("%-15s%-15s%-15s%-15s%s", "FILE COUNT",
            $data{'f_usage'}, $data{'f_quota'}, $data{'f_limit'},
            $data{'f_grace'}) . "\n");
    return @lines;
}
 
# Run fmt_quota on quota's output. Nothing interesting before line 2.
print $quota[0];
for (my $line = 2; $line != @quota; $line++) {
    print fmt_quota($quota[$line]);
}

I, the copyright holder of this work, hereby release the BAT file and the BASH script into the public domain. This applies worldwide. In case this is not legally possible, I grant any entity the right to use the BAT file and the BASH script work for any purpose, without any conditions, unless such conditions are required by law. The Perl script (quotacheck.pl) is released under the terms of the GNU General Public License version 2, or (at your option) any later version.

Comments No Comments »

One of the hardest parts of starting a new project is finding a catchy, easy to pronounce and easy to spell name. I’m writing a set of utilities for managing GPG on a LUKS partition that will do the following:

  • Create a LUKS partition and copy your GPG homedir to it
  • Provide a wrapper for gpg that will automatically mount the partition and then, if the user wishes, automatically call the unmounter in X minutes
  • The unmounter would unmount your gpg directory and copy your pubring to the mount target once the LUKS partition was unmounted. This permits you to do things which don’t require your private key without having to mount the encrypted partition
  • The LUKS partition could be on a USB flashdrive or LVM lv

I’ve been using a prototype I hacked together for the past few months… I would imagine it useful for those who have multiple laptops and desktops, all under their own control, but who don’t want to have copies of their private key spread out all over the place… therefore they just plug USB key in computer A, and when they need to go work on computer B, they just take their key with them… I would also imagine it useful for those among us who are paranoid and want to backup their key to an encrypted USB stick, etc.

Anyways, the most creative names I’ve come up with are:

  • gnuks-utils — (GNupg lUKS) pretty boring, but it reminds be of Canuck :)
  • GLutils — Gnupg Luks… could be confused as something to do with OpenGL … the name is already taken anyways.
  • gpg-luks-utils — Has the advantage that the end user automatically knows it has something to do with GnuPG and LUKS :)

Any ideas?

Comments 11 Comments »

The Kubuntu wiki has a flashy new theme! It isn’t yet default, but if you’d like to help test it out, head on over to your wiki preferences page and select the kubuntunew theme from the dropdown box.

If you encounter any bugs, please report them here.

Thanks to Matthew “mdke” East for providing the base for our theme and to the Canonical Sysadmins for installing it.

Comments No Comments »

Sorry, two posts in a row, but here’s my quote. A bit more than a sentence, but oh well.

“Remember kids,” he tells them sternly. “Don’t shoot each other. Aim at the fragile, expensive stuff.”

Mark Z. Danielewski’s House of Leaves

Meme HOWTO:

  1. Grab the nearest book.
  2. Open it to page 56.
  3. Find the fifth sentence.
  4. Post the text of the sentence in your journal along with these instructions.
  5. Don’t dig for your favorite book, the cool book, or the intellectual one: pick the CLOSEST.

Comments 2 Comments »

As webmaster, one should test their work in as many browsers as they can. As Kubuntu doesn’t have Firefox installed by default, I decided I probably should install it (Konqueror rocks by the way… :D ). However, when one goes to install firefox, here’s what happens:

ryan@iota> sudo aptitude install firefox ~
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
The following NEW packages will be installed:
apturl{a} docbook-xml{a} firefox firefox-3.0{a} firefox-3.0-branding{a} gksu{a} gnome-app-install{a} gnome-icon-theme{a} libcairo-perl{a} libgksu2-0{a} libglib-perl{a}
libgnome2-canvas-perl{a} libgnome2-perl{a} libgnome2-vfs-perl{a} libgtk2-perl{a} libgtkhtml2-0{a} libgtop2-7{a} libgtop2-common{a} liblaunchpad-integration1{a}
librsvg2-common{a} libscrollkeeper0{a} libvte-common{a} libvte9{a} python-cairo{a} python-gconf{a} python-glade2{a} python-gst0.10{a} python-gtk2{a} python-gtkhtml2{a}
python-launchpad-integration{a} python-numeric{a} python-pyorbit{a} python-sexy{a} python-vte{a} scrollkeeper{a} sgml-data{a} software-properties-gtk{a} synaptic{a}
ubufox{a} xulrunner-1.9{a}
0 packages upgraded, 40 newly installed, 0 to remove and 17 not upgraded.
Need to get 20.9MB of archives. After unpacking 87.8MB will be used.
Do you want to continue? [Y/n/?]

Notice, there’s a pile of GNOME cruft, namely synaptic, gksu, that we Kubuntu users don’t necessarily need nor want. Since aptitude does not have super cow powers, we can do the following:

sudo aptitude install firefox-3.0 ubufox= gksu=

Lets take a closer look at what is going on here. We are installing firefox-3.0, but we are asking aptitude not to install ubufox nor gksu and to keep it that way on any future upgrades. To learn more about aptitude’s install options, look at aptitude’s manpage, from line 38 onwards.

This command reduced what we had to install to

Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
The following NEW packages will be installed:
firefox-3.0 firefox-3.0-branding{a}
The following packages are RECOMMENDED but will NOT be installed:
ubufox
0 packages upgraded, 2 newly installed, 0 to remove and 17 not upgraded.
Need to get 0B/1086kB of archives. After unpacking 3854kB will be used.
Do you want to continue? [Y/n/?]

Much better, don’t you think? Two packages to install instead of 40, 1086kB vs 20.9MB to download and 3854kB vs 87.8MB unpacked.

Enjoy,
Ryan

Comments 9 Comments »

Hi Planet,
Due to numerous requests, we’re looking for screenshots of Kubuntu Intrepid to put on the Kubuntu website. If you have any snazzy screenshots that really show the power and sleekness of Kubuntu and KDE4, please upload them to this wiki page, or if you have an account on KDE-look, you can upload them there with “[Kubuntu Intrepid]” prefixing the title so that we can find them.

If you’ve customized the default desktop, please try to keep it minimal and include instructions on how you achieved these customizations so that new users don’t get frustrated trying to achieve them.

Thanks!

Comments No Comments »