redirecting a stdout to a file using sudo and tee
Shell Tips
September 8, 2014 | COMMENTS

When you attempt to modify a file without write permission on it, you will end-up with a permission denied error.

$ touch donottouch.txt && sudo chown root donottouch.txt
$ cat donottouch.txt
$ echo "change stuff" > donottouch.txt
-bash: donottouch.txt: Permission denied

Using sudo before echo won't help since the redirection will still apply within your shell environment. Here is few approaches to this problem.

Continue Reading
Download files from a Bash Shell
Shell Tips
July 9, 2011 | COMMENTS

Looking at downloading a file from a bash script but not sure where to start? Let me show you how to use wget, curl or download files with a shell script using Bash Redirections.

Continue Reading
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