GnuPG In 10 Minutes

Encrypted

If you need to secure communication or encrypt personal / sensitive data, GnuPG is the tool. Its free, and available for download from Gnu's Website or install from Debian repositories.

GnuPG is a free clone of PGP (PrettyGoodPrivacy), cryptographic software.

To find it on Debian, do:

aptitude search gnupg

To install:

aptitude install gnupg

To use GnuPG first, you generate your key:

gpg --gen-key

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection? 

Select # 1

RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 

Accept and press [ Enter ]

Please specify how long the key should be valid.
      0 = key does not expire
        = key expires in n days
      w = key expires in n weeks
      m = key expires in n months
      y = key expires in n years
Key is valid for? (0) 
Key does not expire at all
Is this correct? (y/N) 

Press Y

You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
    "Heinrich Heine (Der Dichter) "

Real name: [ Enter your name here ]
Email address: [ Enter your email address here ]
Comment: [ Enter a comment or leave blank ]
You selected this USER-ID:
    "Your Name "

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? 

[ Press 'O' to accept settings ]

You need a Passphrase to protect your secret key.

[ Type a memorable phrase. You will need it later. ]

GnuPG will generate and display your key. Something like:

pub   2048R/8E6D74A2 2010-12-31
uid                  Your Name
sub   2048R/AD17E388 2010-12-31

The first line displays my key: 8E6D74A2. 

First entry identifies my public key: pub. 
I used 2048 bits to generate the key: 2048R/
The date my key was created: 2010-12-31

You can see my key is 8E6D74A2.

To encrypt a file:

gpg --output myfile.gpg --encrypt --recipient myfile.txt

GnuPG creates an output file called myfile.gpg which is encrypted and is generated for recipient using myfile.txt as input file.

To decrypt a file:

gpg --output myfile --decrypt myfile.gpg

You will need to give your memorable passphrase to decrypt the file.

To generate your public key:

gpg --armor --export myemail@address > mypubkey

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.10 (GNU/Linux)

mQENBE0dNWMBCACZtfh/236A9Gul+e8LcQEgXLr/XWiDdhcEwK/i1m5Z9KVWVcYP
+ai79SGQQ+tQWCdqXX9DZsRvBW+Ftq4Iv2pnpDIdN8fsj7TgPHYo02vkPwoHghQZ
hpz/MtItHzJGZn6jqhqldp3zB/1K3IZ4d+rl/ER1PdmYvFcAfNqGVgALa56dO+0g
hshHYhke5fryVGFa9PReybkJHtqah8r8PXdR+G1MywN8SzTPdt3hohVAzirDWfsK
S6I3e/xiASbop5vaXekAFh4xWrFf8WG2197wF+arDAQO1BZFXWzCz7Vcretj1kCw
LsChl29kE62RPZRxeKqCdASQDdXHYYq3gn0BABEBAAG0KVBhdHJpY2sgV2Fsc2gg
PHBhdHJpY2t3YWxzaC5pc0BnbWFpbC5jb20+iQE4BBMBAgAiBQJNHTVjAhsDBgsJ
CAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRB4Lwybjm10ogHdB/4xhJslafp/4kvm
0lAtVYoW5zigawP7mwn5Zg+5nFXBNtEgEA7N+ty6L/SJjZirZemqWLaBrYqzGzrw
Srk4KMetoZBdOXAd8T509jI6viX3/wjAYyJukpO7JjHCJLSqQftXGU8AknCDsYIU
zRRD5TE2LZm7mwPDfdEaBcdeAjhV3sNpXa+n4IV1c+z4pq3R1UE5hl5D+DpzfB78
WjgGZ4sflEo8uuAigyPDlZRJfRO90e3Knr99tDLLcpVEEQ2Qq9dlxHSw4KrVRVzz
7IqrYKDZqdiZqjaMWfJtLz3OOXnTwQVk4HFWvxQGl8WDMcpAzaBFSAFwNTgxz91k
UxJscJvHuQENBE0dNWMBCACkSS12IQDZ/p5oDStrE2do4fwQt0J84DrqEfBPxlSt
Jhjv2nDOq4h7uRkoobRPjNtx8n6J+ddL01W9S9KHJpkMU0+O7pVZDEAAs2moDgIG
siu2A2If2ep4U36lXLzibKi/HgGCWHkVFLAXepKYhXlZLlRUBxeo5rGipgPIMKPV
dTaPy3ky+DTjU5ItIj3QFenw4bu0VwY6saEEtnmrancEjNpYGJURweDZnIF9UFTk
9ZlgnFKVBCRliMZ0QSrypcYaVc6Co8X1x4Xx+ls69f/8pxDW3sXpEgkBEIIO+F0+
1tVoarnz/tzcnPHG1sr4XltSA/KLlxsHf1vt/0XdRSHXABEBAAGJAR8EGAECAAkF
Ak0dNWMCGwwACgkQeC8Mm45tdKJtwAf+LbHF4AbHA0pBvSPqawl0YnFaKfj/wJIp
Tu3noYh/n7uSCswtBF9UvJrN5+rHmr/H7aEP47OOxphkQtUhaDT0pFiRhqXKt8YW
A9a+0ubHzQWfxOX+kQ/O9RdM9/hVNdjYMO9MsT6AjP/FHtsMU478bUf3Yd8rdcQI
kkg4T1OluqHTrvCZQn/yPwH08B/Que9NFZTTVtpOetkZXSprOUjIcGK60YI8ysGm
RnqkTASpFMNwTk2EyApIChfoUWn0lBO1JLIXqweTzTsVA2JkJm6hTQgq8wvRHpYH
0eE+IIJEnR/hSFvCwpCWtb2uzGwM5inXeDImc7r4t7lWz09c2VqWkQ===7WdN
-----END PGP PUBLIC KEY BLOCK----

GnuPG generates my public key. I can display the key on my website, or send it via email to people I know and trust who wish to send me secure messages or files. 

That covers some uses of GnuPG. Its worth reading the online GnuPG Handbook.

Another Sacking For Benitez

San Siro Exit

I read ex-Livepool manager Rafa Benitez has been acrimoniously sacked by Inter Milan, after only six months in the job. Apparently El-President is a little unhappy that Inter lie 7th in the league. Why is that so bad? The season's not over yet.

Last year Inter finished top in Italian Seria A under 'The Special One' Jose Mourinho. Inter also picked up the Coppa Italia and to round the season off, they won the Champions League Cup. Quite a feat. Beating the best Europe can throw at them. It was the first time they have done the 'Treble'. Whether you like Mourinho or not, he gets results.

Benitez inherited a treble winning team, and has slowly squandered the winning momentum and mentality to sink to a lowly 7th place. Add to the mix, Benitez belligerent abrasive style, and you can understand why the Inter board were pleased to dump him.

In a way, its a re-run of what happened at Liverpool. Benitez inherited a good squad. He spent close to £300 Million and left behind a collection of mediocre players, that deserve Liverpool's current position of 9th place in the Premier League.

I watched incredulously and horror last season when, week after week Benitez wrestled with indecision on formation and team selection. After an outstanding performance one week, Benitez would drop key players for the next. Players whose game sparkled with flair, improvisation, commitment and work rate. Next game they warm the bench.

Game after game Benitez would switch formation. Change winning team selection. Move Gerrard out left or wide on the right wing. He would split partnerships that worked well, built a quiet understanding of each others game and support play.

Benitez laboured with zonal marking year after year, when it was obvious it did not work. Any one with a modicum of intelligence could see it was Liverpool's achilles heal. They leaked goals every week. Liverpool conceded more goals from set pieces (corners, and free kicks), than open play.

The news emanating from Italy, suggests Inter have suffered a similar fate.

Some online news sites suggest Premiere League vacancies will open to Benitez. They must be crazy. Has this guy's track record not spoken loudly enough? At best, he is mediocre, other times poor.

One part of Benitez game has remained consistently high. The Blame Game. It was something he played well. Throughout his time at Liverpool he always looked to blame others for a poor performance. Always looking for scape goats.

He argued the case for total control on team matters, player purchase, player sales, the youth team, and more. When he finally got the controll he yearned for, Liverpool bombed. He guaranteed a top 4 finish for Liverpool last season, but could only manage 7th place and effectively sealed his fate. Benitez blamed it on the owners lack of funds. He left behind him a Liverpool team in a desperately poor state, from which they have not recovered.

I'm pleased he's gone. Looks like the Italians feel the same way.

Aplay: Device Or Resource Busy

In Use

Went to check the sound setup on a Debian box and the sound app would not play. I kept getting the following error message:

aplay: audio open error: Device or resource busy

To extract info on the application hogging the sound device, do:

lsof | grep snd

This displayed:

xmms2d  31732  patrick   7u    CHR  116,9  0t0  3885 /dev/snd/controlC0

I could see evidence of the app that was blocking access. I had nothing obvious running, so I killed the process.

killall xmms2d

Then checked again.

lsof | grep snd

Nothing. Its clear.

Done.

Chrome Flashplayer 64-Bit Plug-In

Get Working

At the end of November, Adobe Labs announced the long awaited release of 64-bit flashplayer plug-in for Linux. I checked around and there are numerous HowTo's providing guidance on installing the new, improved plug-in on a Linux System. Most are wrong.

Advice includes downloading the Flashplayer-plug-in tarball and adding it to /usr/lib/. Ignore the advice. If you run Google's Chrome browser, here's how to install the new 64-bit flashplayer plug-in. I run Debian Linux.

Check /etc/apt/sources.list. You should have contrib non-free added:

$ cat /etc/apt/souces.list

If not, as root add contrib non-free to your repository. Here's my sources.list:

deb http://ftp.uk.debian.org/debian/ squeeze main contrib non-free
deb-src http://ftp.uk.debian.org/debian/ squeeze main contrib non-free

Yours should look similar. I run squeeze. After you confirm your repository has non-free added, close and save the file. 

Type:

# aptitude update

Next run:

aptitude install flashplugin-nonfree

Debian will download and auto install the flashplayer plug-in. Close and restart Chrome.

Go to Youtube.com and check it works.

Mine worked first time.

Done!

Add Slime To Emacs

Viscous Liquid Matter

SLime. Superior Lisp Interactive Mode for Emacs. Slime is an Emacs mode for editing and working with Common LISP. Setting up Slime is a breeze. Download the CVS file, gunzip it, move the directory and add the directory path to your dot.emacs file.

Slime recommends pulling down the latest CVS version.

After download, gunzip the file:

tar zvxf slime-current.tgz

Delete the tar file and move the unzipped directory.

rm slime-current.tgz

mv slime-2010-12-23 ~/prog/slime

Open dot.emacs file and add the following:

emacs ~/.emacs

(add-to-list 'load-path "~/prog/slime" ) ; slime directory
(require 'slime)
(slime-setup)

Close, restart Emacs, then start Slime mode:

M-x slime

You'll have the CLISP prompt:

CL-USER> 

Have a read of the Slime Online Manual. Its worth a look.

Done!

Gnu Screen

Multi Display

Gnu Screen is a faily low key application that is quite awesome in usage. Its functionality is grossly underrated, for such a powerful utility.

Taken from User Manual:

Screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells. There is a scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows the user to move text regions between windows.

When screen is called, it creates a single window with a shell in it and then gets out of your way so that you can use the program as you normally would. Then, at any time, you can create new full-screen windows with other programs in them including more shells, kill the current window, view a list of the active windows, turn output logging on and off, copy text between windows, view the scrollback history, switch between windows, etc. All windows run their programs completely independent of each other. Programs continue to run when their window is currently not visible and even when the whole screen session is detached from the user's terminal.

When a program terminates, screen kills the window that contained it. If this window was in the foreground, the display switches to the previously displayed window; if none are left, screen exits.

If you have used Emacs, its very similar in user interaction, though functionality is very different.

Here are a few commands to get you going. You can find the rest and plenty of info at Gnu Screen Documents.

Start screen in an XTerm:

xterm screen

Auto start screen with XTerm:

xterm -e screen

Kill screen:

C-a C-\

Create a new window:

C-a C-c

Kill current window:

C-a C-k

Switch to next window:

C-a C-n

Switch to previous window:

C-a C-p

Toggle between windows:

C-a C-a

Name a window:

C-a A

Display screen list:

C-a C-w

Display interactive screen list:

C-a C-"

Clear the screen of text:

C-a C

That's all for now.

Microsoft Loves Linux

MS Linux

Out of curiosity, I wandered over to Netcraft.com and ran a check on what servers Microsoft runs for its Hotmail.com mail service. I queried Netcraft's database and ran a What's That Site Running? search. If you have never used it, give it a shot it turns up interesting results at times.

Anyhow, it seems Microsoft loves Linux so much, 18 of its 24 Hotmail servers run flavours of Linux OS. Only 6 of the 24 use Microsoft's own Windows Server 2003. Either MS can't afford the licence fees (they are very expensive) or Server 2003 can't handle the workload.

Microsoft's previous server offering, NT was prone to going zombie and a re-boot was the only way to bring it back to life.

Here's a capture a screen capture of the web page.



Would Ford Motor Company use GM vehicles for its operations?

It must be Linux love.

Ext4 File System

No More fsck

Recently did a clean install of Debian on a box and went with Ext4 file system on '/'. I read a while back that Fedora was shipping with Ext4 as default. Ubuntu being more conservative, stayed with Ext3.

I've had a few bad experiences in the past with exotic and novel technologies, I now take a more cautious path. Sometimes.

When I read Google was upgrading to Ext4, and hired the guy who played a main role in the development of Ext4, that was enough to persuade me. If it was good enough for big 'G', it was good enough for me.

One immediate benefit of Ext4; no more fsck. Those times when you reboot your machine and get the message:

/dev/sda1 been mounted 28 times without being checked, check forced.

Sit around twiddling your thumbs while fsck goes to work.

Ext4 is reputed to be faster than Ext3. Read the paragraph on the bitmap allocator.

In the meantime, check out the Ext4 Wiki page, which is packed with useful and meaningful info on the topic.

Done!

GRUB Multi Disk Multi Boot HowTo

Boot It

Recently installed Debian Linux on a new disk drive. I  still had my old drive with all my settings, data, files and so on. I want access to the old drive partitions while I worked on the new larger disk.

I could mount the old drive and access files from the mount, but I still wanted access to some applications and settings on the old disk. The easiest way to do this, was to Multi Boot from GRUB. I want the option to boot the old drive or the new.

If I need file access, I can do a temporary mount. The multi-boot set up allows me to work on the new disk at my leisure, till I'm ready to transfer files and wipe the old disk.

There's a lot of info on GRUB Multi Boot and a lot of HowTo's kicking around. Most are out of date. Many are misleading. Some refer to editing menu.lst or editing grub.conf. Both files no longer exist in GRUB. They have been replaced by grub.cfg, which is not to be manually edited. It states in grub.cfg.

Here's an excerpt:

$ cat /boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

After installing Debian Linux on a new disk, including GRUB, here's the method for advising GRUB of your other disk and OS:

1. Shut down your system
2. Disconnect power from machine
3. Attach old disk
4. Connect power to your box
5. Boot system
6. Press del key to enter BIOS set up
7. Go to Boot section > Boot order
8. Ensure new disk is select as first boot device
9. Check old disk is recognized.
10. Save settings and exit
11. System reboots into your new disk
12. Fire up XTerm or other Terminal emulator
13. Become root user
14. dmesg | grep sd 

This will display all your disks. 
Your first boot device will be sda1 (your new disk).
Your old disk will be sdb1. This is for SATA disks. 
IDEs disks will be labelled hda1 and hdb1.

15. Run the update grub command and pass your old disk as argument

# update-grub /dev/sdb1

Grub will run off and do its thing

16. Reboot system

On system reboot, you should see your old disk lower down the menu boot. Select it and hit enter to boot off your old disk.

That's about it.

P.S. If you want to boot your new disk and need access to your files, you can do a temporary mount of your old disk. To create a mount point and mount your old disk, become root and do:

# mkdir /mnt/olddisk
# mount -t ext3 /dev/sdb1 /mnt/olddisk

If your not running ext3 on the old disk, replace with ext2 or fat, or whatever is there. If you run XP on the old disk it will have NTFS file system. You will need ntfs-3g utils to access NTFS files.

Do aptitude search ntfs for options and aptitude show for more info.

Done!

Identify Linux Hardware

What Is It?

Trying to identify the hardware in your box, when you run Linux, can be a wasted effort. Sure there are a few utils to identify some parts of your hardware setup, but its not comprehensive.

Apart from opening the case up and eye balling, how do you find out what you got under the 'hood?

lshw to the rescue. Its not installed as part of the Debian core, but it is available for download from Debian repositories.

You know the routine:

# aptitude install lshw

Once installed, run lshw as root user, to get a complete listing of your hardware setup.

The listing is comprehensive. I got 459 lines output when I ran it on my primary box. So I suggest piping it to a file where you can peruse it at your leisure, or just grep the hell out of it.

# lshw > hardware.list

That's about it.

*     *     *

StumpWM MPlayer Crash

Wreckage

I have been running StumpWM the keyboard oriented Window Manager for the last few days. It takes a little getting used to, but not much if you have used Emacs. It is very similar in usage to Emacs and Screen.

I like the concept and execution. Though as a finished product, some things are left for you to sort out. There are many key bindings left undone and  documentation is not extensive. You have to roll your sleeves up and set the bindings yourself in .stumpwmrc config file.

MPlayer crashes if you play a movie. I googled and discovered this was down to the way MPlayer defaults aspect ratio which, if not defined, results in a divide by zero error in CLISP.

I guess if you bypass default and pass an aspect ratio to MPlayer, that should get around the problem. I haven't tried this since stumpwm crashed last night I fired up and used XFCE4. I will try later and post an update.

To pass MPlayer an aspect ratio, do:

mplayer -aspect 2.4:1 nameofmovie.mpg

Here's the page I found describing the error.

MPlayer refuses to run under StumpWM

It looks like the developers are on the case and a fix may appear soon.

Done!

SSH Login No Password

Logos

To enable ssh login to other hosts on your network is pretty simple to set up. Generate a public key using ssh-keygen and copy the key to the hosts you want to access without a password. It that simple.

Here's how to do it:

1. Generate a public/private rsa key pair

ssh-keygen -t rsa

2. Give file location to save key. Accept default.

Press [enter]

3. Enter password for the key
Press [enter]

4. Enter same password:
Press [enter]

Your identification has been saved in /home/patrick/.ssh/id_rsa
Your public key has been saved in /home/patrick/.ssh/id_rsa.pub.

5. Copy your public key.

Caution. Make sure you copy the right key. When ssh-keygen runs, it creates two keys: id_rsa.pub and id_rsa.

Id_rsa.pub is the public key. The one you share. The second key, id_rsa (no .pub extension) is your private key. If you copy the wrong key to the remote host, connection without password will not work.

cp ~/.ssh/id_rsa.pub

6. Copy public key to hosts on your network.

cat id_rsa.pub >> ~/.ssh/authorized_keys

7. Add your public key after any existing entries in authorized. Don't overwrite any.

8. Test it by logging in to one of the hosts on the network

ssh host

You're in with no password. If not, you carried out one of the steps wrong. Go back and check the id_rsa.pub matches the copy. Check the file is in the correct location: ~/.ssh. Check the file is correctly named: authorized_keys.

Added Bonus

Aside from being able to log in with no password, you can also copy files without needing to authenticate yourself.

*    *    *

Disable Root Login

More Secure

If you wanted to break into a system, one of the first ways to try is to find an account on the system. You could spend time guessing at users on the system or go for the one user on every Linux/Unix system. Root.

You know root exists on every system. It has to. All you need now is the password and your in. You're half way there.

To increase security, its best to disable root log in. Here's how.

As root open /etc/ssh/sshd_config and find the line PermitRootLogin.

emacs /etc/ssh/sshd_config
PermitRootLogin yes

Change 'yes' at the end of line to 'no', so it looks like this:

PermitRootLogin no

If the line has a hash mark '#' at start of line. Delete the '#' hash mark.

Save the file. Exit and restart sshd daemon.

/etc/init.d/ssh restart

Test it by trying to log in as root user. Log in should fail.

Done!

Using SSH And SCP

Secure

SSH and SCP command line tools are very similar in usage. Both utilise a secure connection. Data is encrypted to ensure secure transit. Passwords and other sensitive data is safe.

Using SSH

You must have a user account and password on the remote host or connection will fail. The remote host must be running ssh server. You can check for sshd using ps and grep.

ps -e | grep sshd
1493 ?        00:00:00 sshd

Another consideration is a firewall that blocks connections to port 22. If you cannot connect to the remote host, check firewall settings.

To log into a remote host using ssh, do:

ssh remotehost
myname@remotehost password:

Enter the password for the account on the remote host to gain access.

Using SCP

Using scp is similar to using ssh, in how you log in to the remote host. Once your in, the similarity ends.

To copy files from a remote host into the current directory do:

scp myname@remotehost:/filetocopy .

Notice the colon after the host name. Its important. Followed by the path to the file you want to copy. Finally at the end the dot '.' or period. That tells Linux to place the copied file in this directory. The dot is short hand for 'the current directory'.

Copying files from my box to a remote host is pretty much the same command, rehashed.

scp filetocopy myname@remotehost:/directory/to/copy/to

Give it a shot. See how ya go.

That's about it.

Done!

X Windows Lock Up

Kill It

Occasionally I've had X Windows lock up solid that no keyboard or mouse input has any effect.
So what do ya do, when X is totally unresponsive? How do ya free your machine?

You have a few options.

Remote ssh Login

If you have ssh installed and have access to another Linux box, you can remote login and kill X. When you ssh into yourbox, it will ask for your password. After entering correct password, do a ps -e| grep X to find Xorg process and kill the process id or run killall Xorg.

ssh yourbox
you@yourbox's password: 

ps -e |grep X
6408 tty8     00:08:42 Xorg

killall Xorg

That should do it.

Use Magic SysRq Key

You can use Magic SysRq Key to do a System Request and pass keyboard control to the console. Then switch to console and kill X from there. The SysRq key is sometimes marked PrntScn. You have to  press

Alt+PrntScn+r

This should allow you to switch to the console by pressing

Ctrl+Alt+F1

Once on the console, kill the X Server

killall Xorg

Warm Reboot

If that fails, you have to do a warm reboot then fsck. If you have a current distro and ext3 or equivalent filesystem, you should be okay. Press the reset button and wait for the system to reboot.

Check your X log under /var/log/Xorg.0.log to see what caused the lock up.

# less /var/log/Xorg.0.log

Done!

Emacs Web Jump

From Here To There

Use Emacs. Can't be bothered to fumble the mouse, launch a browser, enter URL and maybe a search term? Then try Web Jump. Its part of Emacs and works like this:

M-x webjump
WebJump to site: google
Google query: Linux

Emacs fires up Firefox, Google and passes your query to Google ready to for your enjoyment.

You may find it useful.

Done!

StumpWM Install

The Right Way

Installed StumpWM last week and have been running it as my Window Manager for a few days. I like it. It's very different to many mainstream Window Managers or Desktop Environments.

StumpWM is keyboard centric. Usable without a mouse. In fact that was the primary design principle. Once StumpWM is running, there is nothing to click. No icons. No buttons. Nothing for the mouse to do.

Documentation is not extensive, and it takes some getting used to keyboard only usage. Once you start to get the feel, its great.

I hit a problem using StumpWm. Sometimes it hangs. Kill Xorg and log back in is the only solution.

StumpWM requires you to install LISP before you install Stump. I installed CLISP - an ANSI Common Lisp Implementation from Gnu.org. After the recurring hangs, I searched for a fix and found this:
Multi-threading is available in SBCL, though not in CLISP. Running Swank (or any other command that doesn’t fork or exit) on a single-threaded StumpWM will hang StumpWM. You’ll be able to move the mouse, but the prefix key won’t react anymore. You’ll have to Ctrl+Alt+Backspace to start a new session.
And there's the rub...

I uninstall CLISP and StumpWM and start afresh.

I'm running Debian. Here' s how I did it:

1. Install SBCL

# aptitude install sbcl

2. Install CL-CLX-SBCL. An X11 Common Lisp client library for SBCL

# aptitude install cl-clx-sbcl

3. Install CL-PPCRE. Portable Regular Express Library for Common Lisp 

# aptitude install cl-ppcre

4. Install StumpWM. Common Lisp window manager

# aptitude install stumpwm

Check StumpWM is in the path

# ls /usr/bin/stumpwm
/usr/bin/stumpwm

On Debian the default install is under /usr/bin/stumpwm. I have seen references to /usr/local/bin/stumwm on some systems. Check the location to ensure its correct.

Ensure X launches StumpWM by adding a line to .xinitrc

$ echo "exec stumpwm >> ~.xinitrc

Create symlink from .~/xsession to ~/.xinitrc

$ ln -s /home/myname/.xinitrc /home/myname/.xsession

Kill and restart Xorg.

I kept my other Window Manager  in case there were further problems to resolve.

You can add StumpWM as an entry to GDM sessions menu using Emacs or another editor

emacs /usr/share/xsessions/stumpwm.desktop

[Desktop Entry]
Encoding=UTF-8
Name=StumpWM
Comment=Tiling Window Manager
Exec=/usr/bin/stumpwm
Icon=
Type=Application

Save file. Restart X server.

Normally hit Ctrl-Alt-Del to kill and restart X server. If that fails, as root user, open XTerm and do:

# ps -e | grep X
6408 tty8     00:06:43 Xorg

# killall Xorg 

X server will die and restart.

Done!

Debian Aptitude Too Big

Getting Fat

Using aptitude since last clean install, I recently observed how big /var had grown. Starting around 100 Megabytes, it now stood at a whopping 2.5 Gigabytes. I suspected it was caused by aptitude's cache archive. Running du -sh /var confirmed it.

Deb files are stored in /var/cache/apt/archives. Aptitude's cache was now 2.3 Gigabytes in size. Time to trim.

I ran aptitude autoclean:

# aptitude autoclean

It took around 1 minute and reduced the cache by 1.4 Gigabytes. Still too much. I ran aptitude clean:

# aptitude clean

This purges pretty much everything. Check again and it was down to a manageable 263 Megabytes. Okay.

Keep an eye on aptitude. Its a disk space hog.

Done!

Linux Firewall

Protection

If your looking for a free firewall (free as in liberty and in beer), then go check out Firestarter.

Its an Open Source easy to use firewall with GUI setup and admin.

Its simple to use and has many options. It even has Internet Connection Sharing similar to Windows XP.

If you don't feel comfortable reworking those IPTables rules, go download and install Firestarter.

Its great for laptops, desktops or servers.

Done!

Fujitsu Amilo Laptop

Portable

I bought a Fujitsu Amilo budget notebook for occasional use when away from home. Overall the laptop is pretty good, my only complaint is that battery life is dismal. You get around one hour usage, before it shuts down. Stay close to a power outlet at all times.

It came with Vista Home Edition installed. That was buggy and slow. But that was gone a short while later. Grabbed the Debian Net Install Disk, and completed a laptop install. Now it purrs along.

Its a nice notebook, with decent graphics, a large disk, and plenty of RAM. Three USB ports, inbuilt card reader, wireless and lan connections.

Aside from the poor battery performance, I'm pleased with the machine.

Here's the full specification:

Fujitsu-Siemens Amilo Pi 2515 Notebook specifications

Processor
Intel Core 2 Duo T7100 1.8 GHz

Mainboard
Intel GM965

Memory
2048 MB, DDR2 PC5300 667MHz. 2x1024MB

Graphics adapter
Intel Graphics Media Accelerator (GMA) X3100, up to 384MB video RAM

Display
15.4 inch 16:10, 1280x800 pixel, WXGA BrightView, TFT

Harddisk
160 GB - 5400 rpm, WD Scorpio WD1600BEVS

Soundcard
Motorola Si3054

Connections
1 Express Card 54mm, 3 USB 2.0, 1 VGA, 56k V.92 Modem

Audio Connections
Microphone, Earphones,

Card Reader
4in1 Cardreader

Networking
Realtek RTL8101 (10/100MBit),
Intel PRO/Wireless 3945ABG 802.11 a/b/g

Optical drive
Optiarc DVD RW AD-7540A
8x (DVD-R/+R/+R DL/-RW/+RW/-ROM)

Size
length x width x height (mm): 355 x 255 x 40

Weight: 2.71 kg
Power Supply: 0.3 kg

Battery
44.4 Wh Lithium-Ion, 11.1V 4000mAh

MPlayer Audio Track

Identify And Select

Using MPlayer on the command line, sometimes a movie defaults to, and plays the wrong audio track. How do you identify the correct track? How do you select the correct audio track?

First check the audio tracks available on your movie. This one is in matroska (mkv) format.

$ mplayer -identify greatmovie.mkv
[matroska,webm @ 0x374eae0] max_analyze_duration reached
[matroska,webm @ 0x374eae0] Estimating duration from bitrate, this may be inaccurate
ID_VIDEO_ID=0
ID_AUDIO_ID=0
ID_AID_0_LANG=eng <-- Here's the audio we want!
ID_AID_0_NAME=English
ID_AUDIO_ID=1
ID_AID_1_LANG=eng
ID_AID_1_NAME=Commentary actor, director
ID_SUBTITLE_ID=0
ID_SID_0_LANG=eng
ID_SID_0_NAME=English
ID_SUBTITLE_ID=1
ID_SID_1_LANG=eng
ID_SID_1_NAME=English (SDH)
ID_SUBTITLE_ID=2
ID_SID_2_LANG=fre
ID_SID_2_NAME=French
ID_SUBTITLE_ID=3
ID_SID_3_LANG=spa
ID_SID_3_NAME=Spanish
ID_CLIP_INFO_NAME0=title
ID_CLIP_INFO_VALUE0=gr
ID_CLIP_INFO_N=1
ID_FILENAME=greatmovie.mkv
ID_DEMUXER=lavfpref
ID_VIDEO_FORMAT=H264
ID_VIDEO_BITRATE=0
ID_VIDEO_WIDTH=1280
ID_VIDEO_HEIGHT=528
ID_VIDEO_FPS=23.976
ID_VIDEO_ASPECT=2.4242
ID_AUDIO_FORMAT=22127
ID_AUDIO_BITRATE=0
ID_AUDIO_RATE=48000
ID_AUDIO_NCH=2
ID_START_TIME=0.00
ID_LENGTH=6162.19
ID_SEEKABLE=1
ID_CHAPTERS=0
ID_VIDEO_CODEC=ffh264
ID_AUDIO_BITRATE=0
ID_AUDIO_RATE=48000
ID_AUDIO_NCH=2
ID_AUDIO_CODEC=ffvorbis
ID_VIDEO_ASPECT=2.4242 <-- Here's the aspect ratio!
ID_PAUSED
ID_EXIT=QUIT

Now we have the audio track details, we can pass that value to MPlayer when we start the movie:

mplayer -aspect 2.42:1 -aid 0 greatmovie.mkv

MPlayer will now play the audio track we want.

Done!

Using Linux Find

Searching...

Linux find utility is a great tool for digging out files buried in the vast depths of your disk platters. Not quite as good as  Google, but a lot smaller and already built into your Linux OS.

If you have an inkling of your file details, find can locate it. I misplaced some files a couple of months ago. I knew I had worked on them on another machine and was pretty sure, a copy resided on my disk, somewhere.

I found a date reference to the files. It was all I needed. find did the rest.

I knew I had last worked on the files on 19 July. I calculated the number of days, using fingers and toes, and passed the number to 'find'.

It was 137 days since I last modified or accessed the file. Here's the find command.

find . -mtime 137 -print

Explanation:

find - the find command
'.'  - start search in the current directory
-mtime - look at files last modified
137 - days ago
-print - print out results

Minutes later, I had my files.

You can search for files by name, using -name instead of -mtime.

Add wildcards:

find . -name *.gif

Searches for all gif files in current directory and sub-directories.

Done!

DVD VOB To AVI

Convert DVD VOB Video Files To AVI Format

A friend has some home videos as DVD. He wants to convert the DVD files to AVI so he can edit them with a movie editor.

This is how to do it.

N.B. This is for DVD home movies which are NOT encrypted. This will not work for DVD Videos such as those produced by the Hollywood studios. The movie industry has worked to prevent back up copies of DVDs by encrypting content.

This is for the Windows platform. You can achieve the same using Debian/Linux. I'll leave that for another day.

Download and install the following software:

DVDFab HD Decrypter

Avidemux Video Editor

DVDFab

Fireup DVDFab HD Decrypter. Place your DVD video disc in the drive. When it spins up, DVDFab should detect it and start to scan the disc. DVDFab will ask you to specify the region code. Western Europe for us.


The DVD video will be identified in the field at top marked 'Source'. Click field underneath marked 'Target' and select a drive and a folder / directory to output the ripped DVD data. Make a note of the directory/folder the ripped data is in. You will need to know that a little later.

Click start. Go grab a coffee or watch wrestling. When its finished close DVDFab. Its done its work for today.

Avidemux

Fire up Avidemux. We want to convert the file to AVI.

Left hand panel. Click drop down arrow button under Video. Select MPEG-4 ASP (Xvid)
Left hand panel. Click drop down arrow button under Audio. Select MP3 (lame)
Left hand panel. Click drop down arrow button under Format. Select AVI

Click folder on toolbar go to the location where DVDFab put the ripped files. You do remember the folder location, dont you?

Click it and open the folder makred VIDEO_TS.

Ignore .BUP, .IFO, .idx files.

Select the first VOB file. Should be something like VTS_01_0.VOB. Click 'Open'

Avidemux confirms its opened the file.

Back at main screen, click Save. Second button from left on toolbar. Image of floppy disk.

Give the file a name, including '.avi. extionsion. Avidemux will not add the extension for you.

Avidemux starts conversion.

Go grab a coffee or watch some more wrestling. This could take a couple of hours.

For large files, run it over night.

Done!

ASCII Codes

ASCII Character Set

The ASCII character set defines 128 characters.
0 to 127 dec. 0 to FF hex. 0 to 177 oct.

ASCII is an acronym for American Standard Code for Information Interchange.

The standard set consists of 128 decimal numbers from zero to 127. These are  assigned to letters, numbers, punctuation marks, and special characters.

Control Characters

The first 32 values are non-printing control characters, such as Return and Line feed. Generated by pressing Control and another key. Bell is value 7, Control plus G, shown as ^G.

Notice that Bell decimal value is 7. G decimal value is 71. The Control key subtracts 64 from the value of the key it modifies. So Bell is 64 less than the value of G.

ie 71 - 64 = 7

Here's a jpg with 128 ASCII codes, 0 to 127.


Done!

GStreamer unable to detect any sound devices

No Sound

GStreamer was unable to detect any sound devices. Some sound system specific GStreamer packages may be missing. It may also be a permissions problem.

The error messageI was getting. I installed a few things for testing. Something broke. I googled for a solution without luck.

XFCE4 mixer was greyed out. I couldn't use it. I could use AlsaMixer. I could get sound using MPlayer. I could get sound using Audacious.

I tried to remove gstreamer using aptitude without luck. As root I deleted gstreamer files and directories:

rm -rf /usr/lib/gstreamer-0.10 

I tried aptitude again:

aptitude remove gstreamer0.10-alsa

This time it worked. I got:

root# aptitude remove gstreamer0.10-alsa
The following packages will be REMOVED:  
  gstreamer0.10-alsa 
0 packages upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 578 kB will be freed.
(Reading database ... 91754 files and directories currently installed.)
Removing gstreamer0.10-alsa ...

I purged gstreamer0.10-alsa and installed it again. It worked. This time audacious didn't complain when I fired it up. XFCE4 mixer was stilled grayed out. I removed it from XFCE4 panel and added a new XFCE4 mixer.

Done!

Mount ISO Files

Loop De Loop

Someone recently asked me about reading ISO files and how to go about it. In Debian or any flavour of Linux it's easy.

The command is in three parts.

1. The mount command.
2. The location of the ISO file.
3. The location of the mount point.

ISO file is called homevideo.iso. Locate the ISO image in your home directory. Create a directory to mount it.

mkdir isomnt

We mount the ISO in our home directory mount point:

mount -o loop /home/myname/homevideo.iso /home/myname/isomnt

You can cd into /home/myname/isomnt to check the contents.

When your done you need to unmount the ISO file. Do:

umount /home/myname/isomnt

That's about it.

Done!

XFCE4 Xmodmap Problem

Broken

Running X commands in XFCE4 at start up works, in theory. In practice, not. I had this problem for a while and searched for a solution, without success. Today I was reading through documents on XFCE website and found this entry.
Is it possible to use Media keys in the Shortcut Editor?
Use xmodmap to assign keycodes to your Media keys to make them available for the Xfce shortcut editor:
To determine keycodes of the multimedia keys use the program xev. Create a .Xmodmap file in your $HOME directory containing those keycodes and assign keysyms to them. All possible keysyms can be found in /usr/lib/X11/XKeysymDB or /usr/share/X11/XKeysymDB. 
To ensure that the .Xmodmap file is loaded when you start Xfce add /usr/bin/xmodmap $HOME/.Xmodmap to your .xinitrc or .xprofile file. When you start the shortcut editor the assigned keysyms should show up when you press one of your multimedia keys. Now it is possible to assign a command to them. 
Note: Several problems with auto-loading of .Xmodmap files at xfce startup have been reported (also when issued as autostart command). Search the xfce bugzilla sites for current problems. As a workaround, run xmodmap ~/.Xmodmap by hand every time, or try out editing the somewhat less straightforward xkb configuration files.
There you have it.

Done!

Web Cam Setup In Debian

Moving Pictures

I set up a Web cam running Debian Squeeze in around 10 minutes. The Web Cam itself was an 'el cheapo' model made by Microsoft.

Its a LifeCam VX-1000 color Web Cam with 640x480 resolution for video and still images. It has a built-in microphone and a USB type A connector. More importantly, its supported in Debian Linux.

I plugged the camera in and ran 'lsusb'.

lsusb
Bus 003 Device 004: ID 045e:00f7 Microsoft Corp. LifeCam VX-1000

The device was recognized immediately. Great. I'm running Debian 2.6.32 kernal, I guess the device driver is already in the kernel.

I installed an app to see the Web Cam in action. I pulled down Camorama. Its a simple application with limited abilities, but it will do fine for testing.

aptitude install camorama

Two minutes later, it was installed. I fired up the program and had Web Cam images onscreen. Camorama can capture stills or display images as they happen. It has no streaming capabilities.

I installed Cheese from the Debian repository:

aptitude install cheese

On completion, I fired it up and could capture still images or record video. Its slightly more versatile than Camorama.

I also got the Web Cam to display images in mplayer. I did:

mplayer -fps 30 tv://

I googled but results were thin on the ground for what I wanted. I read briefly you can use Mencoder to save the stream to disk or similar. I guess I will have to dive into the MPlayer / Mencoder documents to find what I need.

I will look into that over the next couple of weeks, and post on results.

Anyhow, its a positive start. It works.

Done!

Disable Annoying TouchPad In XFCE4

Veritable Irritant No More

If you have a laptop running Debian Linux or another Linux flavour, touchpad tapping is enabled by default.

This causes the cursor to hop around if your typing or if your hand touches / brushes the touchpad.

Its annoying and time consuming, to go back and correct typing errors caused this way.

If you run GNOME or KDE desktops its easily fixed. If you run XFCE4 the method is not so obvious. There are no settings to disable this activity.

Disable the mouse touchpad on the command line with the following:

syndaemon -d

This causes syndaemon to delay response before activating again after a key press.

Done!

Memory In Linux

Recall

To check memory usage in Linux do:

cat /proc/meminfo

You'll get a long listing of all memory usage.

Use free to show memory usage in megabytes:

free -m

You can use -k for kilobytes or -G for gigabytes.

There is vmstat too:

vmstat 2 5

vmstat displays output every 2 seconds 5 times.

Done!

DVD Backup Revisited

Burn Some More

After digging a little further, I unearthed a couple of other DVD Backup apps, to secure your important data.

K9Copy is a small utility which allows DVD backup on Linux. The DVD video stream is compressed by the program Vamps. Options include:

Copy without menus :
DVDAuthor creates a new structure for the DVD. It is possible to arbitrarily set the order of the videos.

Copy with menus :
As dvdauthor can't copy the original menus, K9Copy recreates the original DVD structure. The menus as well as IFO files are modified to point to the compressed MPEG2 stream.

K9Copy features include:
The video stream is compressed to make the video fiton a 4.7GB recordable DVD
DVD Burning
Creation of ISO images
Choosing which audio and subtitle tracks are copied.
Title preview (video only)
The ability to preserve the original menus.

Prerequisites
DVDAuthor
libdvdread
growisofs
mencoder
mplayer
libhal
libdbus
libdbus-qt


OGMRip a Gnome centric app which looks useful. OGMRip is an application and a set of libraries for ripping and encoding DVD into AVI, OGM, MP4, or Matroska files using a wide variety of codecs. It relies on mplayer, mencoder, ogmtools, mkvtoolnix, mp4box, oggenc, lame, and faac to perform its tasks.

The GUI features a clean GNOME 2 interface and tries to minimize esoteric settings for the end user. A CLI client is also available, it's called shRip.

Done!

F4V Files

What Are They?

The F4V file format is an FLV MPEG-4 file Flash video file, that's been renamed to F4V. (Given .F4V extension).

The F4V format and the FLV format, are MPEG-4 video formats defined by Adobe. F4V files are containers for H.264 and MP3.

Before you can open or play an F4V format file, you must have the appropriate codecs installed. The video compression used is H.264. Audio compression is AAC or MP3.

If your media player can't open or play the file, you can download the necessary codecs to enable your media player.

Other choices are to look at VLC, the VideoLan Client, or check out mPlayer for your platform. On the windows platform, media player classic is available.

All have the necessary codecs to play F4V files.

Done!