Create a file with email addresses / usernames

Quickly create a list of email addresses / usernames in the format usernameprefixNumber@domain.name

 

#!/bin/bash
userprefix=$1;
numberofusers=$2;
domain=$3;
filetosave=$4
counter=1;

if [ $# -ne 4 ]; then
echo Insufficient arguments:
echo "Usage: $0 userprefix numberofusers domainname filetosave"
echo " - enter user prefix, e.g. demo"
echo " - enter number of users,e.g. 100"
echo " - enter domain/hostname, e.g. some-hostname.domain.com"
echo " - file to save the result in"
exit 1
fi

touch $4 ;


while [[ $counter -le $numberofusers ]];
do echo Creating User $counter;
echo "$userprefix$counter@$domain" >> $4;
let "counter += 1";
done

The Black Swan by Nassim Nicholas Taleb

Worth reading: Could be. Depends on how interested you are in obvious facts like the general inability to foresee unforeseeable events, how sloppy the “experts” are in terms of forecasting, how often we tend to focus on  (the rare) successes stories rather on (the much more often) failures or how incorrect is to think that just because something was it will always be.

Word reading twice: No.

Writing style: Angry Finger Waving. Most of the time. Occasional episodes of clarity and serenity. Reminds me of Larry Winget.

Predominant feeling while reading it: Annoyance.

Skipping pages: Yes. Too much mumbo jumbo.

Presence of SPAM: High. Lots of mumbo jumbo, in fact 2/3rds  of the book volume are mumbo jumbo, which could have been bearable if the writing style wasn’t so annoying.

Presence of useful information: Low. Mainly due the different examples, experiments and stories behind them. They were truly interesting and probably the one good reason to read this book.

Topics covered: See ‘Worth reading’.

Application/Motto: Expect the unexpected for it is going happen and you won’t be able to forecast it so better expect it and don’t freak out. Too much.

Conclusion: Reading this book was a little torture due the writing style. It sucked. It was not a waste of time but definitely it is not something I’ll get back to. Ever.

p.s. If you wonder should you read the book – read it.

How to install sysstat (sar) for performance statistics ?

apt-get update; apt-get install sysstat

The sysstat package contains several utilities for monitoring system performance. To enable performance data collection edit
/etc/default/sysstat
set
ENABLED="true"
restart sysstat
/etc/init.d/sysstat restart. If necessary edit the cronjob which will collect the statistics and make sure to setup a logrotate entry in order to avoid large logs.

Create files with certain size

What it does:  The script will create certain number of files with certain size. It takes two arguments – first is the number of files and the second is the size of each file ( in kilobytes ).

Usage:  ./script.sh 100 1
(this will create 100 files 1MB each)

Code:

#!/bin/bash
filecount=$1;
blocksize=$2;
counter=1;
while [[ $counter -le $filecount ]];
do echo Copying $counter;
dd if=/dev/zero of=filename$counter bs=$2k count=1024
let "counter +=1";
done