Tuesday, August 26, 2008

Extracting contents of .deb packages

Commands to decompress .deb files :
mkdir /tmp/foo
cd /tmp/foo
ar vx /home/user/foo.deb

tar vxf data.tar.gz
Contents will be extracted in the current directory. Use the binaries and/or configuration files at your disposal.

Sunday, August 17, 2008

A simple IRC Logger-bot in Bash

The script :

## Bot.sh - begin
#!/bin/bash
config=/tmp/ircbot

echo NICK ircbot > $config
echo USER username +iw ircbot :$0 >> $config
echo JOIN #orkut_linux >> $config

tail -f $config | telnet irc.freenode.net 6667 | while true
do read MESSAGE || break
echo $MESSAGE >> irclog.txt
done

rm $config
## EOF

Make Bot.sh executable:

chmod +x Bot.sh

Now all that's left is to run it.
Enjoy!

Saturday, August 16, 2008

ACPI Suspend/Resume

Suspend to RAM or Suspend to disk on GNU/Linux with an ACPI enabled kernel:

First, we find out what sleep state the system supports by running
echo /sys/power/state
And we finally put the system to sleep by doing (as root) :
echo -n "X" > /sys/power/state
Where X is one of the sleep states obtained from the before mentioned command.
mem / standby - Suspend to RAM (standby)
disk - Suspend to Disk (hibernate)

Example : ( '#' prompt denotes that i'm root already)
# cat /sys/power/state
# mem standby disk
# echo -n disk > /sys/power/state # for suspend to disk (a.k.a 'hibernate')

NOTE : For suspend to disk to work correctly, pass the resume kernel parameter at boot.
kernel /vmlinuz-2.6.25-custom root=/dev/hda1 ro resume=/dev/hda4
Keep in mind that this resume partition must be a valid swap partition.