Discovering Python's Great World!
.tar.gz - archiving and extracting files

Archiving :

tar czf /path/to/output/folder/filename.tar.gz /path/to/folder

Extracting :

tar xzvf /path/to/output/folder/filename.tar.gz /path/to/folder

Script to install a chrooted Bind on Debian

Script tested on Debian Squeeze

#!/bin/bash
# Author: Omar AKHAM (akham.omar@gmail.com) 2012
## Install a chrooted Bind9 on Debian (Squeeze tested) script
## Source : http://wiki.debian.org/Bind9#Bind_Chroot

#install bind9
apt-get install bind9 bind9utils &&

#Stop bind service
/etc/init.d/bind9 stop

#Switch Bind9 to use the chroot
sed -i 's/OPTIONS="-u bind"/OPTIONS="-u bind -t \/var\/bind9\/chroot"/g' /etc/default/bind9

#Create chroot
mkdir -p /var/bind9/chroot/{etc,dev,var/cache/bind,var/run/bind/run}
chown -R bind:bind /var/bind9/chroot/var/*
mknod /var/bind9/chroot/dev/null c 1 3
mknod /var/bind9/chroot/dev/random c 1 8
chmod 660 /var/bind9/chroot/dev/{null,random}

#Move config file to chroot
mv /etc/bind /var/bind9/chroot/etc
ln -s /var/bind9/chroot/etc/bind /etc/bind

chown -R bind:bind /etc/bind/*

#Set correct PIDFILE
sed -i 's/PIDFILE=\/var\/run\/named\/named.pid/PIDFILE=\/var\/bind9\/chroot\/var\/run\/named\/named.pid/g' /etc/init.d/bind9

#Tell rsyslog to listen to the bind logs in the correct place
echo "\$AddUnixListenSocket /var/bind9/chroot/dev/log" > /etc/rsyslog.d/bind-chroot.conf

#Start services
/etc/init.d/rsyslog restart;
/etc/init.d/bind9 start

Get packages and dependencies for installing offline

Apt based distribution :

apt-get --print-uris --yes install __PACKAGE__ | grep ^\' | cut -d\' -f2 >downloads.list
Disable Debian Banner Suffix on SSH Server

From man sshd_config:

DebianBanner
         Specifies whether the distribution-specified extra version suffix
         is included during initial protocol handshake.  The default is
         “yes”.

  • Edit ssh config file :

sudo nano /etc/ssh/sshd_config

  • Enter the following line :

DebianBanner no

  • Restart ssh

invoke-rc.d ssh restart

SVN : reverse-merge a revision

svn merge -c -REVISION_TO_REVERSE

ex: reverse merging r122

svn merge -c -122

Set default editor for crontab command

export VISUAL=’__your_favourite_editor__’

Grub Single User Mode

At the grub boot menu :

(1) Select a kernel
(2) Press the ‘e’ edit key
(3) Select the line starting with the word ‘kernel’


(4) Add either a ‘1’ or ‘single’ to the end of the kernel parameters


(5) Press ‘b’ to continue booting up

Enjoy.