Category: linux

  • Sponge – Shell command

    Today, my sed kung-foo seemed to be lacking, so I ended up having to split the sed command over a zillion lines… Normally I’d do something like : sed ‘s/foo/bar/g’ tmp.txt > tmp2.txt sed ‘s/fo2/blah/g’ tmp2.txt > tmp3.txt But this obviously gets painful after a time, a different approach would be to use sponge where…

  • exim + spamassassin subject rewriting on symbiosis

    One customer of mine has an Bytemark Symbiosis based exim mailserver which uses SpamAssassin. It works pretty well – however the : rewrite_header Subject *****SPAM***** directive in spamassassin (/etc/spamassassin/local.cf) seemed to be being ignored – and the only effect of the mail being classified as spam is/was a couple of additional headers added (X-Spam-Status: spam).…

  • netstat –tcp -lp output not showing a process id

    I often use ‘netstat –tcp -lpn’ to display a list of open ports on a server – so i can check things aren’t listening where they shouldn’t be (e.g. MySQL accepting connections from the world) and so on. Obviously I firewall boxes; but I like to have a reasonable default incase the firewall decides to…

  • Checking varnish configuration syntax

    If you’ve updated your varnish server’s configuration, there doesn’t seem to be an equivalent of ‘apachectl configtest’ for it, but you can do : varnishd -C -f /etc/varnish/default.vcl If everything is correct, varnish will then dump out the generated configuration. Otherwise you’ll get an error message pointing you to a specific line number.

  • yum changelog (Want to know what you’re about to upgrade on CentOS/RHEL?)

    Want to see what changes you’re about to apply when doing a ‘yum update’ ? Similar-ish to how ‘apt-listchanges’ works… On CentOS 5.6, try : yum install yum-changelog python-dateutil Note, python-dateutil seems to be an unmarked dependency – i.e. you get an error message like : “Dateutil module not available, so can’t parse dates” when…

  • Useful settings for history recording in bash (/etc/profile or ~/.bashrc)

    shopt -s histappend shopt -s checkwinsize export HISTCONTROL=ignoredups:ignorespace export HISTTIMEFORMAT=’%Y-%m-%d %H:%M:%S  ‘ export EDITOR=vim histappend: don’t overwrite .bash_history files on each logout; then when someone logs into the server, and messes something up, there’s a vague chance you’ll see what they did. Your history file will obviously grow to be quite big – but suppression…