Tag Archives: Unix

Ask me questions

Have a question about unix, linux, freebsd.  Or maybe you want some advice about configuring apache, mysql,an email server like exim, qmail, postfix, a proxy server like squid cache or antinat, dns or anything else similar. Want some help with php programming or maybe you want to create a wordpress plugin?

Feel free to ask and I'll do my best to answer it on this blog. I will publish a new blog post for each question and my answer.

You can use the contact form or ( if your question is short enough ) you can send it to me over twitter

You can follow me on twitter or subscribe to my RSS feeds if you want to be notified when I post the answer to your question.

MacOSX for Unix admins

I'm going to write some posts about doing stuff on MacOSX.

I'm a beginner mac user and I come from a Unix background. I use/administrate/patch/develop on Unix like machines ( mostly just Linux and FreeBSD ) on a daily basis.

Since MacOSX has Unix at it's roots using it shouldn't be hard for me to work with it...right...well I'll see how much it has changed.

Sometimes I find it difficult to do something on MacOSX mostly because I am used to how it is done in Unix and because I don't want or can't use the GUI tools.

The fact that most of the tutorials I find are also  explaining how to do stuff in the GUI makes this an even bigger problem.

So I decided that when I actually find out how to do what I want to do I will write a post  about it so I will not have to look for it again.

Explicitly ignorant in Unix

I'm working on a patch for antinat, to make it do some cool/weird stuff that it can't do at the moment.

In case you're wondering antinat is a great implementation of a socks server. It supports socks4, socks5 with user/password authentication, accept/reject acls based on user or ip, easy configuration in an XML file and it's also multithreaded ( ok maybe this is not so great for some but I like it ).

I'm not going to write about the patch I'm working on but maybe I'll write about that in another post.

While I was looking over it's source code I found this funny comment right before a function that was used to handle the SIGPIPE signal:

  1.  
  2. /*
  3. UNIX trivia - when is a problem a problem? When you don't ignore it.
  4. If you do nothing, well, you're not being ignorant enough. You have
  5. to be explicitly ignorant.
  6. */

This is funny but the comment has a good point. If you write an application and it tries to write to a connection that was closed, your program will receive a signal with the code SIGPIPE, which means ( according to the man page of the kill program) that if the proces does not have a default handler for SIGPIPE then it will just exit. So there you have a big problem.

The simple solution is to just set your own signal handler for SIGPIPE . So you have to set a function that will be called when the program receives a SIGPIPE and your function doesn't really have to do anything about it, so it will just ignore it and reset the handler to itself.

  1.  

But if you don't explicitly set this, your process will just die upon receiving a SIGPIPE and you really don't want that especially when writing server applications.

Blog action day for environment

Let's see what happens if a lot of bloggers write about the same thing in one day? Would it matter ? Would you make a difference. Blog action day, on October 15'th will be the day when thousands of blogs will write about the one thing.

One day per year, one topic, thousands of bloggers contributing to making a better world. This year's topic is "Environment".

I have signed up my blog and hopefully I'll post something related to Unix, Linux, Patches and Hacks to help create a better environment.

How to make linux feel like windows

Anyone missing windows ? Not me, but sometimes is good to go back to windows just to see how it was in the old days when nothing worked well and you would have a crash every few minutes or reinstall once a week.

Do that and you'll realize how privileged you are for using a Unix like os and be thankful to those that develop and contribute to it.

Don't want to reinstall it ? Well here's a little script inspired by the author of random lines ( a program that reads lines from a file or stdin, randomizes them and then outputs them ) that will make your linux system feel like windows:

  1. span style="color: #ff0000;">'{print $1}'

I recommend running the script as root and only if you understand completely what it does. You may not see immediate results, have confidence and let it run for some time like an hour or more. If you want to see results faster you can replace 3600 with 360 or even 36 or less.

You will need random lines ( rl ) installed if you want this script to run or you can modify it and replace every occurrence of "rl --count=" with "shuf -n " if you have shuf (should be there if you have coreutils and most distros have it )

Feel free to let me know how your "back to windows experience" affected you 🙂 ...