Linux Version Numbers

Kernel Version
To find out the version info for the running kernel:

$ uname -a

This will give you something like:

Linux t.example.com 2.6.18-128.1.14.el5 #1 SMP Wed Jun 17 06:40:54 EDT 2009 i686 athlon i386 GNU/Linux

Ubuntu
On the ubuntu terminal, type:

$ cat /etc/lsb-release

Which will give you something like this

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION="Ubuntu 9.10"

CentOS and Red Hat Linux
On the terminal, type:

$ cat /etc/redhat-release

This will give you something like

CentOS release 5.6 (Final)

Repair MBR from linux

Use install-mbr to overwrite the MBR:

install-mbr -i n -p D -t 0 /dev/sde
Repalce sde with proper device letter. The options are:

-i interrupt (n=none/do not display a MBR prompt)
-p partition (D=boot the partition which has bootable flag set)
-t timeout (0=do not wait before boot)

More on manpage: http://xgen.iit.edu/cgi-bin/man/man2html?install-mbr+8

Messing with iptables connection tracking

iptables -A FORWARD -m recent --name badguy --rcheck --seconds
60 -j DROP

 
iptables -A FORWARD -p tcp -i eth0 --dport 139 -m recent --name
badguy --set -j DROP

Steve’s ipt_recent website (http://snowman.net/projects/ipt_recent/)
also has some examples of usage.

/proc/net/ipt_recent/* are the current lists of addresses and informa‐
tion about each entry of each list.

Each file in /proc/net/ipt_recent/ can be read from to see the current
list or written two using the following commands to modify the list:

echo +addr >/proc/net/ipt_recent/DEFAULT
to add addr to the DEFAULT list

echo -addr >/proc/net/ipt_recent/DEFAULT
to remove addr from the DEFAULT list

echo / >/proc/net/ipt_recent/DEFAULT
to flush the DEFAULT list (remove all entries).

Ubuntu – GRE Tunnel

Creating a tunnel on Ubuntu

Edit /etc/network/interface file and add this code

auto gre1
iface gre1 inet static
    address 
    netmask 
    pointopoint 
    pre-up iptunnel add gre1 mode gre local  remote  ttl 255
    up ifconfig gre1 multicast
    post-down iptunnel del gre1

You might also need to “modprobe ip_gre” in some cases before activating the tunnel.

Ubuntu – disable USB automount

Hate it when Ubuntu unnecessarily mounts USB drives when you are doing some R&D.

Here’s a quick way to disable it.

$ gconftool-2 --type bool --set /apps/nautilus/preferences/media_automount false

You can also use gconf-editor to set it to false. Once done, just set it to true again to make it auto-mount.