mac flood

1) install dsniff

2) macof -d 255.255.255.255 -i eth0 -n 1005000

and your switch will be stupid (hub)/

MySpaceBlogger PostLinkedInWordPressVkontakteBookmark/FavoritesDeliciousGoogle ReaderShare

Get Unix time seconds from regular one format

To get Unix time seconds from regular one format just use:

date --date="Wed Aug 22 07:51:04 UTC 2007" +%s

where Wed Aug 22 07:51:04 UTC 2007is input regular time. The output will be: 1187769064.

MySpaceBlogger PostLinkedInWordPressVkontakteBookmark/FavoritesDeliciousGoogle ReaderShare

MySQL: change data folder in ubuntu

sudo su
mkdir -p /data/mysql
mv /var/lib/mysql/* /data/mysql
rm -rf /var/lib/mysql
ln -s /data/mysql /var/lib/mysql
chown -R mysql.mysql /data/mysql /var/lib/mysql

edit /etc/mysql/conf.d/datadir.cnf // create this file
[mysqld]
datadir=                /data/mysql

edit /etc/apparmor.d/usr.sbin.mysqld
after
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,

add
/data/mysql/ r,
/data/mysql/** rwk,

/etc/init.d/apparmor reload
/etc/init.d/mysql restart

MySpaceBlogger PostLinkedInWordPressVkontakteBookmark/FavoritesDeliciousGoogle ReaderShare

postgresql: join analog

Example:

I have database «WAR» with two tables:

a_table

id guildId guildName
0 100500 RealGods
1 22115 BestPlayers
... ... ...

b_table where fields «attackerGuild» and «defenderGuild» are foreign keys from a_table.

id attackerGuild defenderGuild
0 1 0
1 5 6
2 ... ...

 

I want to make select and see guildId of attacker and defender.

select a."attackerGuild", b."guildId", a."defenderGuild", c."guildId" from «a_table» a, «b_table» b, «b_table» c where (a."attackerGuild" = b."id" and a."defenderGuild" = c."id");

Now i have table:

acctackerGuild guildId defenderGuild guildId
1 22115 0 100500
5 33421 6 895656
... ... ... ...
MySpaceBlogger PostLinkedInWordPressVkontakteBookmark/FavoritesDeliciousGoogle ReaderShare

bash: increment

var=0
echo $var

0

((var++))
echo $var

1

let var++
echo $var

2

var=`expr  $var + 1`
echo $var

3

MySpaceBlogger PostLinkedInWordPressVkontakteBookmark/FavoritesDeliciousGoogle ReaderShare

Freeradius: add motp authentication

aptitude install ksh gcc libpam0g-dev -y
wget http://motp.sourceforge.net/pam_mobile_otp-0.6.2.tgz
tar -zxf pam_mobile_otp-0.6.2.tgz
cd pam_mobile_otp-0.6.2
make && make install
wget http://downloads.sourceforge.net/project/pam-script/pam-script-1.1.5.tar.gz
cd pam-script
./configure && make && make install
wget http://motp.sourceforge.net/otpverify.sh
chmod +x otpverify.sh
wget http://motp.sourceforge.net/dictionary.motp
include this file to /etc/freeradius/dictionary
mkdir -p /var/motp/{cache,users}
chown -R freerad.freerad /var/motp
create file /etc/freeradius/modules/MOTP
MOTP {
wait = yes
program = «/path/to/otpverify.sh %{User-Name} %{User-Password} %{reply:Secret} %{reply:Pin} %{reply:Offset}»
input_pairs = request
output_pairs = reply
}

add to file /etc/freeradius/sited-enabled/default (or which do you use)
Auth-Type External {
         MOTP
}

edit /etc/freeradius/users
DEFAULT Auth-Type := External
  Fall-Through = Yes
yourlogin
 Secret = e37629f6d057dcc5,
 PIN = 1234,
 Offset = 0

/etc/init.d/freeradius restart

MySpaceBlogger PostLinkedInWordPressVkontakteBookmark/FavoritesDeliciousGoogle ReaderShare

git: tag

git tag newtag

git push -u origin tag newtag

MySpaceBlogger PostLinkedInWordPressVkontakteBookmark/FavoritesDeliciousGoogle ReaderShare

Bash: Better history

To view all typed history commands in different running terminals with one user, add to  ~/.bashrc:
shopt -s histappend
PROMPT_COMMAND='history -a'

MySpaceBlogger PostLinkedInWordPressVkontakteBookmark/FavoritesDeliciousGoogle ReaderShare

default crontab editor

Add two strings in ~/.bashrc

export VISUAL="/usr/bin/vim"
export EDITOR="/usr/bin/vim"

where «/usr/bin/vim» path to your favourite editor.

Now when you will launch command «crontab -e» it'll be openned with your favourite editor.

MySpaceBlogger PostLinkedInWordPressVkontakteBookmark/FavoritesDeliciousGoogle ReaderShare

iotop collect data

iotop -oa

MySpaceBlogger PostLinkedInWordPressVkontakteBookmark/FavoritesDeliciousGoogle ReaderShare