Shell
Linux sysctl configuration and tuning script
Shell Tips
September 13, 2010 | COMMENTS

Frequently when I setup a new server (or a bunch of them) I use a small shell script that will go thru all the basic linux sysctl config. I decied to share it. I always change it a bit according to my needs and the application/services that will run on the server. Though having a script to automate some of this manual tuning is quite useful. Use it at your OWN risk. There is no silver bullet, make sure to understand each parameters and that they fit your needs/usage/network/OS.

Continue Reading
Performing Math Calculation in Bash
Shell Tips
June 14, 2010 | COMMENTS

I use math in bash scripts a lot, from simple crontab reports to Nagios monitoring plugins... Here is few small examples on how to do some maths in Bash with integers or float.

Continue Reading
Using losetup and dd to secure sensitive data (encrypted block device)
Shell Case Study
July 13, 2008 | COMMENTS

My previous post was made a long time ago, so here is a draft that I finally decide to post. Let’s see how to secure some of your data with an encrypted block device using losetup and dd.

Steps will be :

  1. Create an image with dd
  2. Build a new device using the image with an encrypt algorythm by using losetup
  3. Format the device using mkfs.ext3
  4. Mount the device and start using it !

Of course, when you have mounted the device, your data are readable to anyone who have access to the mounted directory.

Continue Reading
Printing a sequence of letters or numbers
Shell Tips
January 14, 2008 | COMMENTS

Some times, while scripting in your favorite shell (I mean Bash !! 😃 you need to print a sequence of letters or numbers. Don’t write it yourself ! Script it using seq or curly braces !

nicolas@macvin:~$ seq 1 10
1 2 3 4 5 6 7 8 9 10
nicolas@macvin:~$ seq 0 2 10
0 2 4 6 8 10
nicolas@macvin:~$ echo {1..10}
1 2 3 4 5 6 7 8 9 10
nicolas@macvin:~$ echo {a..g}
a b c d e f g

Hope this will help you while doing a loop or building some hash directories :

nicolas@macvin:~$ mkdir -p test/{1..10}/{1..10}

Enjoy !

How to flush DNS Cache in Mac OS X ?
Shell Tips
January 3, 2008 | COMMENTS

Joy ! I just get my new [Mac Book Pro][1] (2Go RAM / 2,4Ghz Core 2 Duo / 160Go HDD / etc.). So I’m playing a lot with [VMware Fusion][2] and multiple host (debian, ubuntu, solaris, windows, etc.) with a great fluidity ! A big improvement for me who was working with an old DELL Laptop with 1Ghz Celeron and 512Mo of Ram...

But, while playing with my new laptop and my multiple virtual instances I needed to flush my DNS Cache. So, here come the tips :

With Mac OS X <= 10.4 :

macvin:~ root# lookupd -flushcache

With Mac OS X > 10.5 :

macvin:~ root# dscacheutil -flushcache